Freshly delivered FOSS screencasts - every Friday.

#16 Hello Zsh! Part 1

Zsh is a great alternative to Bash and other Unix shells. It has programmable completion, paging, and many other great features.

We'll take a good look at paging and the completion that Zsh offers in this episode and explore more in the next episode.

As mentioned in the episode, the Zsh Wiki is an excellent source for Zsh information and help with your .zshrc.

Uploaded on Dec 18, 2009 | 6:10 | Tags: bash Linux OSX zsh

Click to Play

# ~/.zshrc

PS1="[%T][%n@%M][%d]$ "
zmodload zsh/complist
autoload -U compinit && compinit

### If you want zsh's completion to pick up new commands in $path automatically
### comment out the next line and un-comment the following 5 lines
zstyle ':completion:::::' completer _complete _approximate
#_force_rehash() {
#  (( CURRENT == 1 )) && rehash
#  return 1# Because we didn't really complete anything
#}
#zstyle ':completion:::::' completer _force_rehash _complete _approximate
zstyle -e ':completion:*:approximate:*' max-errors 'reply=( $(( ($#PREFIX + $#SUFFIX) / 3 )) )'
zstyle ':completion:*:descriptions' format "- %d -"
zstyle ':completion:*:corrections' format "- %d - (errors %e})"
zstyle ':completion:*:default' list-prompt '%S%M matches%s'
zstyle ':completion:*' group-name ''
zstyle ':completion:*:manuals' separate-sections true
zstyle ':completion:*:manuals.(^1*)' insert-sections true
zstyle ':completion:*' menu select
zstyle ':completion:*' verbose yes

local _myhosts
if [[ -f $HOME/.ssh/known_hosts ]]; then
  _myhosts=( ${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*} )
  zstyle ':completion:*' hosts $_myhosts
fi
zstyle ':completion:*:kill:*:processes' command "ps x"


If you enjoyed this episode, be sure to check out the newest Technicast on Apache2. All purchases support FOSSCasts.