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.


Add Comment


1. Dave on Dec 18, 2009

Cool! Provides some of the completions I get in vim (that I miss when I'm in the shell), I'll give it a try! A quick tip I picked up recently - instead of typing "clear" to clear the console, Ctrl-L does the same thing (at least on Ubuntu!). Thanks for the screencast! Dave

2. John Yerhot on Dec 18, 2009

Thanks Dave!

3. Millisami on Dec 18, 2009

I simply installed from the package source on Jaunty. It doesn't work on Ubuntu Jaunty as shown in the cast. Do I have to dig hard to make it work? coz I googled, gets a huge list of bugs problems. Any latest news on this coz the functionality is really awesome.

4. Kieran P on Dec 21, 2009

The last line is a killer command. Thank you. Keep them coming! I didn't know how much I've not been using since I switched.

5. John Yerhot on Dec 21, 2009

@Millisami Hey - I gave the zshrc a fly on 9.10 and didn't run into any issues. Do you have any other customizations in there that may be causing issues? @Kieran Thanks :)

6. ludmila on Mar 10, 2010

propecia 657 buy accutane 30451 cheap online aciphex :-P ambien cr aextch

Name

Email (not shared)

Website URL

Comment (no code please)