Skip to content

zsh

Created: 2022-02-17 15:48:05 -0800 Modified: 2023-12-21 09:47:01 -0800

  • Getting started: it’s probably best to install oh-my-zsh to have some nice settings out of the box.
  • Prompt colors: You can set prompt colors to arbitrary 3-digit colors (reference): PS1="%{%F{69}%}%2~%{$reset_color%}%{$fg[cyan]%}\>%{$reset_color%}"
  • Overriding an alias temporarily: just precede the command with a backslash, e.g. “cat”.
  • Deleting lines from history: to remove sensitive entries/passwords from autosuggestions, just edit ~/.zsh_history, then make a new shell.

This is very interesting. When enabled:

  • You don’t have to type “cd” to switch into directories, so ”..” and “Documents” become valid commands.
  • ”d” is aliased to “dirs -v”, which lets you see your most recently used directories.
    • From here, you can type 1…9 as a command and it’ll go to that directory.

Basics:

  • “fzf” can be used to enter fuzzy-find mode, but so can something like “cd src/**” → pressing tab.
  • ”fzf” just lets you search through a list, so you can pipe things to it, e.g. “rg —files-without-match blog | fzf”
  • Ignore certain results by typing “!term_to_be_ignored” while inside fzf
  • When in multi-select mode (“fzf -m”), you can press tab to select multiple files, e.g. “vim fzf -m”.
  • Use a command like this to open some number of files under the current directory:
    • vim rg --files --ignore-vcs --hidden | rg -v ".git" | fzf -m -i
      • ripgrep will ignore anything in .gitignore (reference)
      • fzf: “-m” is for multi-select and “-i” is for case-insensitivity on matching