My problem is: whenever I'm coding, I work inside folders that are inside other folders and it's a long way to type:
cd /folder1/folder2/.../folderN
I know it's possible to make a shortcut to the folder using alias
. So it would be:
alias ep="cd /Users/thi/Dropbox/CurrentProject"
My question is, where should I put this alias? Inside /etc/bashrc
? Or should I create a file called ~/.profile
and place it there? Where should I put it?
Best Answer
I keep aliases in
~/.bash_profile
.Terminal and iTerm 2 open new shells as login shells by default. When bash is invoked as an interactive login shell, it reads
~/.bash_profile
but not~/.bashrc
. The terminal emulators on other platforms often open new shells as non-login shells, so for example bash reads~/.bashrc
but not~/.bash_profile
. OS X users often use~/.bash_profile
as the personal configuration file corresponding to~/.bashrc
on other platforms, but it is also possible to source~/.bashrc
from~/.bash_profile
or to tell Terminal or iTerm 2 to open new shells as non-login shells.If both
~/.profile
and~/.bash_profile
exist, bash only reads~/.bash_profile
when it is invoked as an interactive login shell.~/.profile
is also used by other shells and programs that might not understand the same configuration options as bash./etc/bashrc
is owned by root, and it might get replaced when you upgrade OS X.See
man bash|less +^INVOCATION
or https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html for more information.