Where's environment variables SHELL and BASH defined in OS X? [closed] - bash

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
When I execute set in my bash terminal, among many other things I see this and I can't figure out where these are defined:
BASH=/usr/local/bin/zsh
SHELL=/usr/local/bin/zsh
Since I've uninstalled zsh I wish to make sure applications are not reading these environment variables and attempt to use zsh. I've noticed that Sublime Text 3 generates errors because it reads the SHELL environment variable.
I've checked ~/.bashrc and ~/.bash_profile but there's no definitions in them where these environment variables are defined.
When checking Terminal.app's settings, it's set to use /bin/bash.
Where are these environment variables defined?

SHELL (just as HOME, USER, LOGNAME) is set from the values for login shell (home directory and user name) in the user database.
On OSX you can read out the value for your login shell from the user database with
dscl localhost -read Local/Default/Users/$USER UserShell
On most other Unix-like operating systems you can retrieve your login data with
getent passwd $USER
where the last (colon-separated) field usually denotes the login shell.
In order to change SHELL, you need to change your login shell. This can be achieved with the chsh utility. For example, if you want to set it to bash, you can do so with
chsh -s /bin/bash
The change will take effect at the next login (it is not sufficient to close and re-open the terminal window).
Note, that the full path to the shell needs to be given and the path has to be listed in /etc/shells.
BASH is set by bash itself and should expand to the absolute path used to run the current instance of bash.
The fact that it expands to /usr/local/bin/zsh in your case, leads me to suspect that it is a linked or copied version of /bin/bash. I would suggest to remove that link/file after changing the login shell an confirming that the change took effect.

Related

Export command not found on mac terminal [duplicate]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I added something to my bash_profile while trying to add Playframework to my path and something got messed up badly.
I added the following line to my .bash_profile
export PATH=$PATH:the path to my play excitable
then I saved everything and restarted my terminal. I can no longer do anything from my terminal. I can't cd into any directory, I can no longer find java, I can't open vi or nano.
I found this thread on SuperUser that suggested opening a different terminal and changing the bash profile.
I tried opening bash by typing
/bin/bash
and I was successfully able to open another terminal but I still don't have access to any of the regular unix commands. I still wasn't able to open vi or nano to remove the line that is causing the problem.
I tried downloading a new terminal application without any luck.
I tried turning on hidden files so that I can just change the file with a text editor by running the following command:
defaults write com.apple.finder AppleShowAllFiles TRUE
but since my terminal isn't working that didn't work either.
How can I fix my computer.
While this is offtopic for stackoverflow, it's also pretty simple to fix:
Start Terminal.app.
Reset $PATH:
$ export PATH=/bin:/usr/bin:/usr/local/bin
Fix ~/.bash_profile:
$ vi ~/.bash_profile
Or you can avoid setting $PATH at all with:
$ /usr/bin/vi ~/.bash_profile

PhpStorm terminal doesn't work properly on Linux Mint [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
My PhpStorm terminal doesn't work properly on Linux Mint
In Settings > Tools > Terminal my Shell path is "/bin/bash"
When I open Terminal window in PhpStorm and call ls command work properly but php and sudo and etc not work and return bash: php: command not found
Original terminal app:
Terminal in PhpStorm:
PhpStorm CLI interpreters:
Does the issue persist if your start PhpStorm from terminal, either with the command line launcher or with bin/phpstorm.sh?
When being launched from desktop/System menu, PhpStorm only sees environment variables configured in login shell, but not in interactive shell configuration files (like .bashrc or .zshrc).
Possible workarounds:
Workaround 1: make required variables available in a login shell by moving them to the corresponding shell profile config
Workaround 2: run IDE from a terminal
Workaround 3: edit the desktop launcher and set command to /path/to/shell -l -i -c "/path/to/phpstorm.sh" (make sure that the shell you specified there has the needed variables configured in its interactive shell configuration file)
see also https://youtrack.jetbrains.com/issue/IDEABKL-7589

Exit in oh-my-zsh leads to bash instead of closing window [duplicate]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
How is it possible to change the default shell? The env command currently says:
SHELL=/bin/tcsh
and I want to change that to Bash.
Try linux command chsh.
The detailed command is chsh -s /bin/bash.
It will prompt you to enter your password.
Your default login shell is /bin/bash now. You must log out and log back in to see this change.
The following is quoted from man page:
The chsh command changes the user login shell. This determines the
name
of the users initial login command. A normal user may only change the
login shell for her own account, the superuser may change the login
shell for any account
This command will change the default login shell permanently.
Note: If your user account is remote such as on Kerberos authentication (e.g. Enterprise RHEL) then you will not be able to use chsh.
You can change the passwd file directly for the particular user or use the below command
chsh -s /usr/local/bin/bash username
Then log out and log in
You should have a 'skeleton' somewhere in /etc, probably /etc/skeleton, or check the default settings, probably /etc/default or something. Those are scripts that define standard environment variables getting set during a login.
If it is just for your own account: check the (hidden) file ~/.profile and ~/.login. Or generate them, if they don't exist. These are also evaluated by the login process.

Got "permission denied" when emulating sh under zsh [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I just switched to zsh as my default Mac OS terminal shell. However, I found it won't automatically hit the ~/.profile file. After researching on Google, it looks like it can be solved by adding the following command in ~/.zprofile to emulate whatever in ~/.profile:
emulate sh -c '~/.profile'
However, I got the follwoing error when terminal starting up:
zsh:1: permission denied: /Users/XXX/.profile
Any idea why this is happening?
To accomplish your goal, you'd have to use:
emulate sh -c 'source ~/.profile' # Note the `source`; alternatively, use `.`
Without the source, ~/.profile would run in a subshell, which defeats your intent (exports wouldn't "stick"); you have to source that other file.
(The specific error you saw stems from an attempt to execute ~/.profile directly, without its being marked as executable. Note that shell profiles normally needn't be executable, because their only purpose is to be (automatically) read by a shell. It's a moot point, however, given that sourcing from within a shell is needed.)
As for what zsh initialization file to put the command in:
On macOS, if you've made zsh your default shell, then ~/.zprofile works, as all shells you'll open in a terminal will be login (zsh) shells, which will read that file.
Generally, though, ~/.zshrc is the better choice, as that file gets sourced by any interactive zsh shell, whether it's a login shell or not. It's also the file to use with the Oh My Zsh framework.
Sounds like you should be using .zshrc
Add this to ~/.zshrc:
EXPORT JAVA_HOME="whatever"
And type $ source ~/.zshrc in your terminal window, or start a new shell instance.
Follow up:
this article lists the startup files loading order which clarifies the confusion.

How to change the terminal prompt to just current directory? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am using a Macbook Pro, and I wanted to change it to the current directory and a dollar sign prompt in Terminal. I've already looked at these resources to try and solve this issue.
I tried modifying the ~/.bashrc file and saving it but it did not seem to work.
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
export PS1="\W$ ”
The last line is what I added to change the prompt.
This should be done in .bash_profile, not .bashrc.
nano ~/.bash_profile
Add a line containing this:
export PS1="\W\$ "
.bashrc is ONLY excuted when starting a sub-shell. bash login shell uses the following initialization scripts:
.bash_profile
.bash_login
.profile
You need to escape the dollar sign. Like this:
$ PS1="\W\$ "
~$ cd tmp
/Users/philip/tmp
tmp$
And once you change your .bashrc you either need to logout/back-in or . ~/.bashrc to re source it.
I would humbly recommend not doing this. Having a full path is very useful as 'tmp' directories could be anywhere. Consider using "\w" which does relative path (ie. uses ~ to represent HOME)

Resources