export PATH=~/workspace/swift-dev/usr/bin:"${PATH}" - bash

Taken from
https://swift.org/download/#linux
export PATH=/path/to/usr/bin:"${PATH}"
how come I have to do this every time!? every session it stops the path thing, is this because I have to have administrative privledges?

Try editing your .bashrc file and including the line:
export PATH=/path/to/usr/bin:"${PATH}"
then source your .bashrc with:
source ~/.bashrc
or:
. ~/.bashrc

Related

Why does activating conda unload my .bashrc configurations?

Ever since I added conda activate to my .bashrc file, opening up a new terminal on MacOS does seem to "unload" my .bashrc configuration. I have to manually call source ~/.bashrc every time.
Here is the content of my .bashrc file
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
. /usr/local/anaconda3/etc/profile.d/conda.sh
conda activate base
export GPG_TTY=$(tty)
If I want to use the j command now, I first have to source the .bashrc file again.
Anybody know what is causing this and how to fix it?
So after some digging, I found out that activating conda starts bash with .bash_profile, so I copied my .bashrc contents into .bash_profile and now everything works smoothly again.

macOS Catalina 10.15(beta) - Why is ~/.bash_profile not sourced by my shell?

I want to set the environment variable I added below the line to ~/.bash_profile and ~/.profile but it didn't work.
export JBOSS_HOME=/Users/{USERNAME}/Desktop/jboss7
Afterward, exit the terminal and open it again when executing echo $JBOSS_HOME I get nothing.
Apple has changed the default shell to zsh. Therefore you have to rename your configuration files. .bashrc is now .zshrc and .bash_profile is now .zprofile.
If you for some reason (as me) don't want to rename/move your ~/.bash_profile file you can do the next things:
Create a new file ~/.zprofile
Type there source ~/.bash_profile
Save and close
Run a new terminal session
You can just copy your existing bash_profile and name it zprofile and it will work fine.
Run the below command in terminal and you are set after closing and opening new terminal.
cp ~/.bash_profile ~/.zprofile
I created a new file called
/usr/local/bin/mybash
which contains a wrapper script:
/usr/local/bin/bash --init-file $HOME/.bashrc
I installed this local/bin/bash from HomeBrew.
Full Sequence of Events
brew install bash
echo "/usr/local/bin/bash --init-file $HOME/.bashrc" > /usr/local/bin/mybash
chmod +x /usr/local/bin/mybash
Then I opened the settings for terminal.app [cmd-comma]. Under the General Tab, select the radio button for Command (complete path)
In the text box change the text from /bin/zsh/ to /usr/local/bin/bash.
After you close a Terminal window, variables you set in that window are no longer available. If you want the value of a variable to persist across sessions and in all Terminal windows, you must set it in a shell startup script. For information about modifying your zsh shell startup script to keep variables and other settings across multiple sessions, see the “Invocation” section of the zsh man page.
You can use ~/.zlogin to add your variables.
Check out this reference.
changing the bash profile to zsh profile works and source it as well to see in action.
vikas#Vikas-Kumar ~ % mv .bash_profile .zsh_profile
vikas#Vikas-Kumar ~ % source .zsh_profile
You can create a simbolic link and keep your .bash_profile file with this:
ln -s .bash_profile .zsh_profile
source .zsh_profile
Any changes in .bash_profile will be reflected in .zsh_profile
Even with os Catalina /bin/bash comes for free, brew is not needed. Simply create your .bash_profile and set shell in terminal settings to /bin/bash. it automatically finds your .bash_profile. z-shell is not bash-shell and simply renaming will work in most cases but definitely is not correct.
you don't need to update the file, zsh is mac's default, put this in terminal. e.g.:
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
cp zprofile ~/.zprofile
Add to .zprofile:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
eg. by >vi .zprofile
Done

alias script is not running `source ~/.bash_profile`

I have modified my .bash_profile script with the following command:
alias shortcuts-update='nano ~/.bash_profile && source ~/.bash_profile && say profile shortcuts have been updated'
It's a great way to add aliases on the fly. The nano works well but the the source ~/.bash_profile does not! I must run it manually before any changes I have saved in .bash_profile take effect. Can anyone tell me why?

bash: :/usr/X11R6/lib:/usr/local/lib: No such file or directory

I started to install ns2, and after that any time I open the terminal I get this message
bash: :/usr/X11R6/lib:/usr/local/lib: No such file or directory
Any idea?!
I added to this to my bashrc
# LD_LIBRARY_PATH
OTCL_LIB=/home/Apps/ns-allinone-2.35/otcl-1.14
NS2_LIB=/home/Apps/ns-allinone-2.35/lib
X11_LIB=/usr/X11R6/lib
USR_LOCAL_LIB=/usr/local/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB
:$X11_LIB:$USR_LOCAL_LIB
# TCL_LIBRARY
TCL_LIB=/home/Apps/ns-allinone-2.35/tcl8.5.10/library
USR_LIB=/usr/lib
export TCL_LIBRARY=$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/home/Apps/ns-allinone-2.35/bin:/home/Apps/ns-allinone-2.35/tcl8.5.10/unix:/home/Apps/ns-allinone-2.35/tk8.5.10/unix:/home/Apps/ns-allinone-2.33/xgraph-12.2/
NS=/home/Apps/ns-allinone-2.35/ns-2.35/
NAM=/home/Apps/ns-allinone-2.35/nam-1.15/
export PATH=$PATH:$XGRAPH:$NS:$NAM
You are trying to install the NS-2 but the lines that you have added to the .bashrc file are slightly wrong. Instead you have to add the following lines in the .bashrc to set the environment variables (remember to replace /path_to/ with the location where you have extracted the ns; by looking at your post it is /home/Apps/):
# LD_LIBRARY_PATH
OTCL_LIB=/path_to/ns-allinone-2.35/otcl-1.14/
NS2_LIB=/path_to/ns-allinone-2.35/lib/
USR_Local_LIB=/usr/local/lib/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OTCL_LIB:$NS2_LIB:$USR_Local_LIB
# TCL_LIBRARY
TCL_LIB=/path_to/ns-allinone-2.35/tcl8.5.10/library/
USR_LIB=/usr/lib/
export TCL_LIBRARY=$TCL_LIBRARY:$TCL_LIB:$USR_LIB
# PATH
XGRAPH=/path_to/ns-allinone-2.35/xgraph-12.2/:/path_to/ns-allinone-2.35/bin/:/path_to/ns-allinone-2.35/tcl8.5.10/unix/:/path_to/ns-allinone-2.35/tk8.5.10/unix/
NS=/path_to/ns-allinone-2.35/ns-2.35/
NAM=/path_to/ns-allinone-2.35/nam-1.15/
export PATH=$PATH:$XGRAPH:$NS:$NAM
After this you have to restart your system or you may use
source ~/.bashrc
to reload the .bashrc. Now run the ns and you will get the %.
You may want to refer to this blog for installation instructions http://installwithme.blogspot.in/2014/05/how-to-install-ns-2.35-in-ubuntu-13.10-or-14.04.html

How can I define my text editor in bashrc?

I'm trying to set a variable containing my editor in ~/.bashrc. Unfortunately it doesn't seem to be coming through
# ~/.bashrc
export EDITOR=sublime
in terminal:
source ~/.bashrc
echo $EDITOR
=> nothing
How can I set and persist this variable?
Edit
This is my current .bashrc file:
source ~/.profile # Get the paths
source ~/.bashrc # get aliases
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
export EDITOR=sublime
Depending on your OS, check your .bash_profile or /etc/bash.bashrc
If your .bashrc isn't sourced, your .bashrc isn't read. All you need to do is source your file or drop your export command in something that is.
The .bashrc is only read in when a new shell is created and not when you log in. If you want your .bashrc read in during logins, you have to add this line to your $HOME/.bash_profile or $HOME/.profile:
[ -x $HOME/.bashrc ] && . $HOME/.bashrc
Note that $HOME/.bashrc must be both readable and executable by the user. (i.e., the file permission must be 5.. or 7..) for it to work. Make sure that your file permissions are set correctly.

Resources