zsh
CLI
Dry run a script
zsh -n / --no-exec $scriptPrint commands and arguments as they are executed
-
For a script
zsh -x $script > $log_file 2>&1 -
For the current shell
zsh -xl > $log_file 2>&1Can be used to source the value of an environment variable
alias
oh-my-zsh
- Update:
omz update - Reload zsh:
omz reload - GitHub - ohmyzsh/ohmyzsh - Wiki - Cheatsheet (opens in a new tab)
Modules
zsh/zle (opens in a new tab)
-
Shortcuts
-
Alt + Lls
-
-
Resources
Builtins
Builtins manual page
-
man zshbuiltins -
Resources
autoload
-
autoloadtellszshto look for a file in$FPATH/$fpathcontaining a function definition, instead of a file in$PATH/$pathcontaining an executable script or binary. -
Example
-
Make
autoloaddirectory-
mkdir -p "$HOME/.zsh/autoload".Create a new directory where you want.
-
-
Add the created directory to
$FPATHexport FPATH="$HOME/.zsh/autoload/:$FPATH"
-
Add a script file in
autoloaddirectory-
echo "echo hello zsh autoload" > "$HOME/.zsh/autoload/hello-zsh-autoload"File nameiscommand name.- No need for excutable permission
- No need to define function in file
-
-
Add new command by
autoloadautoload -U hello-zsh-autoload
-
Now you can hit new command
$ hello-zsh-autoload > hello zsh autoload
-
-
Resources
compdef
hook functions
chpwd
-
Execute the specified command whenever the current working directory is changed.
-
Add a hook
add-zsh-hook chpwd <command>
-
Remove a hook
add-zsh-hook -d chpwd <command>