I\'m on OSX and I need to put something like this, alias blah=\"/usr/bin/blah\"
in a config file but I don\'t know where the config file is.
To create a permanent alias shortcut, put it in .bash_profile file and point .bashrc file to .bash_profile file. Follow these steps (I am creating an alias command called bnode to run babel transpiler on ES6 code):
I hope this helps! Good luck!
You can do a few simple steps:
1) open terminal
2) sudo nano /.bash_profile
3) add your aliases, as example:
# some aliases
alias ll='ls -alF'
alias la='ls -A'
alias eb="sudo nano ~/.bash_profile && source ~/.bash_profile"
#docker aliases
alias d='docker'
alias dc='docker-compose'
alias dnax="docker rm $(docker ps -aq)"
#git aliases
alias g='git'
alias new="git checkout -b"
alias last="git log -2"
alias gg='git status'
alias lg="git log --pretty=format:'%h was %an, %ar, message: %s' --graph"
alias nah="git reset --hard && git clean -df"
alias squash="git rebase -i HEAD~2"
4) source /.bash_profile
Done. Use and enjoy!
The config file for scripts and programs is ~/.bashrc
and the config file that gets loaded when you use Terminal is ~/.bash_login
.
I think the best way is to just have everything in ~/.bashrc
.
For your specific question just enter (this will overwrite any existing ~/.bashrc):
echo "alias blah=\"/usr/bin/blah\"" >>~/.bashrc
into the Terminal and a ~/.bashrc
file will be created with your new alises. After that just edit the file to add new aliases, functions, settings etc.
For macOS Catalina Users:
Step 1: create or update .zshrc file
vi ~/.zshrc
Step 2: Add your alias line
alias blah="/usr/bin/blah"
Step 3: Source .zshrc
source ~/.zshrc
Step 4: Check you're alias, by typing alias on the command prompt
alias
You probably want to edit the .bashrc
file in your home directory.
create a bash_profile at your user root - ex
/user/username/.bash_profile
open file
vim ~/.bash_profile
add alias as ex. (save and exit)
alias mydir="cd ~/Documents/dirname/anotherdir"
in new terminal just type mydir - it should open
/user/username/Documents/dirname/anotherdir