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

Klaymore,
@Klaymore@sh.itjust.works avatar
garam,

<span style="color:#323232;">alias ls='ls --time-style=long-iso'
</span><span style="color:#323232;">alias la='ls -alh'
</span><span style="color:#323232;">alias ncdu='ncdu --color=off'
</span><span style="color:#323232;">alias wttr='curl wttr.in/?T0'
</span><span style="color:#323232;">alias vim='vimx'
</span><span style="color:#323232;">alias ipinfo='curl ipinfo.io --no-progress-meter | jq "del(.readme)"'
</span><span style="color:#323232;">alias pp="pkill -SIGSTOP -f "
</span><span style="color:#323232;">alias pc="pkill -SIGCONT -f "
</span>
darcy,
@darcy@sh.itjust.works avatar

what is vimx just wondering ?

CjkOvPDwQW,

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). www.systutorials.com/docs/linux/man/1-vimx/

But only @aram@lemmy.my.id, can answer that for us.

garam,

vimx support X/Wayland copy paste, using "+y or "+p

Like GVim, but on terminal… haha…

macallik,

Another wttr user 👏🏾👏🏾👏🏾

noli,

Hehe pp

garam,

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…

blog.benyamin.xyz/…/stop-windows-vm-cpu-usage-whi…

thurstylark,

Here ya go

Discussion and suggestions welcome :)

macallik,

I appreciate the focus on verbosity. I should probably set more of my defaults to follow the same thought process 🤔

Pantherina, (edited )

I alias most of my flatpaks to autorun, made a tool for that called flatalias.

github.com/trytomakeyouprivate/flatalias

Also


<span style="color:#323232;">set fish_greeting
</span><span style="color:#323232;">
</span><span style="color:#323232;">alias update='flatpak update -y &amp;&amp; notify-send -a Updater "Flatpaks ready" &amp;&amp; rpm-ostree update &amp;&amp; notify-send -a Updater "rpm-ostree ready"'
</span><span style="color:#323232;">
</span><span style="color:#323232;">alias upfin='flatpak update -y &amp;&amp; rpm-ostree update &amp;&amp; shutdown -h now''
</span><span style="color:#323232;">
</span><span style="color:#323232;">alias flatrm='flatpak remove --delete-data'
</span><span style="color:#323232;">
</span><span style="color:#323232;">alias ls="ls --color=auto -GF"
</span><span style="color:#323232;">
</span><span style="color:#323232;">alias reload="source ~/.config/fish/config.fish &amp;&amp; echo 'Fish-config updated'"
</span><span style="color:#323232;">
</span><span style="color:#323232;">abbr conf "kate ~/.config/fish/config.fish &amp;&amp; source ~/.config/fish/config.fish &amp;&amp; echo 'Fish-config updated'"
</span><span style="color:#323232;">
</span><span style="color:#323232;">### NETWORKING
</span><span style="color:#323232;">abbr myip 'curl ifconfig.co'
</span><span style="color:#323232;">abbr netlisten 'netstat -plntu'
</span><span style="color:#323232;">abbr pingtest 'ping -c 2 wikipedia.de'
</span><span style="color:#323232;">
</span><span style="color:#323232;">abbr rpmq "distrobox enter -n fedora -- dnf search"
</span><span style="color:#323232;">abbr rstat "rpm-ostree status"
</span><span style="color:#323232;">
</span><span style="color:#323232;">abbr rpmfind "rpm -qa | grep"
</span><span style="color:#323232;">
</span><span style="color:#323232;">abbr flatinst 'flatpak install -y'
</span><span style="color:#323232;">
</span><span style="color:#323232;">abbr flatfind "flatpak list | grep"
</span><span style="color:#323232;">
</span><span style="color:#323232;">abbr history-off 'set +o history'
</span><span style="color:#323232;">
</span><span style="color:#323232;">abbr sshcloud "ssh -i /home/user/.local/share/Cryptomator/mnt/SSH-keys/KEYNAME -p PORTNUMBER root@IP
</span><span style="color:#323232;"># and others
</span><span style="color:#323232;">
</span><span style="color:#323232;">abbr httpcode "curl --head --silent --output /dev/null --write-out '%{http_code}' "
</span><span style="color:#323232;">
</span><span style="color:#323232;">abbr "pin-this" "ostree admin pin 0"
</span><span style="color:#323232;">abbr "q" "exit"
</span><span style="color:#323232;">abbr c "clear"
</span><span style="color:#323232;">
</span><span style="color:#323232;">abbr errors-boot "journalctl -b"
</span><span style="color:#323232;">abbr errors-last-boot "journalctl -b -1"
</span><span style="color:#323232;">
</span><span style="color:#323232;">function copy
</span><span style="color:#323232;">    if test -f $argv[1]
</span><span style="color:#323232;">        cat $argv[1] | wl-copy
</span><span style="color:#323232;">        echo "Copied to clipboard."
</span><span style="color:#323232;">    else
</span><span style="color:#323232;">        echo "Error: '$argv[1]' is not a file!"
</span><span style="color:#323232;">    end
</span><span style="color:#323232;">end
</span><span style="color:#323232;">
</span><span style="color:#323232;">abbr off "shutdown -h now"
</span><span style="color:#323232;">
</span><span style="color:#323232;">function findmod
</span><span style="color:#323232;">    set mod_path (whereis $argv[1] | cut -d' ' -f2)
</span><span style="color:#323232;">    kate $mod_path;
</span><span style="color:#323232;">end
</span><span style="color:#323232;">
</span><span style="color:#323232;">function mdtopdf -a filename
</span><span style="color:#323232;">  set -x name (basename $filename .md)
</span><span style="color:#323232;">  pandoc $filename -o $name.pdf | tee $name.pdf
</span><span style="color:#323232;">end
</span><span style="color:#323232;">
</span><span style="color:#323232;">function mdtoodt -a filename
</span><span style="color:#323232;">  set -x name (basename $filename .md)
</span><span style="color:#323232;">  pandoc $filename -o $name.odt | tee $name.odt
</span><span style="color:#323232;">end
</span><span style="color:#323232;">
</span><span style="color:#323232;">function mdtotex -a filename
</span><span style="color:#323232;">  set -x name (basename $filename .md)
</span><span style="color:#323232;">  pandoc $filename -s -o $name.tex | tee $name.tex
</span><span style="color:#323232;">end
</span><span style="color:#323232;">
</span><span style="color:#323232;">abbr rootfish "sudo -i fish"
</span><span style="color:#323232;">
</span><span style="color:#323232;">abbr eng "export LANG=en_US.UTF-8"
</span><span style="color:#323232;">abbr english "export LANG=en_US.UTF-8"
</span><span style="color:#323232;">alias conf='nano ~/.config/fish/config.fish'
</span><span style="color:#323232;">alias reload='. ~/.config/fish/config.fish'
</span><span style="color:#323232;">
</span><span style="color:#323232;">alias pipwire-restart="systemctl --user restart pipewire.service"
</span><span style="color:#323232;">
</span><span style="color:#323232;">function tarbrot #not yet fully working I think
</span><span style="color:#323232;">    if test -z $argv[1]
</span><span style="color:#323232;">        echo "Usage: tarbrot "
</span><span style="color:#323232;">        return 1
</span><span style="color:#323232;">    end
</span><span style="color:#323232;">
</span><span style="color:#323232;">    set folder $argv[1]
</span><span style="color:#323232;">    set tarball (basename $folder).tar
</span><span style="color:#323232;">    set brotli_file $tarball.br
</span><span style="color:#323232;">
</span><span style="color:#323232;">    # Start the timer
</span><span style="color:#323232;">    set start_time (date +%s)
</span><span style="color:#323232;">
</span><span style="color:#323232;">    # Create a tarball without compression
</span><span style="color:#323232;">    tar -cf $tarball $folder
</span><span style="color:#323232;">
</span><span style="color:#323232;">    # Display the time elapsed
</span><span style="color:#323232;">    set end_time (date +%s)
</span><span style="color:#323232;">    set elapsed_time (math $end_time - $start_time)
</span><span style="color:#323232;">
</span><span style="color:#323232;">    # Compress the tarball with Brotli
</span><span style="color:#323232;">    brotli $tarball &amp;&amp; rm -f "$tarball"
</span><span style="color:#323232;">
</span><span style="color:#323232;">    echo "Folder '$folder' has been tarred and Brotli compressed as '$brotli_file'"
</span><span style="color:#323232;">    echo "Time elapsed: $elapsed_time seconds"
</span><span style="color:#323232;">    echo "Size of compressed file: (du -h $brotli_file | awk '{print $1}')"
</span><span style="color:#323232;">end
</span>

I use fish btw, nice shell.

conkbin, (edited )

I got so much crap gathered throughout the years... some of them I don't even use, but, here they are:

#!/usr/bin/zsh
# vi: ft=zsh

#############
# zsh aliases
#############

# grep
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias zgrep='zgrep --color=auto'

# processes
#alias pss='ps auxww | grep -v grep | grep'   # show all processes with user, hide grep itself
alias top='top -i -e m -E m'                # hide inactive and zombie processes, show ram in MB

# update system
alias p='sudo pacman'
alias pu='paru -Sua --noconfirm'
# clean up
alias pc='sudo pacman -Rsn $(pacman -Qdtq) --noconfirm 2>/dev/null; paru -Sccd --noconfirm'

# lvim
alias nvim='lvim'
alias vim='lvim'
alias vi='lvim'
alias v='lvim'

# cpg & mvg
alias cp='/usr/bin/cpg -ig'
alias mv='/usr/bin/mvg -ig'

# other useful ones
alias rm='trash'
alias duu='du -d 1 -h'

# wayland
alias gparted='sudo /bin/env WAYLAND_DISPLAY="$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY"  XDG_RUNTIME_DIR=/user/run/0  /usr/sbin/gparted'

# edit configs
alias vcs="$EDITOR $XDG_CONFIG_HOME/starship/config.toml"     # starship
alias vca="$EDITOR $XDG_CONFIG_HOME/alacritty/alacritty.yml"  # alacritty
alias vct="$EDITOR $XDG_CONFIG_HOME/tmux/tmux.conf"           # tmux
alias vcv="$EDITOR $XDG_CONFIG_HOME/nvim/init.vim"            # neovim
alias vcl="$EDITOR $XDG_CONFIG_HOME/lvim/config.lua"          # lunarvim
alias vch="$EDITOR $XDG_CONFIG_HOME/hypr/hyprland.conf"       # hyprland
alias vcw="$EDITOR $XDG_CONFIG_HOME/waybar/config"            # waybar

# edit & source zsh configs
alias scz="source $ZDOTDIR/.zshrc"
alias vcz="$EDITOR $ZDOTDIR/.zshrc && source $ZDOTDIR/.zshrc"
alias vczo="$EDITOR $ZDOTDIR/options && source $ZDOTDIR/options"
alias vczb="$EDITOR $ZDOTDIR/bindkeys && source $ZDOTDIR/bindkeys"
alias vcze="$EDITOR $ZDOTDIR/exports && source $ZDOTDIR/exports"
alias vcza="$EDITOR $ZDOTDIR/aliases && source $ZDOTDIR/aliases"
alias vczc="$EDITOR $ZDOTDIR/completions && source $ZDOTDIR/completions"
alias vczf="$EDITOR $ZDOTDIR/functions && source $ZDOTDIR/functions"

# other cool toys
alias exa='exa --long --header --git --sort=name --group-directories-first'
alias ls='exa'
alias cat='bat -pp'
alias bat='bat --style=full'

# x11
# alias X='startx ${XDG_CONFIG_HOME}/X11/xinitrc'
# alias XX='~/.screenlayout/home2.sh'
# alias kb='setxkbmap -rules evdev -model pc105 -layout "ro,de" -variant "basic" -option "grp:shift_caps_toggle"'

# tmux
alias tmux="tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf"
alias t="tmux new-session -A -s id"

# dmenu stuff
# alias dnm='networkmanager_dmenu'
# alias dbt='dmenu-bluetooth'

# other cli utils
alias pm='pulsemixer'

# locations
alias lab='cd ~/priv/code/lab'
alias own='cd ~/priv/code/own'
alias pixl='aft-mtp-mount ~/priv/pixl'

# cleanup home
alias irssi="irssi --home ${XDG_CONFIG_HOME}/irssi"
alias svn="svn --config-dir ${XDG_CONFIG_HOME}/subversion"
alias wget="wget --hsts-file=$XDG_DATA_HOME/wget-hsts"

# dotfiles
alias stowe="sudo stow -d $HOME/.dotfiles/etc/ -t /etc/"

# ansible
alias ansible-vault='EDITOR=lvim ansible-vault'

# acme
alias acme='acme.sh --home "$XDG_CONFIG_HOME"/acme.sh/'

# vscode
alias code='vscodium --enable-features=UseOzonePlatform --ozone-platform=wayland'

# time sync
alias synctime='echo "time now:" && date && sudo systemctl stop ntpd && sudo ntpd -gq && sudo systemctl start ntpd && echo "new time:" && date'

# nordvpn
alias nvro='sudo systemctl start nordvpnd && nordvpn c ro && nordvpn whitelist add subnet 10.0.0.0/8 && nordvpn set dns 10.10.10.10'
alias nvdown='nordvpn d && sudo systemctl stop nordvpnd'

# work
alias vpnup='nmcli con up vpn-work --ask'
alias vpndown='nmcli con down vpn-work'
alias vpn='nmcli con down vpn-work; nmcli con up vpn-work --ask'
alias vault-connect='source $HOME/work/secrets/vault.work'
alias terraform-connect='source $HOME/work/secrets/terraform.work'
alias teamsx='killall -15 teams'
alias adm='sudo mount /home/$HOME/work/adm'
alias mongo='ssh -L \*:27777:appserver:27017 jumphost'
macallik,

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

bnjmn,

Using trash is good… aliasing it to rm, maybe not so good

macallik,

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

bnjmn,

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-cli instead’ # and abbr t trash.

conkbin,

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.

conkbin,

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.

rutrum,
@rutrum@lm.paradisus.day avatar

I don’t like having to renavigate to my project directory in a new terminal:


<span style="color:#323232;">alias clone='(pwd | urxvt &amp; disown $!)'
</span>

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.

tho, (edited )
@tho@lemmy.ml avatar

the only thing this does is add “–recursive” to every git clone invocation


<span style="color:#323232;">
</span><span style="color:#323232;">git() {
</span><span style="color:#323232;">  if [ "$1" = clone ]; then
</span><span style="color:#323232;">    shift
</span><span style="color:#323232;">    set -- clone --recursive "$@"
</span><span style="color:#323232;">  fi
</span><span style="color:#323232;">  command git "$@"
</span><span style="color:#323232;">}
</span>
tho,
@tho@lemmy.ml avatar

same for gh (github cli)


<span style="color:#323232;">gh() {
</span><span style="color:#323232;">  if [[ "$1" = repo &amp;&amp; "$2" = clone ]]; then
</span><span style="color:#323232;">    shift
</span><span style="color:#323232;">    shift
</span><span style="color:#323232;">    set -- repo clone "$@" -- --recursive
</span><span style="color:#323232;">  fi
</span><span style="color:#323232;">  command gh "$@"
</span><span style="color:#323232;">}
</span>
TexasCrowbarMassacre,

alias forgethist=unset HISTFILE

Useful when I run the same two commands 20 times in a row

tho,
@tho@lemmy.ml avatar

in zsh you can just forbid it to save duplicates

SomeBoyo,

I mainly use an alias to ssh into my server and another to stream lofi girl audio with mpv

macallik,

Care to share the lofi mpv one? I use both lol

SomeBoyo,

alias lofi='mpv --no-video www.youtube.com/watch?v=jfKfPfyJRdk

ryannathans,

Lofi girl audio?

macallik,

More info. Got really big during the thick of covid.

tho,
@tho@lemmy.ml avatar

<span style="color:#323232;">ccd() {
</span><span style="color:#323232;">  mkdir "$1" &amp;&amp; cd "$1"
</span><span style="color:#323232;">}
</span>
bubstance, (edited )

A different way to do the usual …=“cd …” and endless chains of …=“cd …/…” types of aliases:

bash/ksh version:


<span style="color:#323232;">..() {
</span><span style="color:#323232;">    local count="${1:-1}"
</span><span style="color:#323232;">    local path="../"
</span><span style="color:#323232;">    while (( --count > 0 )); do
</span><span style="color:#323232;">        path="$path../"
</span><span style="color:#323232;">    done
</span><span style="color:#323232;">    cd -- "$path"
</span><span style="color:#323232;">}
</span>

zsh single-line version:


<span style="color:#323232;">..() { cd $(printf "../%.s" {1..${1:-1}}) }
</span>

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.

macallik,

Thanks for sharing, likely will implement this!

adam,

There is a shell option for this (at least in zsh): setopt autocd. This allows you to change directories while omitting the cd in front

FluffyPotato,

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

RaivoKulli,

Metal

redxef,

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.

duncesplayed,

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.

RaivoKulli,

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.

namingthingsiseasy,

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.

RaivoKulli,

it’s pretty easy to type long commands with little typing

Big if true

bennieandthez,
@bennieandthez@lemmygrad.ml avatar

These are some pacman+fzf implementations from the arch wiki + a flatpak implementation i did with fzf(still needs some polish but it works).

alias pacq=$‘pacman -Q | fzf’

alias pacs=$‘pacman -Slq | fzf --multi --preview 'pacman -Si {1}' | xargs -ro sudo pacman -S’

alias pacr=$‘pacman -Qq | fzf --multi --preview 'pacman -Si {1}' | xargs -ro sudo pacman -Rns’

alias flatr=$‘flatpak list | fzf --preview 'flatpak info {2} ' | grep -Eo '[a-ZA-Z]+.[^ ]+' |awk '{print $1}' | xargs -ro flatpak remove --delete-data’

clemdemort,
@clemdemort@lemmy.world avatar

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.

macallik,

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

olafurp,

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

  • All
  • Subscribed
  • Moderated
  • Favorites
  • linux@lemmy.ml
  • rosin
  • everett
  • thenastyranch
  • magazineikmin
  • ngwrru68w68
  • DreamBathrooms
  • modclub
  • Youngstown
  • slotface
  • PowerRangers
  • osvaldo12
  • InstantRegret
  • kavyap
  • hgfsjryuu7
  • anitta
  • Durango
  • vwfavf
  • khanakhh
  • tester
  • GTA5RPClips
  • ethstaker
  • mdbf
  • cubers
  • tacticalgear
  • normalnudes
  • cisconetworking
  • Leos
  • provamag3
  • All magazines