Skip to content

drowning-cat/zsh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Install

1. Run

Arch
paru -S --needed --skipreview --noconfirm\
  zsh eza fzf fd tree ttf-meslo-nerd\
  keychain neovim zoxide github-cli chezmoi wl-clipboard tmux trash-cli\
  fnm-bin
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
# Install related packages
sudo apt update
sudo apt install -y zsh eza fzf fd-find tree  # Essential
sudo apt install -y keychain neovim zoxide gh chezmoi wl-clipboard tmux trash-cli # Optional, aliases
curl -fsSL https://fnm.vercel.app/install | bash
# Setup configuration files
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"
# Install "MesloLGS Nerd Font"
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 Nerd Font"
fc-cache -f
# Caution! Change the login shell to zsh
chsh -s $(which)
# Alternatively, you can use zsh only as an interactive shell
# ~/.bashrc
# [ -x /bin/zsh ] && SHELL=/bin/zsh exec zsh

2. Set MesloLGS Nerd Font in your terminal

3. Reboot

Dependencies

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/zalias.zsh

1: if [[ -z "$XDG_CURRENT_DESKTOP" ]]; then
2:   alias ls='eza'
3:   alias ll='eza --long --all'
4:   alias lt='eza --tree --level=5'
5: else
6:   alias ls='eza --icons auto'
7:   alias ll='eza --icons auto --long --all'
8:   alias lt='eza --icons auto --tree --level=5'
9: fi
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.
Alt + `, Alt + Tab (External plugin) Trigger fuzzy find for zsh's default completion selection menu with fzf

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

43: 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

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

3: if (( $+commands[keychain] )); then
4:  eval "$(keychain --eval --quiet --timeout 60)"
5: fi
Click to expand

Modern version of vim.

~/.config/zsh/zshrc

4: export EDITOR='nvim'

~/.config/zsh/zalias.zsh

20: alias v='nvim'
21: for v in 'vi' 'vm' 'vim'; do alias $v='v'; done
22: alias svim='sudo -Es nvim'
23: alias sv='svim'
24: alias lvim='vim -c "normal '\''0"'
25: alias lv='lvim'
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

61: (( $+commands[zoxide] )) && eval "$(zoxide init zsh)"
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

60: (( $+commands[gh] )) && eval "$(gh completion -s zsh)"
Click to expand

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

~/.config/zsh/zalias.zsh

15: alias ch='chezmoi'
Click to expand

Command-line copy/paste utilities for Wayland.

~/.config/zsh/zalias.zsh

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

Tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen. It may be detached from a screen and continue running in the background, then later reattached.

~/.config/zsh/zalias.zsh

13: alias tx='tmux'
14: alias tm='tmux'
Click to expand

Alternative to rm that uses trash can.

~/.config/zsh/zalias.zsh

17: alias t='trash'
Click to expand

Fast Node Manager - faster alternative to nvm.

~/.config/zsh/zshrc

57: path+=("$HOME/.local/share/fnm")
...
59: (( $+commands[fnm] )) && eval "$(fnm env --use-on-cd)"

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 Nerd Font font

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

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

Change login shell back to Bash

chsh -s /bin/bash

Uninstall dependencies

Arch
paru -Rns zsh eza fzf fd tree ttf-meslo-nerd keychain neovim zoxide github-cli chezmoi wl-clipboard tmux trash-cli fnm-bin
Ubuntu
Click to expand
sudo apt-get purge --auto-remove zsh eza fzf fd-find tree keychain neovim zoxide gh chezmoi wl-clipboard tmux trash-cli

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
Ctrl + t - Fuzzy search for a file
Alt + c - Fuzzy search for a directory
Ctrl + r - Fuzzy search history
Alt + `, Alt + Tab fzf-tab-complete Fuzzy autocomplemete
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