Friday, June 23, 2006
GNU Screen - disable xterm alternate screen
By default, if you run gnu screen in an xterm (or any "alternate screen buffer"-capable terminal), any text that scrolls off the top of the screen will not be visible if you try to scroll back in your host terminal.
You can of course use the gnu screen scroll commands to scroll around in the virtual terminal, but i find that using my mac's scrollbars is much more convenient.
The easiest way to disable the alternate screen buffer in gnu screen, you can put the following in your ~/.screen.rc file:
# Disable xterm alternate screen buffer
termcapinfo * ti@:te@
The "termcapinfo" command is used to tweak host and virtual terminal settings. "ti" and "te" are termcap entries used to enter and exit the alternate buffer (man termcap or terminfo for more details). The @ symbol tells screen to turn off the specified entries.
Note that if you do this, your alternate buffer will be disabled in both your host and virtual terminals. So if previously you used vi to edit a file and the contents of the file disappeared when you quit vi, this will no longer be the case.
You can of course use the gnu screen scroll commands to scroll around in the virtual terminal, but i find that using my mac's scrollbars is much more convenient.
The easiest way to disable the alternate screen buffer in gnu screen, you can put the following in your ~/.screen.rc file:
# Disable xterm alternate screen buffer
termcapinfo * ti@:te@
The "termcapinfo" command is used to tweak host and virtual terminal settings. "ti" and "te" are termcap entries used to enter and exit the alternate buffer (man termcap or terminfo for more details). The @ symbol tells screen to turn off the specified entries.
Note that if you do this, your alternate buffer will be disabled in both your host and virtual terminals. So if previously you used vi to edit a file and the contents of the file disappeared when you quit vi, this will no longer be the case.
Thursday, June 15, 2006
Vim 7.0 - Edit jar files from within vim
Cross-posted to: http://www.vim.org/tips/tip.php?tip_id=1259
Jar files are really just zip files, and you can browse them from within vim simply by treating them the same as vim treats zip files (note to the vim maintainers: can we add these to the default distribution?)
If you want to figure out how to do this yourself, simply read this section of the help docs: http://vimdoc.sourceforge.net/htmldoc/filetype.html#new-filetype and read zipPlugin.vim in your runtime/plugins directory.
For those who are impatient, the skinny version is to place the following text into a file named ~/.vim/ftdetect/jar.vim (if you're on unix):
Jar files are really just zip files, and you can browse them from within vim simply by treating them the same as vim treats zip files (note to the vim maintainers: can we add these to the default distribution?)
If you want to figure out how to do this yourself, simply read this section of the help docs: http://vimdoc.sourceforge.net/htmldoc/filetype.html#new-filetype and read zipPlugin.vim in your runtime/plugins directory.
For those who are impatient, the skinny version is to place the following text into a file named ~/.vim/ftdetect/jar.vim (if you're on unix):
######################## FILE START #####################That's it! If you vim a jar file now, you'll be able to browse it.
au BufReadCmd *.jar,*.war,*.ear,*.sar,*.rar call zip#Browse(expand(""))
######################## FILE END #####################
Monday, June 05, 2006
Mac - Setting up SSH agent authentication
As far as I can tell, there are three main ways to use ssh-agent with your Mac.
Alternately, you can write your own script to start up a single instance of your ssh-agent in your .bashrc, use a known socket, and set up Mac environment variables to for the three SSH_* environment variables. Mac environment variables can be set up as described here http://wiki.lyx.org/Mac/Environment, and you can use the following in your environment.plist (change emmby to your username):
The keychain utility is available from darwin ports: just "port install keychain"
If you "man keychain" you'll get more information about how to use it. As per the manpage, I did the following in my .profile (adding the -q quiet option):
- Use the "SSH Agent" cocoa app
- Write your own script to run a single ssh-agent on a known socket
- Use gentoo linux's "keychain" app (available in darwinports)
Alternately, you can write your own script to start up a single instance of your ssh-agent in your .bashrc, use a known socket, and set up Mac environment variables to for the three SSH_* environment variables. Mac environment variables can be set up as described here http://wiki.lyx.org/Mac/Environment, and you can use the following in your environment.plist (change emmby to your username):
<dict>Finally, this tip using gentoo keychain seems to work quite well for me: http://www.macosxhints.com/article.php?story=20011128174701140
...
<key>SSH_AUTH_SOCK</key>
<string>/tmp/emmby-sshagent/SSHAuthSock</string>
...
</dict>
The keychain utility is available from darwin ports: just "port install keychain"
If you "man keychain" you'll get more information about how to use it. As per the manpage, I did the following in my .profile (adding the -q quiet option):
# Set up ssh-agent using keychainNote that the advantage of using the "SSH Agent" cocoa-based app is that it will use your Mac Keychain to authenticate you so you will never need to type your ssh passphrase. Another advantage is that if you have any non-Terminal applications that can benefit from ssh-agent authentication (I can't think of any right now), they will authenticate you seemlessly using "SSH Agent" but not using gentoo keychain.
host=`uname -n`
keychain -q ~/.ssh/identity ~/.ssh/id_dsa
[ -f $HOME/.keychain/$host-sh ] && . $HOME/.keychain/$host-sh