alias cat lolcat
alias ccat whatever ohmyzsh does for their colorize extension, I know it’s a function alias
Linux
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
Don't really organize my aliases after making them, so this might be a mess.
##################
# ~/.aliases #
##################
# Colours
alias color-GREEN='tput setaf 2'
alias color-RED='tput setaf 1'
alias color-CYAN='tput setaf 78'
alias color-PURPLE='tput setaf 128'
#alias color-BLUE='tput setaf 4'
alias color-RESET='tput sgr0'
alias color-LIGHT_PURPLE='tput setaf 5'
alias color-LIGHT_BLUE='tput setaf 12'
alias color-TEXT='tput setaf 15'
alias color-HIDDEN='tput setaf 236'
# don't set a shutdown timer
alias shutdown='shutdown now'
# grep
alias grep='grep --color=auto'
alias pgrep='pgrep -l'
# package manager
alias pacman='sudo pacman --color=auto'
alias paru='paru --color=auto'
# ls
alias ls='eza -aMF --hyperlink --group-directories-first --icons --color=auto'
alias ll='eza -alhMF@ --hyperlink --group-directories-first --icons --color=auto --color-scale'
alias lg='eza -alhMF@ --hyperlink --group-directories-first --icons --git --git-repos --git-ignore --color=auto --color-scale'
# confirm before overwriting
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
# update grub.cfg
alias grub-update='sudo grub-mkconfig -o /boot/grub/grub.cfg'
# update function
u() {
# update distro specific packages
if command -v pacman &> /dev/null
then
# update pacman packages
printf "\n[Update] Updating Standard Packages:\n\n"
sudo pacman -Syu --color=auto
# update aur packages
if command -v paru &> /dev/null
then
printf "\n[Uodate] Updating AUR Packages:\n\n"
paru -Sau --color=auto
fi
elif command -v apt &> /dev/null
then
# update apt packages
printf "\n[Update] Updating Standard Packages:\n\n"
sudo apt-get update
sudo apt-get upgrade
fi
# update flatpaks
if command -v flatpak &> /dev/null
then
printf "\n[Update] Updating flatpaks:\n\n"
flatpak update
fi
# todo:
# - update grub
# - source shell config
printf "\n[Update] Done\n"
}
# view metadata
alias meta='exiftool'
# makepkg dependencies and install
alias makepkg='makepkg -si'
# git
alias gc='git clone'
# quick probe
alias probe='sudo -E hw-probe -all -upload -show -verbose'
# shorten pacman commands
alias pm='pacman'
alias pms='pm -Syu'
alias pmr='pm -Rns'
alias pmq='pm -Q'
alias pmu='pm -U'
alias pmd='sudo downgrade'
alias pmc='sudo paccache'
# rm pacman lock
alias rmpml='sudo rm /var/lib/pacman/db.lck'
# quick access to configs
alias brc='$EDITOR ~/.bashrc'
alias bash='exec bash'
alias zrc='$EDITOR ~/.zshrc'
alias zsh='exec zsh'
alias alia='$EDITOR ~/.aliases'
alias expo='$EDITOR ~/.exports'
alias swayc='$EDITOR ~/.config/sway/config'
#alias alac-conf='$EDITOR ~/.config/alacritty/alacritty.yml'
alias starc='$EDITOR ~/.config/starship.toml'
alias kittc='$EDITOR ~/.config/kitty/kitty.conf'
alias nvimc='$EDITOR ~/.config/nvim/init.vim'
# alias fetch scripts with hyfetch during pride month
[[ $(date +'%b') == "Jun" ]] && alias neofetch='hyfetch -b neofetch'
[[ $(date +'%b') == "Jun" ]] && alias fastfetch='hyfetch -b fastfetch'
# use fastfetch backend for hyfetch
alias hyfetch='hyfetch -b fastfetch'
# add sudo
alias docker='sudo docker'
alias systemctl='sudo systemctl'
# systemd
alias sc='systemctl'
alias sce='sc enable'
alias scd='sc disable'
alias scs='sc start'
alias scu='sc stop' # the u comes from unset
alias scr='sc restart'
# yt-dlp
alias ytm='yt-dlp -x -o "~/Music/%(title)s.%(ext)s" --add-metadata --embed-thumbnail --audio-quality 0'
alias ytv='yt-dlp -o "~/Videos/%(title)s.%(ext)s" --add-metadata --embed-thumbnail --embed-subs --embed-chapters'
# edit quicker
alias e='$EDITOR'
alias se='sudoedit'
# ryujinx (created by pinejinx)
alias ryu="AMD_DEBUG=w32ge,w32cs,nohyperz,nofmask glsl_zero_init=true radeonsi_clamp_div_by_zero=true force_integer_tex_nearest=true mesa_glthread=false vblank_mode=0 RADV_PERFTEST=bolist gamemoderun DOTNET_EnableAlternateStackCheck=1 GDK_BACKEND=x11 /home/luna/.local/share/Ryujinx/Ryujinx"
# Vencord
alias inven="sudo VencordInstallerCli-linux -install && sudo VencordInstallerCli-linux -install-openasar"
alias unven="sudo VencordInstallerCli-linux -uninstall && sudo VencordInstallerCli-linux -uninstall-openasar"
# bun > npm
alias npm='bun'
# replace cat
alias cat='bat'
# sudo
alias s='sudo'
alias clear="clear; fastfetch"
alias sudo="doas"
alias clr="clear"
alias kx="killall Xwayland"
alias vpython="~/newVenv/bin/python"
alias vpip="~/newVenv/bin/pip"
For system updates:
[ -r /etc/os-release ] && . /etc/os-release
case "$ID" in
arch|archarm)
if which paru > /dev/null 2>&1; then
alias updates='echo Using paru; paru'
else
alias updates='echo Using pacman; sudo pacman -Syu --noconfirm'
fi
;;
debian|ubuntu)
alias updates='echo Using apt dist-upgrade; sudo apt update && sudo apt dist-upgrade -y'
;;
esac
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 function separator_line_with_text()
to help with the output, basically setting off the file-info portion (just the filename for now) from the file contents.
# # separator_line_with_text
# # Centers text in a separator line
# #
# # Usage:
# # separator_line_with_text «separator_char» «text»
separator_line_with_text() {
local separator_char="$1"
local contents_str="$2"
# Calculate separator_length
local separator_length=$(( $(tput cols) - 2 - ${#contents_str} ))
# Calculate the width of the left and right parts of the separator line
local half_line_width=$(( (${separator_length}) / 2 ))
# Construct the separator line using the $separator_char and $contents_str
for ((i = 0; i « half_line_width; i++))
do
echo -n ${separator_char}
done
echo -n ${contents_str}
for ((i = 0; i < half_line_width; i++))
do
echo -n ${separator_char}
done
echo ""
}
# # read_latest_log
# # Reads the latest log file with a timestamp in the filename.
# #
# # Usage:
# # read_latest_log [[«name_filter»] «extension»] «separator» «timestamp_field_number»
read_latest_log () {
# Check if the function has sufficient parameters
if [[ $# -lt 2 ]]; then
echo "Error: insufficient parameters."
echo "Usage: read_latest_log [[«name_filter» = *] [«extension» = log] «separator» «timestamp_field_number»"
return 1
fi
# Supposing only two parameters are provided
# «name_filter» parameter is "*"
# «extension» parameter is "log"
if [[ $# -eq 2 ]]; then
local name_filter="*"
local extension="log"
local separator="$1"
local field="$2"
fi
# Supposing only three parameters are provided,
# assume that the «name_filter» parameter is "*"
if [[ $# -eq 3 ]]; then
local name_filter="*"
local extension="$1"
local separator="$2"
local field="$3"
fi
# If all parameters are provided, assign them accordingly
if [[ $# -eq 4 ]]; then
local name_filter="$1"
local extension="$2"
local separator="$3"
local field="$4"
fi
# Find all log files with the specified extension, sort them based on the separator and field
local log_files=$(find . -type f -name "${name_filter}.${extension}" | sort -n -t "${separator}" -k "${field}")
# If no log files are found, display a message and return
if [[ -z "$log_files" ]]; then
echo "No log files found."
return 0
fi
# Get the latest log file and its full path
local latest_log_file=$(echo "$log_files" | tail -1)
local full_path=$(realpath "$latest_log_file")
# Define the strings for the separator line and
# calculate the appropriate length of the separator line
local contents_str=" Contents "
local separator_char="—"
separator_line_with_text ${separator_char} ""
separator_line_with_text " " ${full_path}
separator_line_with_text ${separator_char} ${contents_str}
cat "$(echo "$log_files" | tail -1)"
}
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.
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
I don't like having to renavigate to my project directory in a new terminal:
alias clone='(pwd | urxvt & disown $!)'
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.
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)
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.
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
}
I'm a simple man. I do simple things. I replace df
, ls
and top
with more modern alternatives. Courtesy of this list.
alias df="duf"
alias ls="eza --group-directories-first --long --group --sort=ext --icons --all"
alias top="btm"
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
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'