Hacker News new | ask | show | jobs
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'".

2 comments

Did you know you can make your own git commands, and I don't mean just aliases?

Write a script called git-mycommand, and you can invoke it with 'git mycommand'. Tab completion works too, at least for bash + bash_completion.

Yes, I have written some of those too. Just make sure the script is in your PATH. I drop them in ~/bin/ -- which reminds me of another thing you should have in your ~/.bash_profile, if it isn't already in the template provided by your system:

    if [ -d $HOME/bin ]
    then
        PATH=$PATH:$HOME/bin
    fi
Why exactly do you love 'alias psgrep="ps aux | grep"' ? What does it get you that pgrep doesn't (or, if you need more information, 'ps u `pgrep <name>`')?
I've worked on a lot of systems that don't have pgrep.

'ps aux | grep' works everywhere