oh-my-zsh does not start on mac - macos

I installed oh-my-zsh as suggested in http://ohmyz.sh/.
FYI,
[~]$ zsh --version
zsh 5.0.8 (x86_64-apple-darwin15.0)
[~]$ echo $SHELL
/bin/zsh
[~]$ ls .oh-my-zsh/
LICENSE.txt cache lib oh-my-zsh.sh templates tools
README.md custom log plugins themes
Only when I type "zsh" then I can see the oh-my-zsh prompt like:
[~]$ zsh
➜ ~
Also, I tried to change my default shell to zsh:
[~]$ chsh -s /bin/zsh
Changing shell for myUserName.
Password for myUserName:
chsh: no changes made
How can I use directly oh-my-zsh whenever I start mac terminal?

Not only in System Pref>User and Group>...>User profile's shell settings, but also in Mac's terminal>Preference>ChosenProfile>Shell section, I had to change /bin/bash to /bin/zsh. after that, it works! Thank you, #RemyJ!

You have to change the default shell to zsh.
To do so use the following command.
chsh -s /bin/zsh
restart your terminal
I took it from here.
These were the steps I followed when I installed zsh.
I hope it will help you as well.

Run the following in the terminal:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Also, I tried to change my default shell to zsh:
[~]$ chsh -s /bin/zsh
try
chsh -s $zsh
that worked fine for me

I had a similar issue but I resolved it by executing the command chsh -s /bin/zsh in the terminal,then navigated to
Terminal -> Preferences -> General window
and changed the Shells open with: option to Default login shell while the command (complete path) set to /bin/zsh.This should solve your problem.

Related

Unable to set bash 5.1 as default on Mac

I installed bash-5.1 via Homebrew on my Macbook (M1-Monterey).
sachetz$ /opt/homebrew/bin/bash --version
GNU bash, version 5.1.16(1)-release (aarch64-apple-darwin21.1.0)
Added the path to /etc/shells file:
/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/opt/homebrew/bin/bash
And ran the following command to set bash-5.1 as the default:
sachetz$ chsh -s /opt/homebrew/bin/bash
However, when I restart terminal and run the bash --version command, I still see bash-3.2:
sachetz$ bash --version
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin21)
Copyright (C) 2007 Free Software Foundation, Inc.
But if I run echo $BASH_VERSION, I see bash-5.1
sachetz$ echo $BASH_VERSION
5.1.16(1)-release
Running which bash gives:
sachetz$ which bash
/bin/bash
Running echo $SHELL gives:
sachetz$ echo $SHELL
/opt/homebrew/bin/bash
When I run an echo $PATH with zsh as the default, I see /opt/homebrew/bin:
% echo $PATH
/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
However, if I run the same after the chsh to Homebrew bash, I see:
sachetz$ echo $PATH
/Applications/XAMPP/xamppfiles/bin:/Applications/XAMPP/xamppfiles/bin/php:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
I'm guessing the issue here is that /opt/homebrew/bin:/opt/homebrew/sbin is not present in the $PATH after I switch the default to Homebrew bash and restart the terminal. So the question is, why is the path variable different between the two, and how do I fix the issue?
Just needed to add /opt/homebrew/bin:/opt/homebrew/sbin: to the PATH variable in ~/.bash_profile like:
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
I suppose I missed this out as an installation step or something.
You might want to check the profiles, I believe bash checks both ~/.bashrc and ~/.bash_profile. Typically the $PATH are setup there.
For zsh, it looks at ~/.zshrc.
Also, you can check to see Terminal > Preference > Shells open with... option in the Terminal app.
which bash looks for bash under your path and bash --version is running a new bash from your path. If your path points to /bin/bash first, they'll give that bash's path/version. This isn't the correct way to verify the current shell's version.
The $BASH_VERSION & $SHELL point to the current shell and looks like it is already running the correct version.
You could also try new built-in variables, like
echo $EPOCHSECONDS

source /.bash_profile command provide error

I run the command source ~/.bash_profile and get the following error:
$ source ~/.bash_profile
-sh: /Users/chaklader/.sdkman/contrib/completion/bash/sdk: line 37: syntax error near unexpected token `<'
-sh: /Users/chaklader/.sdkman/contrib/completion/bash/sdk: line 37: ` done < <(curl --silent "${SDKMAN_CANDIDATES_API}/candidates/all")'
The login shell that I use is bin/sh:
Whats the issue here and how to solve it?
This is how I solved the issue with the provided steps:
Install Homebrew from the docs on their homepage
Install Git using Homebrew (optional, but nice to have a more up-to-date git)
brew install git
Now install bash:
brew install bash
Add this install of bash to the allowed shells list:
echo '/usr/local/bin/bash' | sudo tee -a /etc/shells;
Homebrew installs things to /usr/local/Cellar/ by default, then symlinks any binaries to /usr/local/bin, so you've now got the latest bash sitting at /usr/local/bin/bash
Finally, change your shell to use this new one:
chsh -s /usr/local/bin/bash
Open a new terminal window/tab, and run these commands to double-check your work:
$ echo $SHELL
/usr/local/bin/bash
$ echo $BASH_VERSION
5.1.8(1)-release
This also solved the issue for running the source ~/.bash_profile whenever I open a new window in the terminal.
Reference:
The answer is from here How do I install Bash >= 3.2.25 on Mac OS X 10.5.8? by user jeffbyrnes

zsh profile path is not reflected.. in terminal in Mac OS 11.2.3

I have installed mysql, trying to set path.
but somehow it does not reflect.
Is not Mysql compatible for zsh by any chance?
% brew list| grep mysql
mysql#5.7
echo 'export PATH="/usr/local/opt/mysql#5.7/bin:$PATH"' >> ~/.bash_profile
% echo 'export PATH="/usr/local/opt/mysql#5.7/bin:$PATH"' >> ~/.zshrc
% source ~/.bash_profile
then
% mysql --version
zsh: command not found: mysql
You're using zsh in your terminal, so you need to add export PATH="/usr/local/opt/mysql#5.7/bin:$PATH" into your ~/.zshrc file.
If you don't have that file, do touch ~/.zshrc then add that to your Zsh config file.
Alternatively, if you want to switch back to Bash, just do chsh -s $(which bash) (without sudo to only take effect on current logged-in user) and then restart your shell.

Fish shell and rvm - allowing login shell

When I try to use rvm in fish shell, I get this message:
ciembor#ciembor ~> rvm use 1.9.2
RVM is not a function, selecting rubies with 'rvm use ...' will not
work.
You need to change your terminal emulator preferences to allow login
shell. Sometimes it is required to use /bin/bash --login as the
command. Please visit https://rvm.io/integration/gnome-terminal/ for a
example.
I get used to use /bin/bash --login, then rvm and then starting fish from bash. But isn't there more straightforward way? I use xfce4 terminal.
I had the same issue. Download the rvm fish function from GitHub:
curl --create-dirs -o ~/.config/fish/functions/rvm.fish https://raw.github.com/lunks/fish-nuggets/master/functions/rvm.fish
Reference: http://rvm.io/integration/fish
Download the fish functions from GitHub.
curl -L --create-dirs -o ~/.config/fish/functions/rvm.fish https://raw.github.com/lunks/fish-nuggets/master/functions/rvm.fish
And activate the default Ruby manually in your config.fish file:
echo "rvm default" >> ~/.config/fish/config.fish
And you're done
Try look at bash "initialization" files like ~/.bashrc ~/.bash_profile and session "initialization" files ~/.profile /etc/profile* and add rvm related code(something like
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
) to fish "initialization" file ~/.config/fish/config.fish

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 back and forth, or turn zsh on and off?
You can just use exec to replace your current shell with a new shell:
Switch to bash:
exec bash
Switch to zsh:
exec zsh
This won't affect new terminal windows or anything, but it's convenient.
you can try chsh -s /bin/bash to set the bash as the default,
or chsh -s /bin/zsh to set the zsh as the default.
Terminal will need a restart to take effect.
I switch between zsh and bash somewhat frequently. For a while, I used to have to source my bash_profile every switch. Then I found out you can (typically) do
exec bash --login
or just
exec bash -l
if it is just a temporary switch
you can use exec as mentioned above, but for more of a permanent solution.
you can use chsh -s /bin/bash (to switch to bash) and chsh -s /bin/zsh (to switch to zsh)
For Bash, try
chsh -s $(which bash)
For zsh, try
chsh -s $(which zsh)
In Mac OS Catalina default interactive shell is zsh.
To change shell to zsh from bash:
chsh -s /bin/zsh
Then you need to enter your Mac password. Quit the terminal and reopen it. To check whether it's changed successfully to ssh, issue the following command.
echo $SHELL
If the result is /bin/zsh, your task is completed.
To change it back to bash, issue the following command on terminal.
chsh -s /bin/bash
Verify it again using echo $SHELL. Then result should be /bin/bash.
zsh has a builtin command emulate which can emulate different shells by setting the appropriate options, although csh will never be fully emulated.
emulate bash
perform commands
emulate -R zsh
The -R flag restores all the options to their default values for that shell.
See: zsh manual
you can just type bash or if you always want to use bash:
on "iTerm2"
Go to preferences > Profiles > Command
Select "Command" from the dropdown
Type bash
Test by closing iTerm and open it again
You should be able just to type bash into the terminal to switch to bash, and then type zsh to switch to zsh. Works for me at least.
Follow the below steps !
chsh -s /bin/bash
Restart terminal
check which shell is in use by echo $SHELL
source .profile
You are back with Bash !!
For me, the solution was this:
Edit:
sudo vi /etc/passwd
Find your user, for me it was for example:
ubuntu:x:1000:1001::/home/ubuntu:/bin/sh
For you it might be:
ubuntu:x:1000:1001::/home/ubuntu:/bin/zsh
And change it to:
ubuntu:x:1000:1001::/home/ubuntu:/bin/bash
If you want bash to be defaul, or the line above if you want it to be zsh by default.
You can easily switch back to bash by using command "bye"

Resources