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
Latest comments (45)
The next time you are debugging a bash script, give this one a try:
I use this function to quickly (shallow) clone a github repo and open it with my favorite editor.
I like to make my
~/.bash_profile
able to be re-sourced multiple times. Because I'll change it, and then re-source it. But I don't want my PATH to become super long with duplicates. So I check PATH before appending or prepending a path.I use SCOWL to look up words frequently. So I like to be able to grep words no matter where I am.
I'm often on a Macintosh using Terminal.app, and I like to be able to clear the screen and clear the scrollback buffer in one command.
I'm always making little C++ toy programs to test out a thought. I like to compile in a specific way, so a handy alias to the rescue.
I often want to go up directory levels or to HOME quickly.
When I do
mkdir
I often follow it withcd
to that directory. So I've combined the operations. (Sometime I tweak it to be lazy and cd into the directory if it already exists. Sometimes I don't like that behavior, and take it out.)Sometimes I'm editing an HTML file (and possibly associated CSS and JavaScript files), and I want Chrome to reload my local page for me when it changes. (I think I got fswatch through brew.)
..
iscd ..
e
is$EDITOR
(gvim on Linux, mvim on Mac)e.
ise .
to open $EDITOR on the current folderg
is git and I use git aliasesci
co
pus
pul
for sub-commandsdk
is docker anddc
is docker-composeAnd we have a rich
bin
folder on each project with specific scripts likebin/qa_deploy_branch
etcThe usuals:
A shortcut:
c
to be able to quickly jump to any of my local project directories inside my~/Code
directory.Fish shell function:
Full source (including tab completion) installable using Fisher.
Also,
vpn
to connect to or disconnect from corporate (Cisco AnyConnect) VPN (source).I think that my 2 favortites and the 2 I use more are, no doubt:
Wait, what is that first one foist?
I didn't know what it was doing until you asked. I've had it copy/pasted around my dot-files many times. I've just realized now that it does not work on BASH, only on ZSH, sorry :(
EDIT: I mean... I know I always use
e
to open my editor. What I didn't know was why was I using such a complex alias to do it.TL;DR:
It uses
$VISUAL
or$EDITOR
and makes sure that it properly handles any extra parameter given to it. So somehting linevim -a -b -c
works.Detailed explanation
Got it from here github.com/sorin-ionescu/prezto/bl...
What it does If I'm not mistaken is to alias
e
to either the value of$VISUAL
or$EDITOR
. But to only do that it would be enough with:There's also this
(z)
that I just learned on ZSH is an expansion flag. Looking into ZSH manual it says:but I still didn't know what it means... so I tried to do:
If I then I've tried
That doesn't happen if I try with
(z)
flag on the expansionalias e='${(z)VISUAL:-${(z)EDITOR}}'
.PS: Thanks a lot for making me look it up :)
Please write this up into an article or I will, it’s great! And since OS X switched from Bash to zsh I Can actually use it!
Done! dev.to/nflamel/til-how-my-complica...
I'll try to see if I have more things like that around my dot-files to see which ones are worthy of some more articles.
Here are a few of mine:
Make log times human readable
Remove editor backup files
And a couple of functions (in ~/.bashrc)
Change to my ~/bin directory
Quick calculation
I have several aliases that just cd to directories I use a lot.
I have a simple activity log program I wrote in bash that writes to a text file. It has eleven aliases to invoke its features and to create entries for my most common activities that I can just tack details on the end of.
rafed.github.io/devra/posts/termin...
You might find the section on aliases interesting.
One of my favorite aliases is to get a quick answer from StackOverflow
using
howdoi
packageThe cross-platform solution to open current directory form terminal
more of my settings can be found here: github.com/victory-sokolov/dotfiles
If you like
howdoi
, check outtldr
. It works likeman
, but only shows usage examples. It's in the regular Ubuntu repos.Definitely going to use this.
I'm always a fan of:
That is, rerun the last typed command, but prepend it with 'sudo' this time.