OSX: Changing user shell
Today I've tried to install Oh My ZSH! as default terminal and I've resoundingly failed because of a color stuff. I knew I was not good with colors but I didn't know it would affect to terminals... The installation script inserted "/bin\033[01;31m\033[K/zsh\033[m\033[K" as my default shell - yep, with all that color crap - and, of course, that strange and colorful binary does not exist in my computer at all.
So I needed to move back to bash the default shell. As sudo -s
is not working in OSX, I've taken the other way, to play with Directory Service command line utility aka dscl
.
After read a bit the man page I concluded I can -read -change, -delete or -append records, keys and values, so it should be easy to replace zsh
with bash
:
$ dscl . -read /Users/root UserShell
UserShell: /bin\033[01;31m\033[K/zsh\033[m\033[K
$ sudo dscl . -change /Users/root UserShell /bin/zsh /bin/bash
$ dscl . -read /Users/root UserShell
UserShell: /bin\033[01;31m\033[K/zsh\033[m\033[K
Oh, replacement is not working, the fscking color stuff!. Let me give it a second try:
$ sudo dscl . -delete /Users/root UserShell
$ sudo dscl . -append /Users/root UserShell /bin/bash
$ dscl . -read /Users/root UserShell
UserShell: /bin/bash
$ sudo dscl . -append /Users/root UserShell /bin/zsh
$ dscl . -read /Users/root UserShell
UserShell: /bin/zsh
Phew!, it seems to be ok now, after all I wanted to install zsh
as my default user shell, not bash. So, got it after 1 hour instead of 5 mins. You know, color stuff is always mad, God save B&W.