Zsh, Oh My Zsh and …​

noborder

various scripts

Alternative Shell

Zsh

zsh is a shell designed for interactive use, although it is also a powerful scripting language.

Installation

MacOS
$ brew install zsh
$ chsh -s /usr/local/bin/zsh
Ubuntu
$ apt-get install zsh
$ chsh -s `which zsh`

Configuration

Default file for configuration
$ ~/.zshrc #

Basic Usage

$ ls **/*.txt       # extended globbing
$ ls *.[^oh]        # exclude
$ ls run<200-300>   # range
$ ls *.c~bar.c      # exclude file

cd completion

$ cd
chapters/  docs/      images/
$ cd /u/l/b/ <TAB>
$ cd /usr/local/bin/

Path replacement

$ cd /usr/local/bin
$ cd bin share
/usr/local/share

Suffix aliases

zshrc
alias -s md="code"
./README.md

And…​.

Programmable completion

Antigen

The plugin manager for zsh.

Antigen - installation

$ brew install antigen
zshrc
source /usr/local/share/antigen/antigen.zsh

antigen init ~/.antigenrc

Antigen - installation 2

antigenrc
# Load the oh-my-zsh's library.
antigen use oh-my-zsh

# Bundles from the default repo (robbyrussell's oh-my-zsh).
antigen bundle autojump
antigen bundle thefuck
antigen bundle git
antigen bundle web-search

# Syntax highlighting bundle.
antigen bundle zsh-users/zsh-syntax-highlighting

# Load the theme.
antigen theme robbyrussell

# Load bundle from https://github.com/....
antigen bundle djui/alias-tips

# Tell antigen that you're done and activate completion
antigen apply

Antigen - installation 2

If problem with new bundles, delete ~/.antigen/

zsh-completions

$ ls -
-1  -- single column output
-A  -- list all except . and ..
-B  -- print octal escapes for control characters
-C  -- list entries in columns sorted vertically
....
ln -s 2.4.11 latest
-F      -- remove existing destination directories
-f      -- remove existing destination files
....
  • ssh

  • kill

zsh-syntax-highlighting

  • Before : before

  • After : after

  • Before : before

  • After : after

  • Before: before

  • After: after

zsh-autosuggestions

68747470733a2f2f61736369696e656d612e6f72672f612f33373339302e706e67

Zsh extensions

Oh My Zsh

Oh My Zsh will not make you a 10x developer…​but you might feel like one.

oh my zsh github

Plugins

Examples

  • autojump # brew install autojump j …​

  • brew # aliases "bubu"

  • command-not-found # need brew tap homebrew/command-not-found

  • colored-man-pages

  • docker # aliases + docker history <TAB>

  • docker-compose # aliases + docker-compose up <TAB>

Examples 2

Powerlevel9k

Powerlevel9k is a theme for ZSH which uses Powerline Fonts.

powerlevel9k

Installation

$ brew tap caskroom/fonts
$ brew cask install font-hack-nerd-font
$ antigen theme bhilburn/powerlevel9k

Customization

Troubleshooting

If the theme is not loaded when starting a terminal, edit your .zshrc file and add the following:

POWERLEVEL9K_INSTALLATION_PATH=$HOME/.antigen/bundles/bhilburn/powerlevel9k/powerlevel9k.zsh-theme

Delete the ~/.antigen folder and restart your terminal.

Provisionning

Do you source your dotfiles ?

Resources

Various

Various

FZF

A command-line fuzzy finder

fzf

z

changez rapidement de répertoire

Shell Highlighting

de la coloration syntaxique pour la ligne de commande

ipt

Interactive Pipe To: The missing cli interactive workflow

.zshrc.d

zshrc.d
for file in ~/.zshrc.d/*.sh;
do
  source $file
done
$ ls ~/.zshrc.d/
advanced-ssh.sh  env.sh           ipt.sh           macosx.test      svn.sh
aliases.sh       golang.sh        lmfr.sh          powerlevel9K.sh  zsh-highlight.sh

alias-tips

antigem bundle djui/alias-tips
$ git commit -am
Alias tip: g cam

Merci