How to change the default shell from the command line?
- iTerm2 version: 3.4.0beta2
- OS version: MacOS All
- Attach ~/Library/Preferences/com.googlecode.iterm2.plist here (drag-drop from finder into this window) N/A
How to change iTerm2 shell via CLI?
I want to change the user's iTerm2 preferences.
- I've taken a snapshot of iTerm2's preferences:
defaults read com.googlecode.iTerm2 > iTerm2.original.defaults
- Then I've changed them in the GUI:
- And then I've made another snapshot:
defaults read com.googlecode.iTerm2 > iTerm2.updated.defaults
- I can see that the difference is in "New Bookmarks" (though this seems like a rather odd name for a preference change...):
{ ... "New Bookmarks" = ( { ... Command = "/Users/aj/.local/bin/fish"; "Custom Command" = "Custom Shell"; ) }
I have no idea how I can change an array like that - or if it's even possible with the defaults
command. Is there another way?
For reference
I do know how to do this with Unix commands. That's NOT what I'm looking for.
I do NOT want to change /etc/shells
and etc/passwd
.
I've also asked this on SO: https://superuser.com/questions/1587484/how-to-change-default-shell-in-iterm2-via-command-line
Changing the user's default Shell
MY_FISH="$(which fish)"
if ! grep "$MY_FISH" /etc/shells; then
sudo 'bash echo "$MY_FISH" >> /etc/shells'
fi
sudo chsh -s "$(which fish)" "$(whoami)"
Edited by AJ ONeal