|
|
|
|
|
by bstpierre
4616 days ago
|
|
IMO the aliases for git should be in ~/.gitconfig instead. I have a bunch of these, like: [alias]
br = branch
co = checkout
ci = commit -v
sci = svn dcommit --interactive
cp = cherry-pick
l = log --pretty=oneline --abbrev-commit
l3 = log --pretty=oneline --abbrev-commit -n3
lm = log --pretty=oneline --abbrev-commit master..
rc = rebase --continue
st = status -sb
squash = !git rebase -i --autosquash $(git merge-base master HEAD)
Also, I prefer to set aliases in my ~/.functions instead of in ~/.bash_profile or ~/.bashrc. I find that this makes it easier to move the .functions file from one machine to another, especially on a lab/test machine with a shared account where I shouldn't be modifying things in the shared ~/.bashrc. To make this work, you can add this to your ~/.bashrc or ~/.bash_profile: if [ -f ~/.functions ]; then . ~/.functions; fi
This will source your .functions file if it exists when your .bashrc is run.A tweak to the "editbash" suggested alias will make it so that you don't have to reopen your terminal. My equivalent alias is "vif", for "vi .functions": alias vif='vi ~/.functions; . ~/.functions'
Note that the second command (after the semicolon) sources the modified .functions file.Lastly: brevity is king. I love 'alias psgrep="ps aux | grep"', since I use it several times a day, but to "level up your shell game", keep it short. My alias for this command is "psg". The other alias that I use all the time is "d" -- "alias d='ls -lFh --color --group-directories -v'". |
|
Write a script called git-mycommand, and you can invoke it with 'git mycommand'. Tab completion works too, at least for bash + bash_completion.