Live data from Hacker News

Ask HN: Best things in your bash_profile/aliases?

news.ycombinator.com

51–60 of 288 posts

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

#52
post #34

alias grpe=grep Nothing comes close to the amount of time I saved with this one.

seriously. this was the first thing i searched for when i came to the comment thread, so i could add it if (somehow) someone hadn't already done so.

best. alias. ever.

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

#53
One useful alias I have not seen mentioned here is this:

  alias myip='curl -s https://api.ipify.org'
Just prints out my current public IP address. I also have a bunch of others mentioned in this thread, and I've abbreviated a bunch of self-explanatory docker-compose commands, e.g. dcdown, dcup, dcrestart, dcpullup, etc

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

#54
post #34

alias grpe=grep Nothing comes close to the amount of time I saved with this one.

Hehe I liked the 'lcoate' one on this page too, same idea. It might be super-useful to have a function that, if command not found and if there's an anagram of what you typed that is a command, asks if you meant that instead, y/n? (That would make computers seem a lot more intelligent!)

You might be looking for this: https://github.com/nvbn/thefuck/blob/master/README.md

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

#55
I work on a number of Go projects. This is one that lasted me for close to a decade now:

    function workspace_cd() {
        cd $@ && [ -f ".bashworkspace" ] && source .bashworkspace
    }
    alias wscd="workspace_cd"
Each .bashworkspace file contains something like this:

    export GOPATH={PATH HERE}
    export PATH=$GOPATH/bin:$PATH
    export GHC_PACKAGE_PATH={PATH HERE}

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

#56
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 .."

alias ..="cd .." If you use zsh, typing a directory name changes to it automatically. It’s almost always a very delightful thing.

Bash has this as well

  set autocd

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

#57

This is tiny, but I've gotten a surprising amount of mileage out of aliasing 'fx' to firefox --new-instance --profile $(mktemp -d) which pops open a new instance of Firefox with a completely clean, temporary profile. Super useful for testing sites or add-ons without influencing (or being influenced by) by my normal browsing profile.

I have a similar command, except it keeps the existing addons from my main profile. Which is useful as I need a proxy for different environments for work.

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

#59
Some Git aliases I use constantly, with a rebase-heavy workflow:

    di = diff
    dc = diff --cached

    ap = add -p
    unstage = reset HEAD -p
    discard = checkout -p

    ci = commit -v
    ca = commit -va
    amend = commit -v --amend
    reword = commit -v --amend --only
    extend = commit -v --amend --no-edit

    ri = rebase -i
    rem = rebase master
    rim = rebase -i master
    red = rebase development
    rid = rebase -i development
    continue = rebase --continue
    skip = rebase --skip

    pu   = push -v --progress
    poof = push -v --progress --force-with-lease
    pusu = -c push.default=current push -v --progress --set-upstream

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

#60
post #27

Out of everything I like this little alias the most: cls="clear; ls" It harkens back to DOS. Clearing the screen followed by ls happens surprisingly often, if not just to start things in "clean slate". I'm quite fond of it.

My muscle memory is to set on CTRL+L, ls. But I like it, and the call back to DOS days :)
Post reply on HN