Apple changed the default shell to zsh from bash for quite sometime. let’s customize it.People often use OH MY ZSH, I used it for a year but it seems bloated to me. Below is my simple and effective configuration.
Changing the shell prompt to Starship
- Default prompt is ugly
- Starship is the best i used.[period]
- Install starship from https://starship.rs/
- Starship toml file config (~/.config/starship.toml)
add_newline = false [character] success_symbol = "[➜](bold green)" # Clear visibility for exit codes [status] style = "bg:red" symbol = "💣 " format = '[\[$symbol$status\]]($style) ' disabled = false # These symbols will only show when battery levels are 20% or less [battery] charging_symbol = "⚡️ " discharging_symbol = "💀 " [[battery.display]] # "bold red" style when capacity is between 0% and 20% threshold = 40 style = "bold red" #[python] #python_binary = "python3" [swift] symbol = "ﯣ (orange)"
- I have added a warning when my battery is below 40 to warn me and swift language symbol.
- Add the following line in .zshrc to start starship when shell initialize.
eval "$(starship init zsh)"
Key Bindings Changes
- Edit Command in nvim (choose the editor you like)
- Bind edit command line command to Ctrl+x plus Ctrl+e [Work in Progress]
bindkey '^X^e' edit-command-line
- Once we set editor as vim, zsh changes bindings to vi, override with emacs bindings
- Check all the key bindings
bindkey | less
- I like to see suggestion(taken from previous bash history) when typing, ZSH Autosuggestion does that.
- Now i can’t work without it.
Z Script Integration
- Easily jump between directories easily.
- src: https://github.com/rupa/z/
- I have copied the
z.shfrom the above github and place it
- Adding it to the .zshrc
- Override history threshold.
HIST_STAMPS="dd.mm.yyyy" HISTFILE=~/.histfile HISTSIZE=100000 SAVEHIST=100000
- FZF integration with shell.
- I favourite is
ctrl+r, search through history with FZF.
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
NeoVim as Manpager [Optional]
- Using neovim as Man page viewer (Why not? :p)
export MANPAGER="nvim -c 'set ft=man' -"
- Created alias to edit and source Zshell config
- Customize to your likings.
alias zshcnf="nvim ~/.zshrc" alias zshsrc="source ~/.zshrc"