Skip to content

Z Shellλ︎

Z Shell (zsh) is an advanced shell environment and shell scripting language for Linux/Unix systems.

Wikipedia - Z Shell

Community Configurationsλ︎

Zsh is a very rich shell and a community configuration provides a quick way to use all those features.

  • Prezto with sane defaults, aliases, functions, auto completion and prompt themes
  • OhmyZsh framework for managing your Zsh configuration with over 300 plugins

If writing your own configuration, consider Zinit plugin manager which installs plugins from their GitHub repository.

Arch Linux has a guide to configuring Zsh.

Command Historyλ︎

Up and Down navigate through the history of commands.

Edit last commandλ︎

Edit the previous command in the history if you know what it should be, e.g. if you typed got status instead of git statusthe you could run the command

Edit last command

fc -e astro -1

Replace astro with either emacsclient, nvim, vim, nano or any preferred text editor.

Edit last command

Edit the got statusto git status and save & exit. Now the previous command is git status.

Change the -1 to if the command is further back in history (a known location)

Edit command historyλ︎

Edit the whole command history as a file, allowing easy removal of unwanted or duplicate commands using search and replace and other editing tools.

Edit entire history

```shell fc -W; astro "$HISTFILE"; fc -R ````

Replace astro with either emacsclient, nvim, vim, nano or any preferred text editor.

Shell aliases for commandsλ︎

Add aliases to $XDG_CONFIG_HOME/shell-aliases or your preferred location of shell alias definitions.

Shell Alias

# Shell history
# edit entire history
alias zsh-edit-history="fc -W; astro \"$HISTFILE\"; fc -R"

# edit previous command in history
alias zsh-edit-last-command="fc -e astro -1"

Alternativesλ︎

Referencesλ︎