SHARE WITH THE CLASS: What aliases are you using?
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
I Alias "sudo !!" with "plz"
relevant xkcd
For me it's stfu
I rawdog every single command, I use no aliases at all.
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.
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.
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.
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.
Big if true
Metal
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"
you can just put "gimme-dat-new-new"
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
(Bash-Specific)
App-Specific
Terminal Navigation
Replaced Commands
Server & Docker-related
I wonder if you can be a madlad and symlink your bash-aliases to a synced file.
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.exa is unmaintained, as per the the developer you should use eza instead.
Thanks for the heads up
Some QoL stuff my good friend set-up for me.
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:Good to see another exa user. Care to break down what yay does btw?
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 forpacman
can be used foryay
, thus, some of the flags in the aliases I use are actually forpacman
. 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.-Y
--needed
--norebuild
--nocleanafter
--noredownlod
--nodiffmenu
--nocleanmenu
--removemake
--sudoloop
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.
-S
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.-R
--recursive
--sync
operation.--nosave
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
andpacman
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`).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
.I actually would do
cd ..
and then do apwd
(and so on, repeatedly) because I often get confused and have a very short attention span that the aliases ended up unused.vim grindset 💪
alias .=exit
That would make my shell unusable, since some plugins use
.
/source
../ and . Are two different things to your shell
I know; I'm not talking about
./
. I put the slash outside the inline codeblock in the parent comment.My shell is setup with a chdir hook to
[[ -r. /.autoenv.zsh ]] && . ./.autoenv.zsh
.(Edit: Jerboa is bugged with "&" in codeblocks, that should be a "&&", not
&&
)Ah, ok. For me it was an alias common in the university labs back on Ultrix. Became a habit way back then.
I have :q to exit too since i was trying to exit shell with :q. I guess (n)vim users cant exit their shells :)
we spent so much time learning to exit vim, we forgot how to exit shell 😔
I got so much crap gathered throughout the years... some of them I don't even use, but, here they are:
Good to see someone else using trash & bat. Kudos for the clean alias file w/ commented headers too! I just started doing it recently and it makes edits/additions so much easier
Thanks. It's not the prettiest, but I try to keep an order of some kind... My zshrc was getting quite large, so I split it and when I did that I also put in some comments and headers.
Using trash is good... aliasing it to rm, maybe not so good
Care to elaborate?
For me, it once caused an issue once when I thought I was deleting files to make space for /boot/efi/ being at capacity (dual booting issues at the time) when in actuality I was just moving files to an impromptu trash can created on /boot/efi (so the lack of space remained the same lol), but on numerous occasions, it has actually saved my ass and allowed me to retrieve documents that I realized I needed to look at again.
The only other quirk is it straight up ignores all options, so I've tried to delete interactively (rm -i) and then had to use trash-list to view the deleted files
Maybe I'm being a little paranoid, but I DID accidentally delete a few directories with dotenvs in them, which is what led me to find trash in the first place. That experience really traumatized me... so to break the rm habit and make sure I don't do that on ANY computer I set up
abbr rm '# Don\'t use this! Use
trash-cliinstead' #
andabbr t trash
.I try to keep backups of almost everything, so even if I accidentally delete something and only notice after a clear the trash, there is still a chance I will recover the missing pieces.
Another wttr user 👏🏾👏🏾👏🏾
wttr gang
what is vimx just wondering ?
Seems to be just normal vim, maybe some distros packages the binary (of vim with more options enabled at compile time) as vimx so that it doesn't conflict with another vim package (as an example vim-tiny). https://www.systutorials.com/docs/linux/man/1-vimx/
But only @aram@garam@lemmy.my.id, can answer that for us.
vimx support X/Wayland copy paste, using "+y or "+p
Like GVim, but on terminal... haha...
Hehe pp
pp = process pause = pkill -f SIGSTOP
I hate when Win10 idle/pause on KVM/QEMU still taking much CPU, and the only way to stop it using pp/pkill..
https://blog.benyamin.xyz/2023/03/11/stop-windows-vm-cpu-usage-while-paused-on-qemu-linux/
ussr
For connecting as root with a private key on my main server named Undine Sous Speed.
The best alliases are little inside jokes that are easy to remember imo
Just some simple stuff:
alias nano='nano -l'
my only one, to have line numbers when searching for errors in log files
Copying multiple lines will be more difficult. You can use Ctrl+C to display the current position, use page up/down for coarse navigation.
My favorite one: alias upgrate="sudo apt update && sudo apt upgrade"
ahhh a pormanteau lol, I like it
What do you use the ascii to bold function for?
I used to use it for posting on Twitter, with some keywords (like book title) in bold.
A different way to do the usual
..="cd .."
and endless chains of...="cd ../.."
types of aliases:These take the number of directories that you want to move up as an argument (e.g.
.. 3
), otherwise they move you up one directory when used with no arguments.Thanks for sharing, likely will implement this!
There is a shell option for this (at least in zsh):
setopt autocd
. This allows you to change directories while omitting the cd in frontI alias most of my flatpaks to autorun, made a tool for that called flatalias.
https://github.com/trytomakeyouprivate/flatalias
Also
I use fish btw, nice shell.
Here ya go
Discussion and suggestions welcome :)
I appreciate the focus on verbosity. I should probably set more of my defaults to follow the same thought process 🤔
the only thing this does is add "--recursive" to every
git clone
invocationsame for gh (github cli)
A bit long, but here goes:
Start gomuks Matrix Client
alias gomuks=/home/craig/.local/bin/gomuks-linux-arm64
walk: Terminal File Manager
https://github.com/antonmedv/walk
alias walk="walk --icons"
Weather:https://github.com/chubin/wttr.in
alias weather="/home/craig/.local/bin/weather.sh"
Onelinershell https://github.com/Onelinerhub/shellhub
alias oh="/home/craig/.local/bin/oh.sh"
Show open ports
alias ports='sudo netstat -tulanp'
Refresh .bashrc
alias bashrc="source ~/.bashrc"
become root
alias root='sudo -i' alias su='sudo su'
Fix which
alias which='command -v'
APT User Commands
alias search='apt search' alias file='apt-file search' alias policy='apt policy' alias show="nala show"
if user is not root, pass all commands via sudo
if [ $UID -ne 0 ]; then alias update='sudo apt update' alias ainstall='sudo apt install' alias apurge='sudo apt purge -y --autoremove' alias upgrade='sudo nala upgrade' alias aremove='sudo apt autoremove -y' alias clean='sudo nala clean' alias reboot='sudo reboot' alias shutdown="sudo shutdown -P now" fi
Handy-dandy aliases for journalctl and systemctl
alias jc='sudo journalctl -b' alias jca='sudo journalctl' alias jcf='sudo journalctl -f' alias jcr='sudo journalctl --list-boots' alias sc='sudo systemctl'
Making files immortal & executable
alias im+="sudo chattr +i" alias im-="sudo chattr -i" alias exe="sudo chmod +x"
#Add safety nets
do not delete / or prompt if deleting more than 3 files at a time
alias rm='rm -I --preserve-root'
confirmation
alias mv='mv -i' alias cp='cp -i' alias ln='ln -i'
Parenting changing perms on /
alias chown='chown --preserve-root' alias chmod='chmod --preserve-root' alias chgrp='chgrp --preserve-root'
copy the current working directory to the clipboard
alias cpwd='pwd | xclip -selection clipboard'
Clipboard
alias cpy="xclip -selection clipboard"
quick directory movement
alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..'
go to the last directory you were in
alias back='cd $OLDPWD'
quickly find files and directory
alias ff='find . -type f -name' alias fd='find . -type d -name'
Create Python virtual environment
alias ve='python3 -m venv ./venv' alias va='source ./venv/bin/activate'
Ping Commands
Stop after sending count ECHO_REQUEST packets
alias ping='ping -c 5' alias pg="ping google.com -c 5"
alias shortcuts
alias rpi="sudo rpi-update" alias rpi-next="sudo BRANCH=next rpi-update" alias raspi="sudo raspi-config" alias clr="clear" alias clrh="history -c -w ~/.bash_history" alias df='df -H' alias du='du -ch' alias mk="mkdir -p" alias loading="sudo dmesg > ~/dmesg.txt"
ls Commands
Colorize the ls output and human readable sizes
alias ls='ls --color=auto --human-readable -al'
Use a long listing format
alias ll='ls -la'
Show hidden files
alias l.='ls -d .* --color=auto'
Listing files in folder
alias listkb="ls -l --block-size=K" alias listmb="ls -l --block-size=M"
Colorize the grep command output for ease of use (good for log files)##
alias grep='grep --color=auto' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto'
Colorize diff output
alias diff='colordiff'
Start calculator with math support
alias bc="bc -l"
Resume wget by default
alias wget="wget -c"
ps Commands
alias ps="ps auxf"
Get top process eating cpu
alias pscpu="ps auxf | sort -nr -k 3" alias pscpu10="ps auxf | sort -nr -k 3 | head -10"
Get top process eating memory
alias psmem='ps auxf | sort -nr -k 4' alias psmem10='ps auxf | sort -nr -k 4 | head -10'
Free and Used Ram
alias meminfo='free -l' alias free='free -mt'
Run top in alternate screen
alias top='tput smcup; top; tput rmcup'
i wanna see u try use a vanilla profile
The struggle I sometimes face when I SSH into somewhere, lol! Fortunately, there's a lot of differences that it's easy realize that "this is a different machine", and I just open a different terminal tab/window to look up the pure command versions if I need to.
alias hgrep='function _f(){ history | grep $1; };_f'
Because I'm to lazy to type
history | grep whatever_I'm_looking_for
OMG. I originally got the impression (from somewhere) that you couldn't pass arguments to an alias, so I googled and found that weird function nonsense. Oh well, live and learn. Thanks.
Feel free to call me a poser, a scrub, etc but I don't use aliases (other than the default ones, that is).
Why? Two words:
Brain. Exercise.
Finger. Exercise.
I've got a "println" finger reflex now xD
I have codebase of 5k lines. Most used are git commands (squash all to merge base, push to current branch, commit with format etc), work shortcuts for starting projects, time logging, startup programs. Then I have some cli interface for redo commands, size of current folders for disk pruning, abandoned project alias, os commands like brightness adjust, launch game on steam with qwert instead of dvorak keyboard, search cli history, kill with regex matching...
Just anything that I don’t want to Google twice. bash is life
alias cat lolcat
alias ccat whatever ohmyzsh does for their colorize extension, I know it’s a function alias
alias clear="clear; fastfetch"
alias sudo="doas"
alias clr="clear"
alias kx="killall Xwayland"
alias vpython="~/newVenv/bin/python"
alias vpip="~/newVenv/bin/pip"
I just use ^L instead of
clear
.same
Don't really organize my aliases after making them, so this might be a mess.
Gonna steal/repurpose the shutdown one, use the "sudo docker" = "docker" one and also the grub one. Good lord @ all the configs you edit lol.
I agree pms is a pain especially if it is delayed for more than a month.
Call me weird, I don't have any.
Me either. I do a lot of initial setup for customer sites. Don’t want to get too used to customized shells or tmux.
I've got the standard ones (l, ll, ls) to be forms of
ls -flags
I also use
alias nd=nix develop
a lot.Digging the systemctl ones. I added myself to the group so that I wouldn't have to write sudo each time, but I might as well alias the entire prompt for restart and status to make it even shorter
Some random ones I created over the last week or so:
alias clipboard='xclip -selection clipboard' # Allows me to pipe output directly to my keyboard. good for pwd for example.
Function allows me to get tldr and cheat responses to commands quickly
function cht() {
curl cheat.sh/$1
}
Easy calculator so that I can do math w/o launching a specific app
function calc() {
echo "scale=3; $@" | bc
}
For system updates:
I have a similar one but I did it this way:
Actually that’s the install one. Here’s the upgrade one:
Very nice
This is a separate reply since I didn't know that you can include shell functions here.
I made this little function
read_latest_log()
because I just want to "read the latest log file" in a directory full of timestamped log files. I made a helper functionseparator_line_with_text()
to help with the output, basically setting off the file-info portion (just the filename for now) from the file contents.Sorry for all the edits, for some reason anything that looks like an HTML tag gets erased.
I've got aliases for every faltpak app I launch in the terminal for instance I've got code for vscodium or steam for well steam for example, I also alias some system commands so I have an update-grub, update, etc...
I also alias LSD to LS for obvious reasons.
When I switched to KDE I started using kate, but I used to have code as my vscodium alias as well. One interesting thing is seeing how similar people think. No wonder standard password guesses are so easy lol.
On a related note, I tried to make my SSH port based on the letters turned into numbers and realized that had been done before and was google-able also lol
I mainly use an alias to ssh into my server and another to stream lofi girl audio with mpv
Care to share the lofi mpv one? I use both lol
alias lofi='mpv --no-video https://www.youtube.com/watch?v=jfKfPfyJRdk'
Lofi girl audio?
More info. Got really big during the thick of covid.
I don't like having to renavigate to my project directory in a new terminal:
Takes my current directory and opens it in my terminal. Then it disowns that new terminal process, so if I close the current terminal the new one doesnt disappear with it.
https://github.com/K1aymore/Nixos-Config/blob/74f38451c42990756128f0b3980221bc0290b4db/term/aliases.nix
here we go, in no particular order:
I'm stealing claer
control+l
is much easierI can't spell when typing fast :P
alias upgrade="sudo dnf upgrade --yes && flatpak update && flatpak remove --unused"
Or something like that, also a dnf remove unused command in there. Writing this from my phone so might be written wrong.
(NOTE: A lot of my more interesting "aliases" are actually short functions, but I'm keeping myself to
alias
.)Some of mine that I haven't seen yet:
I'm a simple man. I do simple things. I replace
df
,ls
andtop
with more modern alternatives. Courtesy of this list.alias forgethist=unset HISTFILE
Useful when I run the same two commands 20 times in a row
in zsh you can just forbid it to save duplicates
I'm going to assume all these syntax highlighted HTML embeds are from Lemmy users. Sadly, illegible on Kbin.
Ahhh I was wondering what that was as a fellow kbin-er. I was pleasantly surprised when I found out I could create threads across the fediverse today as a consolation.
Edit: Click the 'more' button on the comment and get the fediverse link to view the formatted post