ZSH

From SlackWiki
Jump to: navigation, search

Zsh is one of the most powerfull shells you can get on the face of the planet, and is my favorate (Sandman1)

Now its easier to show you the wonders of zsh with my config below, just copy this and rename it to /.zshrc:


  • Copy what is in the box below
zstyle ':completion:*' completer _complete _correct _approximate 
zstyle ':completion:*' max-errors 3 numeric 
zstyle ':completion:*' prompt '>' 
zstyle :compinstall filename '/home/$USER/.zshrc' 
autoload -U compinit 
compinit 
PS1=$'%{\e[01;32m%}%n@%m:%d%{\e[00m%}> ' 
autoload -U zfinit #This is for the built in ftp client 
EMAIL_ADDR="Hi@hi.com" 
HISTSIZE=50000 
HISTFILE="$HOME/.zsh_history" 
SAVEHIST=50000 
setopt APPEND_HISTORY 
setopt NO_BEEP 
setopt CD_ABLE_VARS 
setopt AUTO_CD 
setopt CORRECT 
setopt NO_HUP 
bindkey "\e[1" beginning-of-line 
bindkey "\e[H" beginning-of-line 
bindkey "\e[2" transpose-words 
bindkey "\e[3" delete-char 
bindkey "\e[4" end-of-line 
bindkey "\e[F" end-of-line 


Now you paste this into /.zshrc and restart ZSH. Now you should have a green prompt color:) Now first type:

removepkg <tab> 

With this you will recieve a list of packages you can remove, how cool (might need to be root). Another cool thing about zsh is that you can used the "vared" tool to edit variables, example:

vared PATH 

Now you can see the path variable and you can see that you can edit this and erase an error if you need to. Press enter when you are done editing it. Now speaking on variable editing, you can put variables into the buffer too:

print -z $PATH 

Another great feature that i use everyday is using M-q. (Alt-q basicly), For an example following the follow steps:

type "Echo hi" (without quotes) type Alt-q type echo woot and press enter see that the old command was back on the buffer, so you can execute commands before (incase you forgot somthing)

Now this is using my config, there is a tool to configure the auto completion stuff so you might want to run these:

autoload -U compinit && compinit -U 
compinstall 


Now you will have questions to answer about the different tab completion modes.

Another cool Zsh thing is the tetris game that you can play! to get to tetris just follow these following steps:

autoload -U tetris 
tetris 

hit the keys M-x and then type tetris and hit RET.


You can do quick math problems on the fly

print $(( 2 + 2 ))