From bash to zsh and everywhere in between, show me yours and I’ll show you mines. Inspire others or get some feedback.

Simply copy & paste the output of alias in your terminal or add some comments to explain things for others.

Edit: Kbin users, click ‘More’ on a comment and use the fediverse link to read responses that have funky formatting

37 points

I Alias “sudo !!” with “plz”

permalink
report
reply
7 points
2 points

For me it’s stfu

permalink
report
parent
reply
35 points

I rawdog every single command, I use no aliases at all.

permalink
report
reply
15 points

I couldn’t even work if I had aliases in my muscle memory. Imagine ssh’ing to a server and every second command you issue doesn’t exist because it’s some weird alias you set up for yourself.

I’ll stick with the “pure” command and use tab completion.

That’s also part of the reason why I don’t use some of the fancy new tools like ripgrep and exa.

permalink
report
parent
reply
11 points

Yeah, I remember when Linux was first becoming cool, in the mid-to-late 90s. There was a lot of folk wisdom going around, and one of them was “make an alias rm='rm -i' so you don’t accidentally delete anything!”

And then there was the (correct, IMHO) counter-wisdom of “no, that actually makes it more likely to accidentally delete something, because one day you’re going to be on a machine where that alias doesn’t exist, but you’ve become dependent on it existing”.

I don’t mind creating aliases to add colour or change formatting a little bit or something, but don’t make an alias to keep yourself safe, because it’ll probably backfire on you.

permalink
report
parent
reply
2 points

You couldn’t even work if you made a few longer commonly used commands convenient aliases? Well alright.

I can’t imagine how you feel about bash scripts lol.

permalink
report
parent
reply
2 points

Not the person you responded to, but sure. Breaking muscle memory is extremely grating.

Also, it’s pretty easy to type long commands with little typing. If you use ctrl+r to search backward in your history, you can easily recall long commands - and also, you can use ctrl+x,ctrl+e to edit the current command line in $EDITOR so you can edit long commands. These two tricks make it very easy to type long commands quickly with very little typing.

permalink
report
parent
reply
1 point
Deleted by creator
permalink
report
parent
reply
3 points

Metal

permalink
report
parent
reply
22 points
*

What… I didn’t know this was a thing.

So I could make be “sudo gimme-dat-new-new” Instead of “sudo DNF upgrade -y”

permalink
report
reply
14 points

you can just put “gimme-dat-new-new”

permalink
report
parent
reply
11 points
*

alias gimmie-dat-new-new='sudo dnf upgrade -y'

Although you should probably look over your upgrade before applying it as a general good practice. But, hey, I do this myself (dnfup instead of gimmie-dat-etc.), so I can’t talk too much shit.

ETA: If you want it to be a persistent alias, though, you gotta add it to your .bashrc

permalink
report
parent
reply
18 points
*

(Bash-Specific)

App-Specific

alias battery='upower -i $(upower -e | grep 'BAT') | grep -E "state|to\ full|percentage"' # Get the battery level of my laptop server when I ssh into it

alias audio="yt-dlp -f 'ba' -x --audio-format mp3" # Download the audio version of a youtube video

alias wttr="curl wttr.in/Chicago" # Get the weather of my city in the terminal

Terminal Navigation

alias ba2sy="cp ~/.bash_aliases ~/Sync/" # copy my current iteration of my aliases to my shared syncthing folder so that it's accessible across devices

alias sy2ba="cp ~/Sync/.bash_aliases ~/" # replace the current iteration of my aliases w/ the synced version from my syncthing folder

alias mba='micro .bash_aliases' # open my aliases file in the modernized version of 'nano'

alias reload="source ~/.bashrc" # Quickly refresh my system so that the latest alias file is loaded

alias l='exa --group-directories-first -hlras modified --no-user --icons' # exa is a prettier version of ls. Options toggled: Human-readable, long format, reverse output, show hidden files/folders, sort by modified, hide the 'user' column since I'm the only one that uses the computer, and show the icons to make it look fancy```

Replaced Commands

alias cat='batcat --theme=ansi ' # Replace generic output of cat w/ a formatted version. This is bat (batcat in Debian)

alias rm='trash ' # Instead of auto-deleting files, put them in the 'trash' bin for 30 days, then delete.

Server & Docker-related

alias lazy='/home/macallik/.local/bin/lazydocker' # Run Docker

alias pad='ssh MyPad20334' # shorthand to ssh into my server

permalink
report
reply
1 point

I wonder if you can be a madlad and symlink your bash-aliases to a synced file.

permalink
report
parent
reply
3 points

Not a symlink, but you can add source /path/to/aliases one your bashrc file to load them from another file. I do that and keep all of my dot files in a hit repo.

permalink
report
parent
reply
1 point

exa is unmaintained, as per the the developer you should use eza instead.

permalink
report
parent
reply
2 points

Thanks for the heads up

permalink
report
parent
reply
16 points
*

Some QoL stuff my good friend set-up for me.

# ALIASES -- EXA
alias ls='exa --group-directories-first --color=auto -h -aa -l --git'

# ALIASES -- YAY
alias yy='yay -Y --needed --norebuild --nocleanafter --nodiffmenu --noredownload --nocleanmenu --removemake --sudoloop'
alias ya='yay -S --needed --norebuild --nocleanafter --nodiffmenu --noredownload --nocleanmenu --removemake --sudoloop'
alias yu='yay -R --recursive --nosave'

# ALIASES -- CP
alias cp="cp --reflink=auto -i"

And then there’s a bunch of stuff from the output of alias, most of them are git aliases. Those which aren’t git-related are listed below:

-='cd -'
...=../..
....=../../..
.....=../../../..
......=../../../../..
1='cd -1'
2='cd -2'
3='cd -3'
4='cd -4'
5='cd -5'
6='cd -6'
7='cd -7'
8='cd -8'
9='cd -9'
_='sudo '
cp='cp --reflink=auto -i'
egrep='grep -E --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}'
fgrep='grep -F --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}'
history=omz_history
l='ls -lah'
la='ls -lAh'
ll='ls -lh'
ls='exa --group-directories-first --color=auto -h -aa -l --git'
lsa='ls -lah'
md='mkdir -p'
rd=rmdir
run-help=man
which-command=whence
permalink
report
reply
7 points

Good to see another exa user. Care to break down what yay does btw?

permalink
report
parent
reply
5 points
*

Ah, yay is an AUR helper, though I personally see it as a pacman helper as well. Link here. Some of the flags and options that can be used for pacman can be used for yay, thus, some of the flags in the aliases I use are actually for pacman. Anyways, on to the breakdown.

alias yy='yay -Y --needed --norebuild --nocleanafter --nodiffmenu --noredownload --nocleanmenu --removemake --sudoloop'

This one is what I use to look up for packages. The result of runnning yy «search term» would be a list of packages matching the search term and prompting the user on which package(s) to install.

flag description
-Y performs yay-specific operations.
--needed (pacman) do not reinstall up to date packages
--norebuild skips package build if in cache and up to date
--nocleanafter do not remove package sources after successful build
--noredownlod skip pkgbuild download if in cache and up to date
--nodiffmenu don’t show diffs for build files
--nocleanmenu don’t clean build PKGBUILDS
--removemake remove makedepends after install
--sudoloop loop sudo calls in the background to avoid timeout

alias ya='yay -S --needed --norebuild --nocleanafter --nodiffmenu --noredownload --nocleanmenu --removemake --sudoloop'

This one is what I use for installing packages. Useful if I already know what package I would be installing.

flag description
-S (pacman, extended by Yay to cover AUR as well) Synchronize packages. Packages are installed directly from the remote repositories, including all dependencies required to run the packages.

alias yu='yay -R --recursive --nosave'

This one is what I use when uninstalling packages. I usually check the package name with something like yay -Qi «package-name-guess» beforehand.

flag description
-R (pacman, extended by Yay to also remove cached data about devel packages) Remove package(s) from the system.
--recursive (pacman) Remove each target specified including all of their dependencies, provided that (A) they are not required by other packages; and (B) they were not explicitly installed by the user. This operation is recurisve and analogous to a backwards --sync operation.
--nosave (pacman) Instructs pacman to ignore file backup designations. (This avoids the removed files being renamed with a .pacsave extension.)

I actually don’t know much about both yay and pacman myself, since the aliases were just passed onto me by the same friend who helped me (re-)install my system (long story) and set-up the aliases. Having looked all these up, however, I might make a few changes (like changing the --nocleanafter and --nocleanmenu options to their clean ones`).

permalink
report
parent
reply
2 points
*

I like the idea of binding numbers to parent directory traversal. I do cd …/… a lot in one of my projects (switching between source code and terraform folder), it’d be handy to get out of the terraform folder by just typing 2.

permalink
report
parent
reply
1 point

I actually would do cd .. and then do a pwd (and so on, repeatedly) because I often get confused and have a very short attention span that the aliases ended up unused.

permalink
report
parent
reply

Linux

!linux@lemmy.ml

Create post

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word “Linux” in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

Community stats

  • 8.5K

    Monthly active users

  • 6.3K

    Posts

  • 174K

    Comments