Live data from Hacker News

Ask HN: Best things in your bash_profile/aliases?

news.ycombinator.com

181–190 of 288 posts

Re: Ask HN: Best things in your bash_profile/aliases?

#181

All of my various git alises. I especially like `goops` which is very useful if you just pushed some code and realised you missed something. https://github.com/k0nserv/dotfiles/blob/7721559be40bba09cd8... alias gs="g status" alias glff="git pull --ff-only" alias glffc="git pull origin \$(current_branch) --ff-only" alias glc="git pull origin \$(current_branch)" alias gpc="git push origin \$(current_branch)" alias gpcf…

git aliases is best done with git itself, e.g. my favorite git alias is `git alias`, which lists all my git aliases.

  alias.alias config --global --get-regexp ^alias
I really like blameconflict:

  alias.blameconflict blame -L '/^>>>/'

Re: Ask HN: Best things in your bash_profile/aliases?

#183
Something funny:

  alias crontab='fuck you, '
Background:

Everyone knows that in a [in]sane workplace, you ALWAYS have to lock your machine. So this particular new hire forgot to lock her machine and one of the seniors (senior prankster, I would say) jumped into her terminal and set a crontab to run EVERY MINUTE.

So she comes back (we pair program so they were actually pairing that day) and goes on with programming for a few seconds. Then she tells us to be quiet. We're all like "WTF?" She asks, "Do you hear some robotic voice saying something?"

At this point we're all trying to listen but to no avail. She thinks it's her machine (which was connected to a 27" monitor) and proceeds to max the volume. A few seconds later, the whole office hears a thundering robotic voice say "ASSHOLE".

Everyone laughs. From that point onwards, we all had shortcuts to lock our screens, and as an added "security" feature, we aliased our crontab to actually say "fuck you" to our senior prankster.

Re: Ask HN: Best things in your bash_profile/aliases?

#184
_dynamic_ssh_creator() {

    for i in `ls ~/.ssh/keys|grep -v ".pub"|grep -v "id_dsa$"`; do

        cmd="$i"ssh

        func="function $cmd {"

        func="$func ssh -i ~/.ssh/keys/$i \$*;"

        func="$func }"

        eval $func

    done
}

_dynamic_ssh_creator

I have so many SSH keys that I can't be arsed to maintain an SSH config - especially when my brain is faster at it. This allows me to type ssh and just live my life.

Re: Ask HN: Best things in your bash_profile/aliases?

#186
post #84

Not strictly an alias, but autojump has been a huge productivity booster for me. Installing it sets up an alias of `j` which guesses the best directory to cd to based on your cd history. So instead of having to type `cd ~/Projects/someproject` you could just type `j some` and it'll end up there. https://github.com/wting/autojump

Thanks a lot! Something like that was one of the tiny tools I wrote back on DOS using Borland Pascal (I named it xcd). I figured something like this existed but I never really investigated. autojump is even included in Debian/Ubuntu, so it is trivial to use. I guess putting aside an hour per month to actively apply/install these little tools would be really useful.

Re: Ask HN: Best things in your bash_profile/aliases?

#187
post #105
post #84

Not strictly an alias, but autojump has been a huge productivity booster for me. Installing it sets up an alias of `j` which guesses the best directory to cd to based on your cd history. So instead of having to type `cd ~/Projects/someproject` you could just type `j some` and it'll end up there. https://github.com/wting/autojump

I've been using z and it's great: https://github.com/rupa/z

Second using z. I couldn't figure out how to get autojump working on windows linux subsystem but z worked perfect right out of the box.

Re: Ask HN: Best things in your bash_profile/aliases?

#188
Some simple things, but little timesavers:

  function mk() {
    mkdir -p $1 && cd &1
  }

  alias gpm='git pull master'
  alias gcm='git checkout master'
  alias grh='git reset --hard HEAD'
  alias gs='git status'
  alias gd='git diff'

  alias h='history | grep' # Use like, "h ssh" to see all ssh in your history

Re: Ask HN: Best things in your bash_profile/aliases?

#189
post #3

Since I'm working in git repos the majority of the time, I type these hundreds of times per day: alias s="git status" alias d="git diff" I prefer looking at this stuff in a terminal rather than an IDE. Reducing them to a single character just feels so good. Note: not a git alias like "git s", literally just the single character "s" in Bash itself. And coming in third: alias ..="cd .."

You should try Diff2HTML - https://diff2html.xyz/ install the cli with `npm install -g diff2html-cli`

    alias diff='diff2html -s side'

Re: Ask HN: Best things in your bash_profile/aliases?

#190
post #182

I use 'u' to navigate up parent directories: alias u="cd .." alias uu="cd ../.." alias uuu="cd ../../.." alias uuuu="cd ../../../.."

I found a much better way of handling this via SO one time, and I've kept it ever since:

  # Up command, from stackoverflow.  Takes optional number of 
  levels to cd ../
  up(){
    local d=""
    limit=$1
    for ((i=1 ; i 
Post reply on HN