DEV Community

Discussion on: What are your preferred bash aliases?

Collapse
 
vonheikemen profile image
Heiker • Edited

Oh no I don't have favorites, but if I did it would be these.

alias -- -='cd -'

alias tvi='tmux new-session -A -D -s vi'
alias tmus='tmux new-session -A -D -s music "$(which cmus)"'
alias pomd='tmux new-session -A -D -s pomodoro'
alias pmd-start='pomd gone -e "notify-send -u critical Pomodoro Timeout"'

alias npr='pnpm run'

Now on the subject of functions I recently added these two.

# Transform the arguments into a valid url querystring
urlencode()
{
  local args="$@"
  jq -nr --arg v "$args" '$v|@uri'; 
}

# Query duckduckgo
duckduckgo()
{
  lynx "https://lite.duckduckgo.com/lite/?q=$(urlencode "$@")"
}

That duckduckgo has ? as an alias, so I can search from the terminal like this.

? how do I get out of vim

If anyone is curious I have those things in my dotfile repo.

Collapse
 
skipadu profile image
Sami Korpela

I'm curious how you set up the ? as an alias for the duckduckgo ?
I couldn't get it working when I tried and can't find that from your dotfiles either. I'm pretty new with these aliases.

Collapse
 
vonheikemen profile image
Heiker • Edited

I believe this is what you are looking for.

alias '?'='duckduckgo'

It's not on the dotfiles because I don't know if I'm going to keep it.

Thread Thread
 
skipadu profile image
Sami Korpela

Thanks! I did not have the single quotes on the ?, TIL :)

Thread Thread
 
vonheikemen profile image
Heiker

You're welcome.

This also seems to work.

alias -- ?='some-command'
Collapse
 
bhupesh profile image
Bhupesh Varshney 👾

I am stealing the duckduckgo one 🔥
Thanks

Collapse
 
wulymammoth profile image
David

Nice! I literally spend all my time in my shell and am not sure why I hadn’t thought of this or employ Alfred (macOS). May try this and see if it sticks

Collapse
 
nocnica profile image
Nočnica Mellifera

I really love the duckduckgo one