Hot answers tagged

154

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 then, you can select bash instead. Scripts are not affected. What changes is the shell for interactive use, i.e. the shell in terminals (and also a few other ...


40

If your friend changed the command that shells are opened with, you can change it back to the default login shell from Terminal's preferences: If the default login shell was changed, you can change it back to /bin/bash by running chsh -s /bin/bash. zsh is included with OS X (in /bin/zsh), but even if your friend installed a newer version of zsh, you don't ...


40

macOS Catalina and later (10.15+) Apple replaced bash with zsh as the default shell. See article. So no need to do anything. You can verify the default shell by typing echo $0 in the terminal. macOS Mojave and earlier (10.14-) See Apple Support page, Use zsh as the default shell on your Mac Surprisingly this doesn't work with the command line tools as ...


30

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, you can change it by typing: chsh -s /bin/bash To configure iTerm2 with zsh you have to open Preferences and change the command on General tab on your ...


22

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: $ZSH/lib/misc.zsh The overrides will be in this folder $ZSH_CUSTOM. Because I don't have any override I had to create the folder first: mkdir $ZSH_CUSTOM/lib/...


17

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'%Su' /usr/*


17

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 migrated users keep their old shell. Many blogs have great write-ups on moving preference files - here is one such - https://scriptingosx.com/2019/06/moving-to-...


16

@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 anything unless you first “unlock” the Users & Groups pane, as shown below in the blue box: Once you have it unlocked, be sure you are clicking in the white-...


15

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 -s chsh /bin/zsh mike Or if you know an admin short name and password you could skip the sudo initially chsh -u admin /bin/zsh @ me if you still have issues, ...


14

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 without even having to edit this file if you like, using the following one-liner: $ echo 'export ENV_VAR=12345' >> ~/.bash_profile And then confirm like so:...


13

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 change your login shell. This will not break any existing bash scripts as these refer to #!/bin/bash in the first line.


11

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 checks completely. So just put this into your zsh configuration file: # don't check for new mail MAILCHECK=0


11

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 the first line (total 0 in your example).


10

Prepend each line of a file with a capital A and write a new file- awk '{print "A"$0}' < FILE > NEWFILE


9

To prepend X to the start of every line of file, writing to newfile, in Terminal: sed 's/^/X/' file > newfile Here I'm using sed, the Unix stream editor, to use a very simple regular expression to substitute the beginning of every line (the ^ symbol) with an X.


8

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 typing its number ID. You can also directly delete it (or even multiple mails) by typing d 1-1344 (1-1344 being the range of your new mails' IDs). Leave mail with ...


8

So apparently some program (probably my MAMP) put an email in /var/mail/ Deleting this message did the trick...


7

If you're joined to an Open Directory sever, or any other directory server, the default shell will have to be specified there. In particular, if you're joined to a Microsoft Active Directory, you can use the Directory Utility to change the default shell, as described here. You can always just add zsh to your bash profile so it gets called on logon as a ...


7

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 variable echo $fpath in my situation I needed to declare the variable in my .zshrc fpath=(/usr/local/share/zsh/5.0.7/functions) This is the location of my zsh ...


7

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 the file, and opened a new tab in Terminal, and echo $PATH showed /foo as expected, in both bash and zsh shells. Assuming you've installed Maven to /opt/apache-...


6

Do you have a custom PS1 that is overriding the prompt from the theme you have selected? Check you don't have any additional lines in ~/.zshrc beyond the default? Backup your .zshrc Delete all lines beyond export PATH=$PATH:/… Reload your Terminal Do you have any plugins that are messing with things? Check ~/.oh-my-zsh/custom/plugins/ for any additional ...


6

This behavior seems to be caused by zsh’s bracketed paste feature, which is on by default as of version 5.1. I found that if I added unset zle_bracketed_paste to my zshrc then dropping files onto Terminal works correctly with zsh 5.2. (This blog post mentions bracketed-paste-magic, which seems like it could be used to support dropping files without ...


6

My shell scripts are really not that complicated Do your shell scripts have shebang lines (begin with #! /bin/bash or similar)? If not, you might have unintentionally been using a bash feature, where it runs scripts without a shebang using bash. Other shells, like dash or zsh, leave it up to the OS, which would usually use /bin/sh instead. /bin/sh on macOS ...


6

Turns out the terminal app has its own settings for which shell to use. I had to go to terminal preferences and change the option for Shells open with to Default login shell:


5

How did you uninstall it? The title bars in the screenshots show that the current command is still zsh, or maybe /bin/zsh. If you changed this setting in Terminal's preferences, change it back to the default login shell: If you changed the default login shell, you can change it back to /bin/bash with chsh -s /bin/bash.


5

The problem was the "iTerm" app's conflicting settings with the shell. To resolve, I've reset "login shell" command in iTerm preference window: iTerm.app -> Preferences -> Profiles -> General -> Command -> Click on "Login shell" Then, I executed chsh to modify it as /bin/zsh. To reproduce the problem (having $SHELL set as /bin/bash/, even though the ...


5

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 must be all-uppercase. export PATH=$PATH:/folder/you/want To verify your change, run: echo $PATH You will see results like this. /usr/local/bin:/usr/bin:/...


5

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 shortcuts remain the same irrespective of the shell you are running.


5

Ok, found what’s going on... SPACESHIP_CHAR_SYMBOL is set to ➜ (Heavy Round-Tipped Rightwards Arrow, unicode U+279C) by default vs → (Rightwards Arrow, unicode U+2192) which has the right width. PR in the making. Submitted a PR to spaceship-prompt.


4

If you can't restore /usr/ from a backup, you could first start up in single user mode (by holding command-S on startup) and run chown -R root /usr/. On my installation, all files under /usr/local/ were owned by either root or me, a few files under /usr/ were owned by _uucp, and all other files under /usr/ were owned by root: $ sudo find /usr/local ! -user ...


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