Questions tagged [zsh]

The Z shell (Zsh) is a Unix shell that can be used as an interactive login shell and as a powerful command interpreter for shell scripting.

Questions about the Unix shell zsh (Z shell). Tag with , and for questions about zsh aliasing, command completion and configuration respectively.

The Z shell can be used as an interactive login shell and as a powerful command interpreter for shell scripting. It can be thought of as an extended Bourne shell with a large number of improvements, including some features of bash, ksh, and tcsh. However, it does not provide compatibility with POSIX or other shells in its default operating mode.

Apple's macOS switched to Zsh as the default shell for new accounts in macOS Catalina (2019). Previously, the default interactive shell was Bash (which still remains available as an option, albeit at a rather dated version).

Origin
The first version of zsh was written by Paul Falstad in 1990 when he was a student at Princeton University.

Features
Features of note include:

  • Programmable command line completion that can help the user type both options and arguments for most used commands, with out-of-the-box support for several hundred commands
  • Sharing of command history among all running shells
  • Extended file globbing allows file specification without needing to run an external program such as find
  • Improved variable/array handling
  • Editing of multi-line commands in a single buffer
  • Spelling correction
  • Various compatibility modes, e.g. zsh can pretend to be a Bourne shell when run as /bin/sh
  • Themeable prompts, including the ability to put prompt information on the right side of the screen and have it auto-hide when typing a long command
  • Loadable modules, providing among other things: full TCP and Unix domain socket controls, an FTP client, and extended math functions
  • Fully customizable

Attesting to the sheer size of this shell is the famous first sentence of the shell's manual page, which reads "Because zsh contains many features, the zsh manual has been split into a number of sections", and then goes on to list seventeen items.

Documentation

The ZSH completion system

ZSH settings

5953 questions
1071
votes
24 answers

How to permanently set $PATH on Linux/Unix

On Linux, how can I add a directory to the $PATH so it remains persistent across different sessions? Background I'm trying to add a directory to my path so it will always be in my Linux path. I've tried: export PATH=$PATH:/path/to/dir This works,…
Ali
  • 261,656
  • 265
  • 575
  • 769
761
votes
28 answers

zsh compinit: insecure directories

What does it mean and how can I fix it? zsh compinit: insecure directories, run compaudit for list. Ignore insecure directories and continue [y] or abort compinit [n]? Running the compaudit returns the follows: There are insecure…
Alex
  • 11,479
  • 6
  • 28
  • 50
540
votes
42 answers

How to add a progress bar to a shell script?

When scripting in bash or any other shell in *NIX, while running a command that will take more than a few seconds, a progress bar is needed. For example, copying a big file, opening a big tar file. What ways do you recommend to add progress bars to…
Tom Feiner
  • 20,656
  • 20
  • 48
  • 51
468
votes
13 answers

Adding a new entry to the PATH variable in ZSH

I'm using zsh terminal, and I'm trying to add a new entry (/home/david/pear/bin) to the PATH variable. I don't see a reference to the PATH variable in my ~/.zshrc file, but doing echo $PATH…
David Barreto
  • 8,887
  • 7
  • 32
  • 46
345
votes
1 answer

Complex Git branch name broke all Git commands

I was trying to create a branch from master with the following command, git branch SSLOC-201_Implement___str__()_of_ProductSearchQuery when Git suddenly stopped responding. I suspect the unescaped () are to blame, somehow. Now, whenever I try to…
ruipacheco
  • 15,025
  • 19
  • 82
  • 138
319
votes
12 answers

Switching from zsh to bash on OS X, and back again?

I'm learning to develop in Rails, and have discovered the power of zsh. However, for some of my other tasks, I wish to use normal bash. Although they are the same, I just feel comfortable with the layout of bash in some situations. How do I switch…
vpoola88
  • 3,669
  • 4
  • 20
  • 21
315
votes
31 answers

After installing Homebrew I get `zsh: command not found: brew`

➜ ~ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -e:77: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040677 It appears Homebrew is already installed. If your intent is to…
Elad Benda2
  • 13,852
  • 29
  • 82
  • 157
313
votes
23 answers

in mac always getting zsh: command not found:

I am using the z Shell (zsh) instead of the default bash, and something wrong happen so that all commands that used to work are no longer recognized: ls zsh: command not found: ls open -e .zshrc zsh: correct 'open' to '_open'…
Malloc
  • 15,434
  • 34
  • 105
  • 192
299
votes
7 answers

How do I update zsh to the latest version?

I recently switched to zsh on my Terminal.app on my OS X machine successfully. The version number of zsh is 4.3.11.
Can
  • 4,516
  • 6
  • 28
  • 50
269
votes
1 answer

Git doesn't work on MacOS Catalina: "xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing"

After upgrading to MacOS X 10.15 Catalina, I cannot run any git commands in my shell: The default interactive shell is now zsh. To update your account to use zsh, please run chsh -s /bin/zsh. For more details, please visit…
user6269864
240
votes
3 answers

What does [nyae] mean in Zsh?

I run the following command unsuccessfully dir and I get zsh: correct 'dir' to 'gdir' [nyae]? What does [nyae] mean in Zsh?
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
240
votes
13 answers

Looking for ALT+LeftArrowKey solution in zsh

I just recently switched from bash to zsh, however I miss my Alt+LeftArrowKey and Alt+RightArrowKey to go back and forth a word at a time. Right now, if I press Alt+LeftArrowKey I go back a couple of letters and then I'm stuck. I won't go any…
Mads Ohm Larsen
  • 3,315
  • 3
  • 20
  • 22
227
votes
12 answers

How can I change the color of my prompt in zsh (different from normal text)?

To recognize better the start and the end of output on a commandline, I want to change the color of my prompt, so that it is visibly different from the programs output. As I use zsh, can anyone give me a hint?
Mnementh
  • 50,487
  • 48
  • 148
  • 202
204
votes
11 answers

Is there anything in Zsh like .bash_profile?

Everytime I open the terminal, I have to source .bash_profile to enable the $JAVA_HOME or other variables.
i3wangyi
  • 2,279
  • 3
  • 15
  • 12
199
votes
14 answers

zsh problem: compinit:503: no such file or directory: /usr/local/share/zsh/site-functions/_brew

I am using apple M1 MacBook pro. When I installed oh my zsh. When I addedexport PATH="/opt/homebrew/bin:$PATH" to my ~/.zshrc file. This error was shown in my terminal: joe :: share/zsh/site-functions » source ~/.zshrc compinit:503: no such file or…
Rachel_Miller
  • 2,093
  • 2
  • 6
  • 9
1
2 3
99 100