zsh
CLI
Dry run a script
zsh -n / --no-exec $script
Print 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>&1
Can 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 + L
ls
-
-
Resources
Builtins
Builtins manual page
-
man zshbuiltins
-
Resources
autoload
-
autoload
tellszsh
to look for a file in$FPATH/$fpath
containing a function definition, instead of a file in$PATH/$path
containing an executable script or binary. -
Example
-
Make
autoload
directory-
mkdir -p "$HOME/.zsh/autoload"
.Create a new directory where you want.
-
-
Add the created directory to
$FPATH
export FPATH="$HOME/.zsh/autoload/:$FPATH"
-
Add a script file in
autoload
directory-
echo "echo hello zsh autoload" > "$HOME/.zsh/autoload/hello-zsh-autoload"
File name
iscommand name
.- No need for excutable permission
- No need to define function in file
-
-
Add new command by
autoload
autoload -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>