DEV Community

Discussion on: What are some useful bash aliases you use?

Collapse
 
vonheikemen profile image
Heiker • Edited

The only use case I have for du

alias duh='du -d 1 -h'

For directory navigation I prefer numbers.

alias -- -='cd -'
alias c1='cd ..'
alias c2='cd ../..'
alias c3='cd ../../..'
alias c4='cd ../../../..'

Some shortcuts for common tmux commands

alias ta='tmux attach -t'
alias tl='tmux list-sessions'
alias ts='tmux new-session -A -D -s'
alias tmus='ts music "$(which cmus)"'

alias pmd-start='ts pomodoro gone -e "notify-send -u critical Pomodoro Timeout"'

That last one uses: gone.

And some cool key bindings. I put these in a .inputrc file in my home.

# Up Arrow
"\e[A": history-search-backward

# Down Arrow
"\e[B": history-search-forward

This changes the behavior of the Up and Down arrows, if you have some text in your prompt it will perform a search using that text. Is like a "prefix search". Let's say I have these three commands in my history.

vim /tmp/test.txt
nvim /tmp/test.txt
echo "a string with vi in it"
vim /tmp/other-text.txt

If you start writing vi and then hit the Up arrow it will only cycle through the commands that start with vi. In this case it will skip nvim and the one that has vi in the middle.

If you are not a fan of changing the arrow keys behavior I suggest using these.

# Alt + k
"\ek": history-search-backward

# Alt + j
"\ej": history-search-forward

You can find more aliases and functions on my dotfiles.

Collapse
 
paraspl01t profile image
Tushar Tyagi

I'll steal you directory navigation aliases.