Share your alias

I just read the article about changing the mirrors to https and there were some cool alias(es?) to update the system with a short command.

Maybe someone else has got some cool or useful alias for daily/weekly tasks to be added to the bashrc?
I only got this ones so far:

alias mirror='sudo reflector --verbose --latest 200 --protocol https --sort rate --save /etc/pacman.d/mirrorlist'
alias update='sudo pacman -Syyu'

So there is much room for improvement. :slight_smile:

alias ls=‘ls --color=auto’
alias merge=‘xrdb -merge ~/.Xresources’
alias microcode=‘grep . /sys/devices/system/cpu/vulnerabilities/
alias mirror=‘sudo reflector --protocol https --latest 50 --number 20 --sort rate --save /etc/pacman.d/mirrorlist’
alias mirrors=‘mirror’
alias pacman=‘sudo pacman --color auto’
alias pdw=‘pwd’
alias pksyua=‘yay -Syu --noconfirm’
alias ps=‘ps auxf’
alias psgrep=‘ps aux | grep -v grep | grep -i -e VSZ -e’
alias skel='cp -rf /etc/skel/
~’
alias trizenskip=‘trizen -S --skipinteg’
alias unlock=‘sudo rm /var/lib/pacman/db.lck’
alias update=‘sudo pacman -Syyu’
alias update-grub=‘sudo grub-mkconfig -o /boot/grub/grub.cfg’

1 Like
# Pacman functions
alias s="sudo pacman -S"
alias syy="sudo pacman -Syy"
alias syu="sudo pacman -Syu"
alias syyu="sudo pacman -Syyu"
alias syyuu="sudo pacman -Syyuu"
alias rns="sudo pacman -Rns"
alias rdd="sudo pacman -Rdd"

# Remove and copy recursively
alias rmr="sudo rm -r"
alias cpr="sudo cp -r"

# up and re to "update" and reorder mirrorlist
alias u='sudo haveged -w 1024; sudo pacman-key --init; sudo pacman-key --populate; sudo pacman-key --refresh-keys; sudo pkill haveged; sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak; sudo reflector --verbose --age 8 --fastest 128 --latest 64 --number 32 --sort rate --save /etc/pacman.d/mirrorlist; sudo pacman -Syy'
alias up='sudo pacman-key --init; sudo pacman-key --populate; sudo pacman-key --refresh-keys; sudo pacman -Syy'
alias re='sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak; sudo reflector --verbose --age 8 --fastest 128 --latest 64 --number 32 --sort rate --save /etc/pacman.d/mirrorlist'

I also have some functions like

pkk(){

    # executes xed as text editor
    # syntax pkk <file>

WHEREAMI=$(pwd)
    pkexec xed $WHEREAMI/$1
}
3 Likes

Thank you for the inspiration. I’ve already saw some entries I’m going to add to my alias. :wink:

@fernandomaroto
Trying to understand the function… it starts the xed (Text-editor?) in your current folder?

I’ll steal most of those, tho I question the need for both Syyu and Syu?

(Running fish so slightly different)

alias mirrors=“sudo reflector --verbose --protocol https --country Germany --country Sweden --latest 20 --sort rate --save /etc/pacman.d/mirrorlist”

funcsave mirrors

alias update=“mirrors && yay -Syyu”

funcsave update

1 Like

I use the AUR helper “pacaur”. There are quite a few AUR helpers and if you are using an Arch based install you would be well advised to read the Arch wiki on them.

AUR helpers

Here are my alias’s,

alias sudo="sudo " #Create an alias for sudo with a space at the end then all other aliases will work with sudo without the need for a password.
alias w7=“sudo mount /dev/nvme0n1p3 /mnt”
alias w7u=“sudo umount /dev/nvme0n1p3”
alias ls=“ls --color=auto”
alias x=“startx”

alias pacu=“pacaur -Syu”
alias paci=“pacaur -S”
alias pacr=“pacaur -Rns”
alias pacq=“pacaur -Q”
alias pacor=“pacaur -Rns $(pacman -Qtdq)” #recursively removing orphans and their configuration files

alias rbs=“firejail --private --dns=8.8.8.8 --dns=8.8.4.4 firefox -no-remote”
alias transmission-gtk=“firejail transmission-gtk”

alias gf=“grim-fandango”
alias ha=“hangman”
#alias boa=“flatpak run com.realm667.WolfenDoom_Blade_of_Agony”

:estonia::sunglasses:

3 Likes

I actually use a linked file to hold all my alias’s, mostly because not all apply to Arch because I distro-hop so often.

~/.bash/.alias

Clear screen

alias cls=‘clear’
alias more=‘less’
alias “:q”=“exit”

Invoke irssi session within tmux

alias irs=“tmux new -s irssi irssi”

Sudo

alias sudo='sudo ’
alias kdsu='kdesu dbus-launch ’
alias reboot=‘reboot’
alias poweroff=‘poweroff’
alias halt=‘halt’

Clean python crud

alias pyclean=‘find . -name *.pyc -o -name *.pyo -o -name pycache -delete’

Pacman

alias pacman=‘sudo pacman --color auto’
alias pacupd=‘pacman -Syy’
alias pacupg=‘pacman -Syyu’
alias pacins='pacman -S ’
alias pacnoc='pacman -S --noconfirm ’
alias pacrem='pacman -R ’
alias pacdep='pacman -Rcn ’
alias pacshq=“pacman -Ql pacman | awk -F”[/ ]" ‘//usr/bin/ {print $5}’"
alias pksyua=“yay -Syyu --noconfirm”
alias editpac=“sudo /opt/sublime_text/sublime_text /etc/pacman.conf”

‘[r]emove [o]rphans’ - recursively remove ALL orphaned packages

alias pacrmo="/usr/bin/pacman -Qtdq > /dev/null && sudo /usr/bin/pacman -Rns $(/usr/bin/pacman -Qtdq | sed -e ‘:a;N;$!ba;s/\n/ /g’)"

Yay

alias yayupd=‘yay -Syy’
alias yayupg=‘yay -Syu’
alias yayrem='yay -R ’
alias yayrms='yay -Rs ’
alias yayins='yay -S ’
alias yaynoc='yay -S --noconfirm ’

Zypper

alias zypdup=‘sudo zypper dup --allow-vendor-change’

reflector update mirrors

alias reflect=“reflector --latest 20 --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlist && cat /etc/pacman.d/mirrorlist”
alias reflectus=“reflector --country ‘United States’ --latest 20 --protocol http --protocol https --sort rate --save /etc/pacman.d/mirrorlist && cat /etc/pacman.d/mirrorlist”

alias ps=“ps auxf”
alias psgrep=“ps aux | grep -v grep | grep -i -e VSZ -e”

#print username uid(1000)
alias uid1000=“awk -v val=1000 -F “:” ‘$3==val{print $1}’ /etc/passwd”

#grub update
alias grubupd=“sudo grub-mkconfig -o /boot/grub/grub.cfg”

#improve png
alias fixpng=“find . -type f -name “*.png” -exec convert {} -strip {} ;”

#mounting the folder Public for exchange between host and guest on virtualbox
alias vbm=“sudo mount -t vboxsf -o rw,uid=1000,gid=1000 Public /home/$USER/Public”

Reaload bashrc

alias rl=‘cls && . ~/.bashrc’

cli infos

alias nf=‘cls && neofetch --ascii_distro arch’
alias al=‘cls && alsi -l’
alias alsi=‘cls && alsi’

Reinitialise Resources

alias xr=‘xrdb -merge ~/.Xresources’
alias xl=‘xrdb -load ~/.Xresources && rl’

Local / Public IP

alias mypip=“curl ipecho.net/plain; echo”
alias mylip=“ifconfig | sed -En ‘s/127.0.0.1//;s/.inet (addr:)?(([0-9].){3}[0-9])./\2/p’”

The ‘ls’ family

alias ll=“ls -l --group-directories-first”
alias ls=“ls -h --color” # add colors for filetype recognition
alias la=“ls -a --color” # show hidden files
alias lx=“ls -xb” # sort by extension
alias lk=“ls -lSr” # sort by size, biggest last
alias lc=“ls -ltcr” # sort by and show change time, most recent last
alias lu=“ls -ltur” # sort by and show access time, most recent last
alias lt=“ls -ltr” # sort by date, most recent last
alias lm=“ls -al |more” # pipe through ‘more’
alias lr=“ls -lR” # recursive ls
alias lsr=“tree -Csu” # nice alternative to ‘recursive ls’

Call Sublime Text

alias sub="/opt/sublime_text/sublime_text "
alias subrc="/opt/sublime_text/sublime_text ~/.bashrc"
alias subal="/opt/sublime_text/sublime_text ~/.bash/.alias"
alias subbp="/opt/sublime_text/sublime_text ~/.bash_profile"
alias subxr="/opt/sublime_text/sublime_text ~/.Xresources"

Shortcuts to edit startup files

alias vim="vim "
alias vi="vim "
alias vali=“vim ~/.bash/.alias”
alias vbrc=“vim ~/.bashrc”
alias vbpf=“vim ~/.bash_profile”

Misc utilities

alias du=“du -kh”
alias df=“df -kTh”
alias chx=“chmod +x”

launch ncmpcpp

alias ncmp=“ncmpcpp 2> /dev/null”

View the entire VIM User Guide

Change ‘vim80’ for currently installed version

if [ -x /bin/cat -a -x /usr/bin/vim ]; then
alias vug=’/bin/cat /usr/share/vim/vim80/doc/usr_*.txt | /usr/bin/vim -’
fi

Efficient and fairly portable way to display the current iface.

[ -x /sbin/ip ] && alias iface=‘X=(/sbin/ip route) && echo ${X[4]}’

Fix all CWD file and directory permissions to match the safer 0077 umask.

if [ -x /bin/chmod ]; then
alias fixperms=’
/usr/bin/find -xdev ( -type f -exec /bin/chmod 600 “{}” + -o
-type d -exec /bin/chmod 700 “{}” + )
-printf “FIXING: %p\n” 2> /dev/null

fi

Display a columnized list of bash builtins.

if [ -x /usr/bin/column ]; then
alias builtins=’
while read -r; do
echo “${REPLY/* }”
done <<< “$(enable -a)” | /usr/bin/column

fi

A more descriptive, yet concise lsblk; you’ll miss it when it’s gone.

if [ -x /bin/lsblk ]; then
alias lsblkid=’
/bin/lsblk -o name,label,fstype,size,uuid,mountpoint --noheadings

fi

Ease-of-use youtube-dl aliases; these save typing!

for DEP in /usr/{local/bin,bin}/youtube-dl; {
[ -x “$DEP” ] && {
alias ytdlv="$DEP -c --yes-playlist --sleep-interval 5
–format best --no-call-home --console-title
–ignore-errors"

	alias ytdla="$DEP -cx --audio-format mp3 --sleep-interval 5\
		--max-sleep-interval 30 --no-call-home --console-title\
		--quiet --ignore-errors"

	alias ytpla="$DEP -cix --audio-format mp3 --sleep-interval 5\
		--yes-playlist --no-call-home --console-title\
		--ignore-errors"

	alias ytplv="$DEP -ci --yes-playlist --sleep-interval 5\
		--format best --no-call-home --console-title\
		--ignore-errors"

	# Just use the first result.
	break
}

}
unset DEP

1 Like

syu is the recommended way to update packages, syyu or even syy are usually not recommended, you can use it if you know why or what you’re doing.
You can even switch the “u” alias to syu in the end.

Keep in mind i update my system once a month or more, that’s why i usuallly run “u” and then update everything. But after this post i just switched “syy” to syu in the end of “u” alias here as well.

I thought yy means you force a sync even though the mirrors claim they’re already synced, right? So unless you suspect the mirrors are not correct somehow it really should just re-sync to be sure? It’s not like Syyuu that also do forced downgrades, which is another story.

2 Likes

I never thought you can get so much out of your bashrc. Thank you very much so far for your script-fu, masters of the terminal. :smile:
I will totally steal some lines from them…

3 Likes

~/.bashrc can do much more than the aliases. Note that I have nothing against aliases.

There you may have also functions, which can be set up somewhat like aliases, but are much more versatile.

Here is one of my favorite examples, the ‘e’:

# 'e' opens any file with the correct program, e.g. e test.doc opens
# a file with libreoffice for editing.
# Usage: e file-name(s)
# Assumes either exo or xdg-utils is installed.
e() { exo-open "$@" & }   # with exo
e() { xdg-open "$@" & }   # with xdg-utils

You may want to get rid of warning messages that some programs give with ‘e’:

e() { exo-open "$@" >& /dev/null & }   # now 'e' will not give any error messages

So with e you don’t have to remember which program can open a file. It works with many file types, like .doc, .odt, .pdf, .txt, etc. If some file doesn’t open with the right program, you can configure the program with your file manager.

2 Likes

A couple of useful commands for dealing with aliases and functions:

  • type – shows info about a commands, aliases or functions. Example:
type ls  # shows how ls is currently defined
  • typeset – can show contents of functions. Examples:
typeset -F         # shows all currently defined function names
typeset -f | less  # same as above but shows also the contents of the functions
2 Likes