21
zsh- a shell for humans @juandebravo

Zsh shell-for-humans

Embed Size (px)

DESCRIPTION

ZSH, a shell for human lecture during Developers Conference 2013

Citation preview

Page 1: Zsh shell-for-humans

zsh- a shell for humans

@juandebravo

Page 2: Zsh shell-for-humans

First goal: this prompt

Page 3: Zsh shell-for-humans

• Is it a new shell? No… it’s been there since 1990!

• It’s newer than bash? Well… less than a year (bash was born in 1989)!

• why has it become popular? Due to oh-my-zsh

Page 4: Zsh shell-for-humans

How to install

# Debian/Ubuntu!

> sudo apt-get install zsh!

# Mac OS X!

> brew info zsh!

> brew install --disable-etcdir zsh

Page 5: Zsh shell-for-humans

Set as default shell

> chsh -s $(which zsh)

Page 6: Zsh shell-for-humans

Nice autocompletion: cd

Page 7: Zsh shell-for-humans

Nice autocompletion: git

Page 8: Zsh shell-for-humans

Nice autocompletion: ssh

Page 9: Zsh shell-for-humans

Globbing> mkdir connect{“-api”,"-backend","-commons"}!

> ls -l **/foo.java!

> ls **/*.py(.x)!

> ls -l */**(Lk+100)!

> vi **/README.md!

Page 10: Zsh shell-for-humans

path expansion

Page 11: Zsh shell-for-humans

path replacement

Page 12: Zsh shell-for-humans

Spelling correction

Page 13: Zsh shell-for-humans

Aliases

# Normal alias!

> alias ..=“cd ..”!

Page 14: Zsh shell-for-humans

Aliases

# Global alias!

> alias -g gp=“| grep -i | grep -v grep”!

> ps -ef gp redis!

=> ps -ef | grep -i redis | grep -v grep!

Page 15: Zsh shell-for-humans

Aliases

# Suffix alias!

> alias -s md=“subl”!

> README.md!

=> subl README.md!

Page 16: Zsh shell-for-humans

Prompt

PROMPT='$(machine_name) [%~]$(rvm_prompt_info)$(nvm_prompt_info)$(python_prompt_info)$(hg_prompt_info)$(git_prompt_info)%{$reset_color%}!

%{$fg[red]%}$(prompt_char) %{$reset_color%}'

python_prompt_info() {!

[ $VIRTUAL_ENV ] && echo " %{$fg[yellow]%}~`basename $VIRTUAL_ENV`%{$reset_color%}”!

}

Page 17: Zsh shell-for-humans

Prompt

python_prompt_info() {!

[ $VIRTUAL_ENV ] && echo " %{$fg[yellow]%}~`basename $VIRTUAL_ENV`%{$reset_color%}”!

}

Page 18: Zsh shell-for-humans

Right Prompt

RPROMPT='$(battery_charge) $(current_time)'

Page 19: Zsh shell-for-humans

Libraries on top of zsh

> oh-my-zsh: https://github.com/robbyrussell/oh-my-zsh!

> Prezto: https://github.com/sorin-ionescu/prezto!

Page 20: Zsh shell-for-humans

More cool stuffhttp://fishshell.com/

Page 21: Zsh shell-for-humans

Thanks!

Juan de Bravo!

@juandebravo!

DEVCON 2013