Live data from Hacker News

Ask HN: Best things in your bash_profile/aliases?

news.ycombinator.com

121–130 of 288 posts

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

#122
My git related aliases:

  alias master='git checkout master'
  alias f='git fetch --all'
  alias s='git status --untracked-files=all'
  # go to the last branch I worked on, excluding master and the current branch
  alias lb='git checkout `git for-each-ref --sort=-committerdate refs/heads/ | grep -v refs/heads/master$ | grep -v \`git rev-parse --abbrev-ref HEAD\`| head -n1 | cut -d \/ -f 3-`'

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

#123
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.

ah, I've been using `nyancat -f1`

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

#124

I use bash, but I like the zsh feature where you could type "cd -n" and go back n entires in your "directory stack", so I made my own version as a function. It's probably subtly broken in some way, since it's bash, but it works relatively well for me: cd() { # Set the current directory to the 0th history item cd_history[0]=$PWD if [[ $1 == -h ]]; then for i in ${!cd_history[@]}; do echo $i: "${cd_history[$i]}" done r…

Funnily enough, I did the exact same thing but for zsh's two-argument cd:

  cd() { if [[ -n "$2" && "$1" != "--" ]]; then builtin cd "${PWD/"$1"/"$2"}"; else builtin cd "$@"; fi; };
It's niche functionality, but super useful when you hit its niche:

  user@machine:/usr/src/linux-kbuild-4.9/scripts/mod$ cd 4.9 4.8
  user@machine:/usr/src/linux-kbuild-4.8/scripts/mod$ 
I'll leave combining these two as an exercise for the reader.

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

#125
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!

Excellent if you also use gundo, which gives a nice visual interface to the undo tree in vim.

https://sjl.bitbucket.io/gundo.vim/

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

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

+1. Very useful extension

[deleted]

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

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

Such a timesaver indeed. The other one would be fzf [1]. Together they get rid of the endless cd'ing and cursing on the default Ctrl-R for being rather stupid and useless :) And there are powershell counterparts as well (ZLocation and PsFzf).

[1] https://github.com/junegunn/fzf

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

#130
post #10

alias lcoate=locate alias ll="ls -l" alias ..="cd .." alias ...="cd ../.." alias mdd='mkdir $(date -I)' alias cdd='cd $(date -I)' alias xt="xtermset -T " alias dtail="dmesg|tail"

    alias cdl="cd (ls -ltr1 | grep '^d' | tail -1 | awk '{print $9}');"
cd to last directory by date.
Post reply on HN