Hot answers tagged

373 votes
Accepted

What are the practical differences between Bash and Zsh?

First, some important things: Bash isn't going away. If you're already using bash, nothing will change for you. All that changes is that zsh will be the default login shell for new accounts, and even ...
174 votes
Accepted

ZSH: .zprofile, .zshrc, .zlogin - What goes where?

This is an attempt to write a canonical QA for this issue, as per the Meta post: Where is the list of canonical questions stored for Ask Different? I expect it to be periodically edited with the goal ...
  • 89.1k
97 votes
Accepted

zsh: bad CPU type in executable

When macOS tries to run an app that is not built for Apple silicon, macOS will prompt to install Rosetta 2 to automatically translate the app to Apple silicon. In Terminal, there is no automatic ...
  • 193k
90 votes
Accepted

How to add permanent environment variable in zsh

Bash Since Bash is typically the default shell you can open up this file in your home directory: $ vim ~/.bash_profile And add your variable to this file: export ENV_VAR=12345 You can do this ...
  • 4,458
52 votes

How do I configure my Terminal app with bash and iTerm2 with zshell and oh my zsh?

If your default system shell is bash, your Terminal should start with it. You can check it on General tab under Terminal Preferences. Should look like the following: If bash isn't your default shell, ...
  • 13k
31 votes

How to add permanent environment variable in zsh

First, execute in a terminal with zsh (Z Shell): echo 'export ENV_VAR=12345' >> ~/.zshenv Then, reload changes: source ~/.zshenv Finally, test if your new variable is set: echo $ENV_VAR ...
30 votes
Accepted

ZSH paste from the clipboard a command takes a few second to be write in the terminal

The final problem is related to zsh. oh-my-zsh is executing bracketed-paste-magic, so I ended up removing it. Because oh-my-szh doesn't have a plugin manager for this. You have to override the file: ...
24 votes

What are the practical differences between Bash and Zsh?

Change your shell now and test - no need to wait. chsh -s /bin/zsh All the scripts that depend on bash syntax will still find and call bash. the same bash from Mojave is shipping on Catalina and ...
  • 227k
24 votes

I switched to Catalina and enabled ZSH now my home/end key do not work in terminal

The other answers didn't work for me when connecting over SSH to the Mac. I had to add the following lines to my ~/.zshrc to get Home and End to work: bindkey "^[[H" beginning-of-line ...
  • 355
21 votes

I accidentally used "touch .." , is there a way to safely delete this document?

Do not delete it! In unixish filesystems (including macOS), .. is a link to the parent directory. So if you were in the directory /Users/Serax/Desktop and you ran touch .., that's equivalent to touch /...
18 votes
Accepted

Cut in CLI doesn't work as expected - returns full lines every time

You can squeeze the white spaces into a single white space in ls 's output then use cut. ls -l /usr | tr -s ' ' | cut -d ' ' -f3 but avoid parsing ls output. Here's an alternate solution. stat -f'%...
  • 9,998
17 votes

Why can't I use zsh?

@bmike has already offered the easiest solution, but I wanted to go back to the GUI instructions not working. I found that Apple’s instructions here can be confusing. Control-Clicking will not do ...
  • 20k
17 votes

Running shell or Bash scripts with zsh on macOS v11 (Big Sur)

You only need to run chmod once for a script, not each time you run it. If you don‘t want to do this, you can also use bash ./run to execute it. You can also create a text file with the executable bit ...
  • 92.8k
16 votes

How do I switch tabs when using iTerm2 with Z shell

Use the keyboard shortcuts Shift + Command + ] and Shift + Command + [ to switch to next and previous tabs respectively. The same are also available under iTerm2 Menu Bar → Window menu. The keyboard ...
  • 49.1k
16 votes

Now that MacOS Catalina has moved to zsh, can I upgrade bash 3.2.57 with 5.0.3?

You can't easily (and shouldn't) change/upgrade /bin/bash. You can install a more recent version of bash through Homebrew though, and use the information from How to use bash as default shell to ...
  • 92.8k
15 votes

How to get rid of "You have new mail." in zsh

Whether zsh checks for new mail can be adjusted through the MAILCHECK parameter as described in zshparam(1). It specifies the interval in seconds between checks for new mail, a zero turns off the ...
  • 303
15 votes
Accepted

Easiest way to migrate aliases from bash to zsh

If until now you've been using ~/.bash_profile for the loading the aliases, here are some of the ways you can migrate your aliases: 1. Copy the contents: The most assiduous and obvious way is to ...
  • 2,555
15 votes

Why can't I use zsh?

Don’t use sudo directly without some additional switches - your invocation would change root’s shell, not your user account. If your short name is mike (you can check with whoami or who am i sudo -...
  • 227k
15 votes

Did the shell ( terminal ) change in Catalina?

Your shell has been changed to Zsh, which is the default for new users on Catalina (10.15) and later. To go back to the old shell (BASH), run chsh -s /bin/bash (chsh is a "Change Shell command, the -s ...
15 votes

I accidentally used "touch .." , is there a way to safely delete this document?

touch .. didn't create a file. That is impossible on macOS because the name .. is already taken and refers to the parent directory. So, you have not created a new file, and you don't need to delete ...
  • 7,868
14 votes
Accepted

How to get rid of "You have new mail." in zsh

It tells you that you have received some mails (for example, because of your configuration of cron). The best way is to read this mail. Type mail: at least one mail should appear. You can read by ...
  • 278
14 votes

What does the time command do on zsh Mac terminal? And what is the output of "children"?

The time you use in your question is not a command, but rather a reserved word in zsh. It can be used in two different ways and its output can be customized through the $TIMEFMT parameter. There is ...
13 votes

ZSH paste from the clipboard a command takes a few second to be write in the terminal

In your ~/.zshrc file (create it if it's not there) you can set DISABLE_MAGIC_FUNCTIONS=true and it will disable bracketed-paste-magic which is causing this issue.
12 votes

How do I add a directory to PATH when using `zsh` in Sierra

export To change the path within your shell session, not system-wide, you can use the bash-style export command with zsh, as documented here. The name of the PATH variable is case-sensitive and ...
12 votes

Cut in CLI doesn't work as expected - returns full lines every time

ls doesn't use tabs, cut doesn't work with a variable number of delimeters between fields. ls -l /usr | awk '{print $3}' will work, or ls -l /usr | awk 'NR > 1 {print $3}' if you want to skip ...
  • 92.8k
12 votes
Accepted

Homebrew PATH set in .zshenv is overridden

After ~/.zshenv is sourced, the next file that is loaded is /etc/zprofile, which is provided by macOS. This script executes eval `/usr/libexec/path_helper -s` The manual for path_helper explains: ...
  • 427
11 votes
Accepted

Is it possible .zshrc is not available in ~?

There is no .zshrc file in your home dir unless you create one, which you can do with a plain text editor of your choice. Do make sure that you save the file as plain text (not rich text) and that do ...
11 votes
Accepted

Why is ~/.zprofile always sourced on every interactive session?

Each Terminal tab is a login session on macOS by default. You can run w to see that each tab/tty running a shell has a process name starting with - attached to it (which indicates a login shell). ...
  • 92.8k
10 votes
Accepted

Is there a way to list all available commands in terminal

In zsh you need to enable the completion system. Please read through man zshcompsys. To install the completion system enter the command compinstall and follow the directions. Check the fpath ...
  • 9,998
10 votes

How do I add a directory to PATH when using `zsh` in Sierra

This answer (to a different question) suggests modifying /private/etc/paths or adding a file to the directory /private/etc/paths/d. I just tried sudo nano /private/etc/paths, added /foo at the end of ...
  • 1,448

Only top scored, non community-wiki answers of a minimum length are eligible