Live data from Hacker News

Ask HN: Best things in your bash_profile/aliases?

news.ycombinator.com

211–220 of 288 posts

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

#211
post #137

Folder Git[0], a quick hack to for example pull all my 100+ repos in one go. First version eight years ago, and I still use it every day. [0] https://gitlab.com/victor-engmark/fgit/blob/9575803b3bf277d5...

https://myrepos.branchable.com/

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

#212
post #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

Curl ipinfo.io

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

#213
post #20

I have a whole repository also including several dotfiles that I maintain for already several years [1]. Following are some snippets from the dotfiles/.alias and dotfiles/.functions files from that repository that probably are the most interesting and which I am using on a regular basis: # easier navigation alias ..="cd .." alias ...="cd ../.." alias ....="cd ../../.." alias .....="cd ../../../.." alias ~="cd ~" # Ge…

You might enjoy replacing your extract function with atool ( https://www.nongnu.org/atool/ ) which provides aunpack. It works similarly, but has niceties like creating and unpacking into a subdirectory to avoid accidentally spraying files all over the current working directory if the archive has multiple files at its root.

Similarly, the unp script automatically detects and unpacks most archives https://manpages.debian.org/jessie/unp/unp.1.en.html

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

#215
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

Shoutout as well to the various `warp` implementations[1,2,3]. Instead of guessing, you set "warp points" so for your example you can do something like:

>cd ~/Projects/someproject

>wd add . some

From then on you can use `wd some` to warp to that dir.

[1]: https://github.com/kigster/warp-dir

[2]: https://github.com/mfaerevaag/wd

[3]: https://github.com/troyxmccall/wd

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

#217
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

Shoutout as well to the various `warp` implementations[1,2,3]. Instead of guessing, you set "warp points" so for your example you can do something like: >cd ~/Projects/someproject >wd add . some From then on you can use `wd some` to warp to that dir. [1]: https://github.com/kigster/warp-dir [2]: https://github.com/mfaerevaag/wd [3]: https://github.com/troyxmccall/wd

Oh that's slick! That will be helpful for a few of my similarly named projects that autojump gets wrong sometimes.

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

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

One/two char git aliases took me to the next level:

    alias ci='git commit'
    alias co='git checkout'
    alias d='git diff'
    alias dc='git diff --cached'
    alias l='git log --oneline --graph --all --decorate'
    alias ru='git remote update'
    alias s='git status'

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

#219

My favorite new one that I have been using a lot: function cheat() { curl cht.sh/$1 } It queries the cht.sh cheatsheet of various Unix commands. 'cheat tar' prints: # To extract an uncompressed archive: tar -xvf /path/to/foo.tar # To create an uncompressed archive: tar -cvf /path/to/foo.tar /path/to/foo/ # To extract a .gz archive: tar -xzvf /path/to/foo.tgz # To create a .gz archive: tar -czvf /path/to/foo.tgz /path…

This is awesome, I ALWAYS have to google for how to untar an archive (I don't do it often enough to commit to memory) thank you!

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

#220
post #82

This one is pretty useful! Open current OSX Finder directory in Terminal: cdf () { target=`osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)'` if [ "$target" != "" ] then cd "$target" pwd else echo 'No Finder window found' >&2 fi }

can't you just wite "cd" and drag the folder into the terminal?

Yes, but that's a royal pain. 'cdf' are 3 adjacent keys.
Post reply on HN