Skip to content

drowning-cat/zsh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TL;DR Install

1. Run

Arch
paru -S --needed --skipreview --noconfirm zsh fzf fd tree eza zoxide neovim wl-clipboard trash-cli github-cli keychain fnm-bin ttf-meslo-nerd
git clone --recurse-submodules https://github.com/drowning-cat/zsh "${XDG_CONFIG_HOME:-$HOME/.config}/zsh"
ln -sf "${XDG_CONFIG_HOME:-$HOME/.config}/zsh/zshenv" "$HOME/.zshenv"
chsh -s $(which)
Ubuntu
sudo apt update
sudo apt install -y zsh fzf fd-find tree eza zoxide neovim wl-clipboard trash-cli gh keychain
curl -fsSL https://fnm.vercel.app/install | bash
git clone --recurse-submodules https://github.com/drowning-cat/zsh "${XDG_CONFIG_HOME:-$HOME/.config}/zsh"
ln -sf "${XDG_CONFIG_HOME:-$HOME/.config}/zsh/zshenv" "$HOME/.zshenv"
mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/fonts"
cp -r "${XDG_CONFIG_HOME:-$HOME/.config}/zsh/other/fonts/MesloLGS NF" "${XDG_DATA_HOME:-$HOME/.local/share}/fonts/MesloLGS NF"
fc-cache -f
chsh -s $(which)

2. Set MesloLGS NF in your terminal

3. Reboot

Detailed Installation Process

Click to expand

1. Install dependencies

Install packages for Arch

paru -S --needed --skipreview --noconfirm\
  zsh fzf fd tree eza zoxide neovim wl-clipboard trash-cli github-cli keychain fnm-bin ttf-meslo-nerd
or using pacman
sudo pacman -S zsh fzf fd tree eza zoxide neovim wl-clipboard trash-cli github-cli keychain

fnm requires manual installation.

Install packages for Ubuntu

Click to expand
sudo apt install zsh fzf fd-find tree eza zoxide neovim wl-clipboard trash-cli gh keychain

fnm requires manual installation.

2. Set up zsh configuration

git clone --recurse-submodules https://github.com/drowning-cat/zsh "${XDG_CONFIG_HOME:-$HOME/.config}/zsh" &&\
ln -sf "${XDG_CONFIG_HOME:-$HOME/.config}/zsh/zshenv" "$HOME/.zshenv"

3. Install MesloLGS NF font

Skip this step if ttf-meslo-nerd is installed (Arch repository: Extra).

mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/fonts" &&\
cp -r "${XDG_CONFIG_HOME:-$HOME/.config}/zsh/other/fonts/MesloLGS NF" "${XDG_DATA_HOME:-$HOME/.local/share}/fonts/MesloLGS NF" &&\
fc-cache -f

[!CAUTION] Do not forget to set MesloLGS NF in your terminal of choice.

Any Nerd font is supported.

4. Make zsh your user's default shell

If necessary, migrate your Bash configuration files to zsh. You can read this arcticle: The right way to migrate your bash_profile to zsh.

sudo chsh --shell $(which) $USER

5. Reboot your system

sudo reboot

Dependencies

Click to expand

Fzf is a general-purpose command-line fuzzy finder.

Trigger search: vim ** + TAB

Key Combination Description
CTRL + t Fuzzy find all files and subdirectories of the working directory, and output the selection to STDOUT.
ALT + c Fuzzy find all subdirectories of the working directory, and run the command “cd” with the output as argument.
CTRL + r Fuzzy find through your shell history, and output the selection to STDOUT.

Meta characters table (search syntax):

Name Example
End of line .tex$
Beginning of line ^./explorer
The OR operator .xml$ | .yml$ | .tex$
The AND operator .tex$ /headers/
The NOT operator .yml$ | .xml$ | .tex$ !/headers/
Exact Match 'ti

~/.config/zsh/plugins/fzf.zsh

File itself

~/.config/zsh/zshrc

41: source "$ZFOLDER/plugins/fzf.zsh"
Click to expand

fd is a program to find entries in your filesystem. It is a simple, fast and user-friendly alternative to find. While it does not aim to support all of find powerful functionality, it provides sensible (opinionated) defaults for a majority of use cases. Used by fzf.

~/.config/zsh/plugins/fzf.zsh

1: @fd() {
2:   print -rn "fd . --hidden --exclude .git $@ | sed 's|^$HOME|~|;s|^./||'"
3: }

tree

Click to expand

Recursive directory listing program that produces a depth-indented listing of files.

~/.config/zsh/plugins/fzf.zsh

35: export FZF_CTRL_T_OPTS="--preview '[[ -d {} ]] && tree -C {} || bat --style numbers --color always --line-range :500 {}'"
36: export FZF_ALT_C_OPTS="--preview 'tree -C {}'"
37: export FZF_COMPLETION_DIR_COMMANDS="cd pushd rmdir tree ls"
Click to expand

eza is a modern, maintained replacement for the venerable file-listing command-line program ls. It uses colours to distinguish file types and metadata. It knows about symlinks, extended attributes, and Git. And it’s small, fast, and just one single binary. It is a maintained fork of exa.

~/.config/zsh/zshrc

60: alias ls='eza --icons auto'
61: alias ll='eza --icons auto --long --all'
62: alias lt='eza --icons auto --tree --level=5'
Click to expand

zoxide is a smarter cd command, inspired by z and autojump. It remembers which directories you use most frequently, so you can "jump" to them in just a few keystrokes. zoxide works on all major shells.

~/.config/zsh/zshrc

52: eval "$(zoxide init zsh)"
Click to expand

Fast Node Manager - faster alternative to nvm.

~/.config/zsh/zshrc

49: path+=("$HOME/.local/share/fnm")
...
51: eval "$(fnm env --use-on-cd)"
Click to expand

github-cli is GitHub on the command line. It brings pull requests, issues, and other GitHub concepts to the terminal next to where you are already working with git and your code.

~/.config/zsh/zshrc

53: eval "$(gh completion -s zsh)"
Click to expand

Keychain helps you to manage SSH and GPG keys in a convenient and secure manner. It acts as a frontend to ssh-agent and ssh-add, but allows you to easily have one long running ssh-agent process per system.

~/.config/zsh/zprofile

1: eval "$(keychain --eval --quiet --timeout 60)"
Click to expand

Modern version of vim.

~/.config/zsh/zshrc

4: export EDITOR='nvim'
...
67: alias v='nvim'; alias vi='v'; alias vim='v'
68: alias svim='sudo -Es nvim'; alias sv='svim'
Click to expand

Chezmoi helps you manage your personal configuration files (dotfiles, like ~/.gitconfig) across multiple machines.

~/.config/zsh/zshrc

65: alias ch='chezmoi'
Click to expand

Command-line copy/paste utilities for Wayland.

~/.config/zsh/zshrc

66: alias wl='wl-copy'
Click to expand

Alternative to rm that uses trash can.

~/.config/zsh/zshrc

69: alias t='trash'

Files

  • File ~/.zshenv (symlink to $XDG_CONFIG_HOME/zsh/zshenv) is the entry point to the configuration.
  • zsh config files are placed in $XDG_CONFIG_HOME/zsh/.zdotdir/ (zsh configuration files in the home directory are also sourced):
    • .zprofile
    • .zshrc
    • .zlogin
    • .zlogout
  • zsh history file is located in $XDG_STATE_HOME/.zsh_history.
  • zsh cache files are located in $XDG_CACHE_HOME.

XDG Base Directory

XDG directory Default path
$XDG_CONFIG_HOME ~/.config
$XDG_STATE_HOME ~/.local/state
XDG_CACHE_HOME ~/.cache

Scripts

Update submodules

git submodule update --recursive --remote

Delete configuration

Click to expand

Remove main configuration files

rm -rf "${ZFOLDER:-${XDG_CONFIG_HOME:-$HOME/.config}/zsh}/"
rm "$HOME/.zshenv"

Remove other .z-files

rm .zprofile
rm .zshrc
rm .zlogin
rm .zlogout

Remove the history file

rm "${HISTFILE:-${XDG_STATE_HOME:-$HOME/.local/state}/.zsh_history}"

Remove MesloLGS NF font

rm -rf "$HOME/.local/share/fonts/MesloLGS NF/"

Remove cache files

for pathname in \
  "${ZCOMPCACHE:-${XDG_CACHE_HOME:-$HOME/.cache}/.zcompcache}" \
  "${ZCOMPDUMP:-${XDG_CACHE_HOME:-$HOME/.cache}/.zcompdump}" \
  "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-"*; do
  rm -rf "$pathname"
done

Uninstall dependencies

Arch
using paru
paru -Rns zsh fzf fd tree eza zoxide neovim wl-clipboard trash-cli github-cli keychain fnm
or using pacman
sudo pacman -Rns zsh fzf fd tree eza zoxide neovim wl-clipboard trash-cli github-cli keychain

Remove fnm manually:

rm -rf ".fnm/"
Ubuntu
Click to expand
sudo apt-get purge --auto-remove zsh fzf fd-find tree eza zoxide neovim wl-clipboard trash-cli gh keychain

Remove fnm manually:

rm -rf ".fnm/"

Key combinations

Key Combination Command Description
Ctrl + l, F1 clear-screen-and-scrollback Clears screen and scrollback
Ctrl + z fancy-ctrl-z Collapse/expand terminal
Ctrl + Down subdir.prev Moves to the parent subdirectory
Ctrl + Up subdir.next Moves back to the child subdirectory
Right smart-partial-accept-completion Partially accepts completion
Ctrl + Right, Ctrl + Space autosuggest-accept Accepts autosuggestion
Ctrl + y autosuggest-execute Executes the autosuggestion
Ctrl + n expand-or-complete Expands or completes the command
Ctrl + p reverse-menu-complete Completes in reverse order through options
Alias Command
.., ..., ...., ..1, ..2, ..3 etc. subdir.prev
ls eza --icons
ll eza --icons --long --all
lt eza --icons --tree --level=5
- cd -
ch chezmoi
wl wl-copy
t trash
q exit
v, vi, vim nvim
svim, sv sudo -Es nvim
lvim, lv vim -c "normal '\''0" (last opened file)
g git, ...

The full list of aliases can be found in $ZFOLDER/zalias.zsh.

About

Custom zsh configuration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published