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
(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:
# Simple python calculator alias pycalc='python3 -ic " from math import *\nimport cmath as C try: import numpy as np except: pass i, j = 1j, 1j "' # Defaults alias cp='cp --interactive --reflink=auto' alias gcc='gcc -fdiagnostics-color=auto' # Lemmy doesn't handle ampersands in codeblocks correctly alias rg='rg --max-columns=$((COLUMNS > 60 && ! ZSH_SUBSHELL ? COLUMNS - 30 : 0))' alias rj='rg --json' alias rm='rm -s' alias rscp='rsync -azP --human-readable --info=flist0,progress2,stats1' alias rust-c='rustc --out-dir build -O' # Shorter forms alias g=git alias v=$VISUAL alias py=python alias jfeu='journalctl --user -xfeu' alias sys='systemctl --user' alias Jfeu='journalctl -xfeu' alias Sys=systemctl # Desktop stuff alias trash='gio trash' alias ud=udisksctl alias y=wl-copy alias Y='wl-copy -p' alias p=wl-paste alias P='wl-paste -p' # Colorize with acolor/grc alias GRC='grc -es' alias LA='acol ls -lFAhb --color' alias LS='acol ls -lFhb --color' alias df='GRC df -hT' alias dig='GRC dig' alias docker='GRC docker' alias docker-machine='GRC docker-machine' alias env='acol env' alias lsblk='acol lsblk' alias lsmount='command mount | rg --color=never "^/" | acol -i -o mount' alias lspci='acol lspci' alias mount='acol mount' alias nmap='acol nmap' alias ping='GRC ping' alias ps='GRC ps --columns $COLUMNS' alias traceroute='GRC traceroute'
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.
it’s pretty easy to type long commands with little typing
Big if true
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; $@”So I’ve checked and…
alias la='ls -a' alias mplayer='mplayer -noautosub -alang en' alias ll='ls $LS_OPTIONS -lh' alias l='ls $LS_OPTIONS -lAa' alias x='startx' alias ekgi='ekg -i' alias glinks='links2 -g'
My god, this must be in my .bashrc since forever. I mean… links2? ekg? startx? It’s like archeology.
I will keep it there for future historians.
deleted by creator
I will keep it there for future historians.
great, now i have spit coffee all over the place. thanks for the laugh!
I Alias “sudo !!” with “plz”
For me it’s stfu
vim grindset 💪
alias q=exit alias :q=exit alias :wq=exit
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 😔
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.
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.
A different way to do the usual
..="cd .."
and endless chains of...="cd ../.."
types of aliases:bash
/ksh
version:..() { local count="${1:-1}" local path="../" while (( --count > 0 )); do path="$path../" done cd -- "$path" }
zsh
single-line version:..() { cd $(printf "../%.s" {1..${1:-1}}) }
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.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.
Discussion and suggestions welcome :)
I appreciate the focus on verbosity. I should probably set more of my defaults to follow the same thought process 🤔
here we go, in no particular order:
claer=clear gvim='nvim +Gclog +Git' vim=nvim vi=/usr/bin/vim v=/usr/bin/vi glog='git log --oneline --graph --all' rcp='rsync -r --info=progress2 --partial' d0='du -h --max-depth 0' d1='du -h --max-depth 1' ls='ls --time-style=long-iso --color=tty' icat=chafa ssh='TERM=xterm-256color ssh' # (kitty messes with TERM)
I’m stealing claer
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.
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.
alias ls='ls --time-style=long-iso' alias la='ls -alh' alias ncdu='ncdu --color=off' alias wttr='curl wttr.in/?T0' alias vim='vimx' alias ipinfo='curl ipinfo.io --no-progress-meter | jq "del(.readme)"' alias pp="pkill -SIGSTOP -f " alias pc="pkill -SIGCONT -f "
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/
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…
(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
Thanks for the heads up
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.