dotfiles/general/.aliases

277 lines
7.7 KiB
Plaintext
Raw Normal View History

2021-02-06 23:41:32 +01:00
#!/usr/bin/env bash
2021-05-28 21:01:01 +02:00
# When using zsh, see also
# $HOME/.oh-my-zsh/lib
2021-05-23 03:00:44 +02:00
2021-10-24 02:44:58 +02:00
export SCREENSHOT_DIR="$HOME/pictures/screenshots"
2021-05-28 21:01:01 +02:00
# ░█▀▀░█░█░▀█▀░░░█▀▀░█▀█░█▀▀░▀█▀░█░█░█▀█░█▀▄░█▀▀
# ░█▀▀░▄▀▄░░█░░░░▀▀█░█░█░█▀▀░░█░░█▄█░█▀█░█▀▄░█▀▀
# ░▀▀▀░▀░▀░░▀░░░░▀▀▀░▀▀▀░▀░░░░▀░░▀░▀░▀░▀░▀░▀░▀▀▀
2021-02-06 23:41:32 +01:00
2021-10-24 02:44:58 +02:00
# Music player
2021-02-06 23:41:32 +01:00
alias m="ncmpcpp"
2021-05-22 17:32:06 +02:00
2021-10-24 02:44:58 +02:00
# Text editor
2021-05-23 03:00:44 +02:00
if command -v nvim &> /dev/null; then
2021-05-22 17:32:06 +02:00
alias vim="nvim"
alias vi="nvim"
2021-05-23 03:00:44 +02:00
elif command -v vim &> /dev/null; then
2021-05-22 17:32:06 +02:00
alias nvim="vim"
alias vi="vim"
2021-05-23 03:00:44 +02:00
elif command -v vi &> /dev/null; then
2021-05-22 17:32:06 +02:00
alias nvim="vi"
alias vim="vi"
else
2021-05-23 03:00:44 +02:00
echo -e "\033[31m[ERROR] No vim program found on the system! Couldn't bind aliases!\033[0m"
fi
2021-10-24 02:44:58 +02:00
alias openfile='$HOME/.scripts/rofi/config-selector.py | xargs nvim'
2021-05-23 03:00:44 +02:00
2021-10-24 02:44:58 +02:00
# IPython
2021-05-23 03:00:44 +02:00
if command -v ipython &> /dev/null; then
alias p="ipython"
fi
2021-10-24 02:44:58 +02:00
# YouTube-dl
2021-05-23 03:00:44 +02:00
if command -v youtube-dl &> /dev/null; then
alias youtube-dl-list='youtube-dl -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio" -o "%(playlist_index)s-%(title)s.%(ext)s"'
2021-08-18 18:37:21 +02:00
alias music-dl='youtube-dl --extract-audio -f "bestaudio[ext=m4a]/best"'
2021-05-23 03:00:44 +02:00
alias music-dl-list='youtube-dl --extract-audio -f "bestaudio[ext=m4a]/best" -o "%(playlist_index)s-%(title)s.%(ext)s"'
fi
2021-10-24 02:44:58 +02:00
# Screenshots
2021-05-23 03:00:44 +02:00
if command -v maim &> /dev/null; then
2021-05-28 21:01:01 +02:00
alias skusho='maim --hidecursor --nokeyboard $(echo $SCREENSHOT_DIR)/$(date +%s).png'
2021-05-23 03:00:44 +02:00
if command -v xclip &> /dev/null; then
2021-05-28 21:01:01 +02:00
alias skushoclip='maim --hidecursor --nokeyboard --select | xclip -selection clipboard -target image/png -in'
2021-05-23 03:00:44 +02:00
fi
2021-05-22 17:32:06 +02:00
fi
2021-10-24 02:44:58 +02:00
# Scan listening ports
if command -v netstat &> /dev/null; then
alias ports='sudo netstat -tulpn | grep LISTEN'
fi
# Latex Make
if command -v latexmk &> /dev/null; then
alias view-latex='latexmk -pdf -pvc main.tex'
fi
# Tmux reload
if command -v tmux &> /dev/null; then
alias reload-tmux='tmux source $HOME/.config/tmux/tmux.conf'
fi
# Ag replacement
if command -v rg &> /dev/null; then
alias ag='rg'
fi
# Xmonad recompilation
if command -v xmonad &> /dev/null; then
alias xr='xmonad --recompile'
alias xmr='paru -S xmobar-git --noconfirm'
alias xxmr='xr; xmr'
fi
if [[ -f $HOME/.scripts/dropbox.py ]]; then
alias dp="python $HOME/.scripts/dropbox.py"
fi
# ------------------------ System tools ------------------------ #
# cp
if command -v z &> /dev/null; then
alias cd='z'
fi
# cp
2021-05-23 03:00:44 +02:00
if command -v rsync &> /dev/null; then
2021-05-28 21:01:01 +02:00
alias ccp='/usr/bin/cp'
alias cp='rsync --progress --human-readable'
alias cpr='rsync --progress --human-readable --recursive'
2021-05-23 03:00:44 +02:00
fi
2021-02-06 23:41:32 +01:00
2021-10-24 02:44:58 +02:00
# cat
2021-05-27 15:05:07 +02:00
if command -v bat &> /dev/null; then
alias ccat='/usr/bin/cat'
2021-10-24 02:44:58 +02:00
# TODO: use mdcat if the file is a markdown file
2021-05-27 15:05:07 +02:00
alias cat='bat'
fi
2021-10-24 02:44:58 +02:00
# htop
if command -v bottom &> /dev/null; then
alias htop='bottom'
2021-05-28 16:16:44 +02:00
fi
2021-10-24 02:44:58 +02:00
# ps
if command -v procs &> /dev/null; then
alias ps='procs'
2021-05-28 22:49:15 +02:00
fi
2021-10-24 02:44:58 +02:00
# find
if command -v fd &> /dev/null; then
# At the current time, fd does not support the -m flag, which I have
# experienced that some software rely on. Therefore, it's gonna be aliased
# to fin
alias fin='fd'
fi
2021-05-28 21:01:01 +02:00
2021-10-24 02:44:58 +02:00
# xxd
if command -v hex &> /dev/null; then
alias xxd='hex'
fi
2021-05-28 21:01:01 +02:00
2021-10-24 02:44:58 +02:00
# uniq
if command -v runiq &> /dev/null; then
alias uniq='runiq'
2021-05-28 21:01:01 +02:00
fi
2021-10-24 02:44:58 +02:00
# cut
if command -v hck &> /dev/null; then
alias cut='hck'
fi
# ------------------------ Reminders ------------------------ #
# compression decompression
if command -v ouch &> /dev/null; then
alias zip='echo "Consider using ouch instead\n"; zip'
alias unzip='echo "Consider using ouch instead\n"; unzip'
alias tar='echo "Consider using ouch instead\n"; tar'
fi
# Make tool
if command -v just &> /dev/null; then
alias make='echo "Consider using just instead\n"; make'
fi
# Disk usage viewer
if command -v diskonaut &> /dev/null; then
alias ncdu='echo "Consider using diskonaut instead\n"; ncdu'
2021-05-28 21:01:01 +02:00
fi
2021-02-06 23:41:32 +01:00
# ░█▀▀░█▀█░█░░░█▀█░█▀▄
# ░█░░░█░█░█░░░█░█░█▀▄
# ░▀▀▀░▀▀▀░▀▀▀░▀▀▀░▀░▀
2021-05-23 03:00:44 +02:00
if command -v exa &> /dev/null; then
2021-05-28 21:01:01 +02:00
alias lls='/usr/bin/ls'
2021-05-22 17:32:06 +02:00
alias ls='exa'
2021-05-28 21:01:01 +02:00
alias sl='ls'
alias lsa='exa -lah --changed --time-style long-iso --git --group'
2021-05-22 17:32:06 +02:00
else
alias ls='ls --group-directories-first --color=auto'
alias ll='ls -alFh --group-directories-first --color=auto'
alias la='ls -A --group-directories-first --color=auto -F'
fi
2021-02-06 23:41:32 +01:00
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
2021-05-28 22:08:01 +02:00
alias ip='ip --color'
2021-02-06 23:41:32 +01:00
2021-08-18 18:37:21 +02:00
alias gpg-tui='gpg-tui --style colored'
2021-05-28 21:01:01 +02:00
# ░█▀▄░▀█▀░█▀▄░░░▀▀█░█░█░█▄█░█▀█░█▀▀
# ░█░█░░█░░█▀▄░░░░░█░█░█░█░█░█▀▀░▀▀█
# ░▀▀░░▀▀▀░▀░▀░░░▀▀░░▀▀▀░▀░▀░▀░░░▀▀▀
alias gt='cd $HOME/git'
alias tmp='cd /tmp'
alias cd..='cd ..'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
2021-05-23 03:00:44 +02:00
2021-06-09 23:29:13 +02:00
alias rrn='chmod 440'
alias wwn='chmod 660'
alias xxn='chmod 770'
alias rrx='chmod 445'
alias wwr='chmod 664'
alias x3='chmod 775'
2021-02-06 23:41:32 +01:00
# ░█▄█░▀█▀░█▀▀░█▀▀
# ░█░█░░█░░▀▀█░█░░
# ░▀░▀░▀▀▀░▀▀▀░▀▀▀
2021-08-18 18:37:21 +02:00
alias dush='du -sh'
2021-02-06 23:41:32 +01:00
2021-05-28 21:01:01 +02:00
alias realias='source $HOME/.aliases'
alias q='exit'
alias rmr='rmdir'
alias pagga='toilet -f pagga'
# Supposed to be used as a pipe: "cat file | rainbow"
alias rainbow='toilet -f pagga | lolcat'
# ░█▀█░█▀█░█▀▀░█░░░▀█▀░█▀█░█▀▀░█▀▄░█▀▀
# ░█░█░█░█░█▀▀░█░░░░█░░█░█░█▀▀░█▀▄░▀▀█
# ░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀▀░▀░▀░▀▀▀░▀░▀░▀▀
2021-06-28 12:32:27 +02:00
alias killall-tmux="tmux ls | awk '{print $1}' | sed 's/://g' | xargs -I{} tmux kill-session -t {}"
2021-02-06 23:41:32 +01:00
# Get current Fcitx mode
2021-05-23 03:00:44 +02:00
alias get-fcitx-mode='qdbus "org.fcitx.Fcitx" "/inputmethod" "GetCurrentIM"'
2021-02-06 23:41:32 +01:00
2021-05-28 21:01:01 +02:00
alias wcd='find . -type f -exec cat {} + | wc -l'
2021-02-06 23:41:32 +01:00
2021-05-28 21:01:01 +02:00
# Make ftp server
alias makeftp='python -m pyftpdlib --directory=$HOME/ --port=2121'
2021-02-06 23:41:32 +01:00
2021-05-28 21:01:01 +02:00
alias echo-colors='for x in 0 1 4 5 7 8; do for i in {30..37}; do for a in {40..47}; do echo -ne "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m "; done; echo; done; done; echo "";'
2021-02-06 23:41:32 +01:00
2021-05-28 21:01:01 +02:00
# ░█▀▀░█░█░█▀█░█▀▀░▀█▀░▀█▀░█▀█░█▀█░█▀▀
# ░█▀▀░█░█░█░█░█░░░░█░░░█░░█░█░█░█░▀▀█
# ░▀░░░▀▀▀░▀░▀░▀▀▀░░▀░░▀▀▀░▀▀▀░▀░▀░▀▀▀
2021-02-06 23:41:32 +01:00
2021-05-28 21:01:01 +02:00
gac(){
git add $1 && git commit -a -m $2
}
2021-05-23 03:00:44 +02:00
2021-05-28 21:01:01 +02:00
c-file() {
nvim $($HOME/.scripts/rofi/config-selector.py)
}
2021-02-06 23:41:32 +01:00
2021-05-28 21:01:01 +02:00
if command -v netstat &> /dev/null; then
# Usage: $ conn-ips 80
conn-ips() {
netstat -tn 2>/dev/null | grep :$1 | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -nr | head
}
fi
2021-02-06 23:41:32 +01:00
2021-05-28 21:01:01 +02:00
# ░█▀▀░█▀█░█░█░█▀▄░█▀▀░█▀▀░█▀▀
# ░▀▀█░█░█░█░█░█▀▄░█░░░█▀▀░▀▀█
# ░▀▀▀░▀▀▀░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀▀
2021-02-06 23:41:32 +01:00
2021-05-28 21:01:01 +02:00
if [[ -f $HOME/.aliases.private ]]; then
source $HOME/.aliases.private
2021-05-23 03:00:44 +02:00
fi
2021-02-06 23:41:32 +01:00
2021-05-28 21:01:01 +02:00
if [[ -f $HOME/.aliases.desktop ]]; then
source $HOME/.aliases.desktop
2021-05-23 03:00:44 +02:00
fi
2021-02-06 23:41:32 +01:00
2021-05-28 21:01:01 +02:00
if [[ -f $HOME/.aliases.laptop ]]; then
source $HOME/.aliases.laptop
2021-05-23 03:00:44 +02:00
fi
2021-02-06 23:41:32 +01:00
2021-05-28 21:01:01 +02:00
if [[ -d "$HOME/.project-template-aliases" ]]; then
for f in $(find $HOME/.project-template-aliases/ -maxdepth 1 -type f)
do
source $f
done
2021-05-22 17:32:06 +02:00
fi