Live data from Hacker News

Ask HN: Best things in your bash_profile/aliases?

news.ycombinator.com

111–120 of 288 posts

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

#114
Strictly speaking, tmux is out of scope of the question, but I hope some people would be interested.

I found myself needing to use deeply nested tmux sessions a few times and navigating between nestings is a huge pain under a vanilla setup. Using some configuration trickery, I was able to hack in keys to "focus" between nesting levels. Here's a repo I have it sitting under:

https://github.com/xelxebar/tmux-addons/tree/master/nesting

The code should be relatively drop-in and the README not terrible.

I'd love to hear thoughts.

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

#115

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.

Please share how you did do that, that sounds awesome!

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

#116
I have a bunch of project/location specific environment preparing handles in my .aliases file.

Stuff like:

alias @projectName="cd $project && alias java='/some/specific/version' && export SOME_VAR=value"

or

alias @untrustedWifi="tor && torbrowser && set up an SSH tunnel to access mail etc"

I can't really share the actual contents, because they depend on a boatload of scripts in my ~/bin dir and they're all pretty specific to my environment.

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

#118
post #80

Can I add something from .vimrc? If you put the commands: set undofile set undodir=~/.vim/undodir You get infinite undo in your files. Now when you go into a file, delete or add some text and close your terminal down, the next time you enter vim you can (re|un)do previous operations. Has saved my ass more times than I care to mention over my career!

This is awesome! Be sure to mkdir ~/.vim/undodir first as vim won't do it for you (or didn't for me)

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

#119
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…

> alias .....="cd ../../../.."

How often do you use that and how often do you get it right? :-)

My cd related aliases are the following. Especially the . is surprisingly useful, although most of the time I only use .2 and .3

  alias ..='cd ../'
  alias .1='cd ../'
  alias .2='cd ../../'
  alias .3='cd ../../../'
  alias .4='cd ../../../../'
  alias .5='cd ../../../../../'
  # sometimes, the space gets swallowed
  alias cd.='cd .'
  alias cd..='cd ..'
But that gave me an idea for another useful directory changer: "go to project root".

Project root definition could vary, although nowadays it is probably "go to the first directory upstream with a .git directory"

Edit: found this elsewhere in this discussion posted by jgresty https://news.ycombinator.com/item?id=18901834

  # go to root git directory
  alias cdgit='cd $(git rev-parse --show-toplevel)'

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

#120

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 can't believe i never thought of using command line switches for that kind of stuff, i always just have firefox set to forget all data on close.

Not exactly a bash alias, but might be useful too: Since I often get bug reports for specific versions of firefox, i've set up a small script for downloading and starting a given firefox version: https://pastebin.com/t2PHxJqE

Post reply on HN