Bash aliases are great ways to increase productivity by bundling commands behind a single alias. What are your favorites? Share in the comments!
For further actions, you may consider blocking this person and/or reporting abuse
Bash aliases are great ways to increase productivity by bundling commands behind a single alias. What are your favorites? Share in the comments!
For further actions, you may consider blocking this person and/or reporting abuse
Oldest comments (45)
I pretty much skip aliases and only make functions most of the time. I do have exceptions, but for the most part I have a "master" .bash_funcs config that I use on most of my machines that I have been building/editing/refactoring for MANY years that has all my favorite stuff in it.
Even for non-args stuff.
It's really hard to pick; so much of it saves time or keystrokes and I find most of them essential.
If you consider small one liner or simple functions as aliases then a few I love are:
Alternate touch
Use null to zero/create a file.
Get cursor coordinates with xdotool
Use realpath with Fuzzy Finder to get the a full path (alternate method)
I have a much smaller alias file (< 10 old aliases that plan to functionize at some point lol)
Always force make parent directories if they don't exist
'ls' with no color for various reasons
I usually either have 'ls' aliased to default list with colors (I think it's preset in some envs) and this overrides it when I need output without color
And one for fun :D Show time in the console but in alternating colors.
I have plans to rewrite this using '\r' instead of clear
I have so many functions I love I could just keep going, but my main function file is around 8500 lines so I won't do that to you lol.
Do you have these functions in a public repository? I'd love to check them out.
I've a handful of functions that I rarely use anymore like one that took an argument like
docs mdnthat would open my browser to Mozilla's documentation anddocs tilthat would open my TIL (today I learned) repository on GitHub with rendered markdown.I've only a handful of aliases as well allowing me to jump around (change dirs) into personal or work, and my dotfiles along with a couple more just masking other commands, like
alias vim=nvimsince I use Neovim andalias make=mmake(Modern Make)I keep a long history and much prefer using
reverse-i-searchto dig up a command that I use somewhat frequentlyI do actually plan on a Shell section on my main misc programming GitHub IO site that has lots of it organized, but it's still "under construction" lol. In the next couple of days I'll make a copy and clean lots of crap and redundancy out of it and put it up in a temp repo and post it back here.
I use history/fzf, but I have extra laptops that I'm always testing distros on and so I always just import my dots, but yeah I'm constantly doing Ctrl+r; FZF is just amazing.
Don’t have to mention fzf twice. It’s a must have both in my shell and Vim coupled with ripgrep. Ah! You’re a distro junkie! Haven’t settled on Arch or Gentoo?
I try anything out, but stick to Debian based. Ubuntu on main/family member machines usually. I do have a soft spot for Bodhi with Enlightenment.
I'd do
:> footo do this (well, I use:>| foobecause I havenoclobberset, but...)As for needing to output
lswithout colour, I thinkcolor=autoworks for most colour-aware commands in that you get colours, but they're suppressed if the output's to a pipe. That should cover most cases?The reason why I originally created that alias is because at some point, for whatever glitched reason, I couldn't force colors off and that was the only way I could force it off. Don't remember exactly what it was; it's been a few years and my memory has been slipping lately.
I've aliased
ptto a long string of a Python test runner (formerly on PHPUnit as well). I also aliaspyto whatever version of Python I prefer working with.One alias that I use many many times every day:
‘’’
alias cdtemp='cd $(mktemp -d)'
‘’’
It creates a new temporary directory and switch to that directory.
interesting! is that just for experimenting with files you might not keep? I'm always curious how others use filesystems, I make a lot of temp files but don't ever make a temp directory to put them in!
I don't either, but it's a cool idea because you can create a bunch of files for something and delete them all when you're done just by deleting the directory they're in. Also makes it so you don't have to worry about file name collisions between tasks.
Yes thats exactly how I use this alias. Another benefit is that in most of linux distros the ‘/tmp’ directory is cleared upon each reboot.
Whaaaaat I did not know this.
Oh no I don't have favorites, but if I did it would be these.
Now on the subject of functions I recently added these two.
That duckduckgo has
?as an alias, so I can search from the terminal like this.If anyone is curious I have those things in my dotfile repo.
I am stealing the duckduckgo one 🔥
Thanks
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
I really love the duckduckgo one
I'm curious how you set up the
?as an alias for theduckduckgo?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.
I believe this is what you are looking for.
It's not on the dotfiles because I don't know if I'm going to keep it.
Thanks! I did not have the single quotes on the
?, TIL :)You're welcome.
This also seems to work.
I use this github.com/Rafi993/DevScripts
I don't remember my own aliases so I just stick to out of the box docs.
So my favorite is a git alias. When I have PR request open and I get comments on it and need to address them and then commit and rebase them.
The need for rebasing the last commit is to squash the
fixing commentscommit into the one that the PR is actually for, ie.Add some featureI do this all the time and with git when you rebase it opens up your text editor so you can edit the commits you are rebasing to tell git whether you want to squash, drop, edit the commit messages.
I found it annoying that you have to manually type go down and change
picktosevery time I had to address PR comments. So I found a Stack Overflow answer and turned that into this alias.This improved my life a lot. Try it for yourself if you want and if anything gets messed up remember
git reflogandgit reset HEAD@{#}are your friends.I've noted down all the aliases I use here: link
My favorite ones are:
really like 'lazygit' I may steal that one :)
Sure :D
Not really a bash alias, but
is quite useful :D
oh, also this one