Tag: zsh
SSH Host Completion – zsh Stylee
by Mez on Dec.06, 2009, under Personal
Ok, so recently, Richard Johnson and Michael Lustfield blogged about tab completion for SSH hosts.
I’m an avid user of zsh, and have my own way of doing this (liberally stolen from Daniel Silverstone).
Now, this requires a little setup to start with, as some Linux Distributions have a habit of creating “hashed” known_hosts files. So, what I’ve done, is before I ever SSH into a host, I add the following line to my ~/.ssh/config
HashKnownHosts no
From here, I can then add the following line to my ~/.zshrc
zstyle -e ':completion::*:*:*:hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })'
Now, when I try and ssh into a host, I can use tab completion to complete any host I’ve previously ssh’d into and any new hosts I ssh into get automatically added to the list
zsh seems to be getting a lot of press of late …
by Mez on Dec.17, 2008, under Personal
And so it should – it’s an awesome shell.
Anyway, I’ve just spent a lot of time sorting out my zsh so it does titles in the right way. By this, I mean changing the title of your xterm window, and/or your screen window.
Anyway, here’s the code that I use for my zsh titles
precmd () {
case $TERM in
screen)
print -Pn "\e]0;%n@%m: %~\a"
print -Pn "\ekzsh: %~\e\\"
;;
xterm*|rxvt)
print -Pn "\e]0;%n@%m: %~\a"
;;
esac
}
preexec () {
case $TERM in
screen)
print -Pn "\e]0;%n@%m: $1\a"
print -Pn "\ek$1\e\\"
;;
xterm*|rxvt)
print -Pn "\e]0;%n@%m: $1\a"
;;
esac
}
I find this works in the same way that the default bash shell does
though – it also works quite nicely with screen, and sets the screen titles for you too
Also – my prompt lines are (inspired by Daniel Silverstone circa 2005)
export RPROMPT='%B%d%b %t ' export PROMPT='%B%n@%m %#%b '
Happy zsh’ing folks!
