Content for people that build.

Customizing Terminal

iTerm 2 & Powerlevel10k

  1. Install iTerm2
  2. Install Powerlevel10k

You can use Homebrew:

brew install romkatv/powerlevel10k/powerlevel10k`

echo ‘source /usr/local/opt/powerlevel10k/powerlevel10k.zsh-theme’ >>! ~/.zshrc

Check if the .zshrc file was written, if not, touch the file and add the source line above. Restart iTerm and the p10k config should start automatically.

ZSH Autosuggestions

Fish-like autosuggestions for zsh: zsh-autosuggestions Install.md

cd

git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions

nano .zshrc
# Add this line: source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh

# Reload config without restart
. ~/.zshrc 

Case Insensitive Autocompletion

In MacOS most directory names are capitalised. So changing directories from Terminal will become tiring quickly as you need to properly capitalise directory names. It's much better to just write the name in lower case, press tab and have zsh capitalise it if needed.

To achieve this, edit the .zshrc file and add the following:

# case insensitive path-completion
zstyle ':completion:*' matcher-list 'm:{:lower:]:upper:]}={:upper:]:lower:]}' 'm:{:lower:]:upper:]}={:upper:]:lower:]} l:|=* r:|=*' 'm:{:lower:]:upper:]}={:upper:]:lower:]} l:|=* r:|=*' 'm:{:lower:]:upper:]}={:upper:]:lower:]} l:|=* r:|=*'

# partial completion suggestions
zstyle ':completion:*' list-suffixes
zstyle ':completion:*' expand prefix suffix

# Improved ZSH autocompletion
autoload -Uz compinit && compinit

Aliases

Aliases are quite handy, but it’s a good idea to not rely on them to heavily, as it can be quite frustrating when you don’t have access to them.

Add to the .zshrc file:

# Aliases
alias ll="ls -lahL"
alias con="tail -40 -f /var/log/system.log"

Search Commands History

The bindkey command tells the shell to do a history search when the up and down arrow keys are used. So in this mode, you can type git and then use the up & down arrow keys to move through the previous used commands.

Add to the .zshrc file:

# Search Previous Used Commands using arrows
bindkey '\e[A' history-search-backward
bindkey '\e[B' history-search-forward

Reload the config file without restarting Terminal

. ~/.zshrc


Published on 2020-05-24 14:26:00 +0000

Tagged with: