command line aliases to make repeated processes quicker. I’ve used them in the past and on specific programs but never on command line utilities.

like for instance with Debian, I’m repeatedly typing sudo apt-get install, so I aliased it: alias sagi=“sudo apt-get install” and it works pretty good.

Are there any best practices or aliases to avoid when using them? Other than known commands obviously. Are there popular alias lists out there?

30 points

alias more=“less -cX”
alias moer=more
alias meor=more
alias meor=more
alias mroe=more
alias More=more

alias grpe=grep
alias gerp=grep
alias gpre=grep

permalink
report
reply
14 points
*

In a big fan of the ‘fuck’ package for this. Try it out. Sudo apt install thefuck.

edit: oops got the name wrong; been a while since I installed it. Fuck.

permalink
report
parent
reply
5 points
*

@model_tar_gz @kometes “yay fuck” sounds better I believe

Does it *work*? IRL?

permalink
report
parent
reply
2 points

Yes it’s for real. I type fuck, it fixes my prompt, I accept and move on.

permalink
report
parent
reply
3 points

The what, now?

googles hastily

Oohhhhh mmmmmyyyyyyy…

permalink
report
parent
reply
1 point
*
Deleted by creator
permalink
report
parent
reply
2 points

Funny. I never even thought of using thefuck in any remotely production-esque kind of way. Only for its intended use case: to save me a few keystrokes retyping some command I fucked up typing.

permalink
report
parent
reply
9 points

oh my

permalink
report
parent
reply
6 points

Have tou heard of the sl command?

permalink
report
parent
reply
3 points

choo chooo

permalink
report
parent
reply
1 point

alias g=grep -i

permalink
report
parent
reply
11 points

A humble and simple “c” for “clear” in the terminal.

permalink
report
reply
9 points

CTRL+L works on most I’ve used

permalink
report
parent
reply

But c and ENTER is even quicker. No need to reach out for ^L.

This kinda feels like Vim vs Emacs now.

permalink
report
parent
reply
7 points

For a few basic things, yes. For a couple of others, I’ve set up a shell function or a script instead.

Obligatory warning before I list a few of my aliases - overriding commands by an alias with the same name can be dangerous, as it can mean that expected behaviour can become destructive behaviour on a foreign system without those aliases. e.g. a common error is aliasing rm to rm -i so that rm always asks if the user is sure. Until that user is on a different machine without the alias and the files vanish without warning, anyway. Oops.

Some of mine are arguably questionable in that regard, but I don’t think any will result in anything particularly destructive if I expect them in the wrong place.

These two override the default which command to deliver slightly more useful output, especially when the command is itself an alias (or an alias override). command is a bash builtin:

alias Which='command -V'
alias which='command -v'

The obligatory ls config override. long-iso formatting ensures that ls’s output is consistent, which is tidy, and also useful for further processing. That said, use of stat is probably a better choice for that sort of thing.). LC_ALL=C setting is so that things sort in “ASCIIbetical” order. My locale mixes upper and lowercase filenames and I’m too old-school for that sort of thing.:

alias ls='LC_ALL=C ls --color=auto --group-directories-first --time-style=long-iso'

Some versions of mtr start in GUI mode. -t prevents that. And of course, Windows muscle memory dies hard:

alias mtr='mtr -t'
alias tracert='echo '\''Use mtr, you ninny.'\'''

Hex dump using the ancient and nearly always present od command (the incantation is right out of the od manual):

alias odx='od -A x -t x1z -v'

Process control. Give either a PID and the process will do as it’s told. Usually. :

alias pause='kill -TSTP'
alias resume='kill -CONT'

How many times do I type the wrong thing? Too many:

alias quit='exit'

Setup for fortune. The first one is self-explanatory. The second one shows which of the fortune files the fortune came from (-c) but does some shenanigans to send that header to STDERR rather than STDOUT. This makes the header vanish when fortune is piped into fun things like cowsay.

alias bofh='fortune bofh-excuses'
alias fortune='fortune -c | while read -r line ; do [[ ! "$A" ]] && echo $line >&2 || echo $line ; [[ "$line" == "%" ]] && A=1; done'

I have a load of silly text cipher filters as scripts, but this one came for free with the bsdgames package

alias rot='caesar'
alias rot13='caesar 13'

And of course, every time I create a new alias (which isn’t very often, I admit), I run this one, which dumps all current aliases into a file that some distros set up by default.

alias save_aliases='alias > ~/.bash_aliases'

permalink
report
reply
7 points

Certain aliases related to docker compose, just because it saves 2-3 words which never change.

permalink
report
reply
6 points

There’s not enough storage space on the Internet to list all my aliases.

permalink
report
reply

Linux

!linux@lemmy.world

Create post

Welcome to c/linux!

Welcome to our thriving Linux community! Whether you’re a seasoned Linux enthusiast or just starting your journey, we’re excited to have you here. Explore, learn, and collaborate with like-minded individuals who share a passion for open-source software and the endless possibilities it offers. Together, let’s dive into the world of Linux and embrace the power of freedom, customization, and innovation. Enjoy your stay and feel free to join the vibrant discussions that await you!

Rules:

  1. Stay on topic: Posts and discussions should be related to Linux, open source software, and related technologies.

  2. Be respectful: Treat fellow community members with respect and courtesy.

  3. Quality over quantity: Share informative and thought-provoking content.

  4. No spam or self-promotion: Avoid excessive self-promotion or spamming.

  5. No NSFW adult content

  6. Follow general lemmy guidelines.

Community stats

  • 1.6K

    Monthly active users

  • 555

    Posts

  • 4.2K

    Comments

Community moderators