profile/aliases.sh

142 lines
4.1 KiB
Bash

#!/bin/sh
ALIASES_BLACK='\033[0;30m' # Black
ALIASES_RED='\033[0;31m' # Red
ALIASES_GREEN='\033[0;32m' # Green
ALIASES_YELLOW='\033[0;33m' # Yellow (or Brown)
ALIASES_BLUE='\033[0;34m' # Blue
ALIASES_MAGENTA='\033[0;35m' # Magenta
ALIASES_CYAN='\033[0;36m' # Cyan
ALIASES_LIGHT_GRAY='\033[0;37m' # Light Gray (or White)
ALIASES_DARK_GRAY='\033[1;30m' # Dark Gray
ALIASES_LIGHT_RED='\033[1;31m' # Light Red
ALIASES_LIGHT_GREEN='\033[1;32m' # Light Green
ALIASES_LIGHT_YELLOW='\033[1;33m' # Light Yellow
ALIASES_LIGHT_BLUE='\033[1;34m' # Light Blue
ALIASES_LIGHT_MAGENTA='\033[1;35m' # Light Magenta
ALIASES_LIGHT_CYAN='\033[1;36m' # Light Cyan
ALIASES_WHITE='\033[1;37m' # White
ALIASES_NC='\033[0m' # No Color
echo "Aliases added:"
echo -e "${ALIASES_WHITE} cs venv"
echo " n ns pc cdlf lfcd g gg gitknow disk-usage"
echo " mc newsh smartresize"
echo " red alice zirconia ultra pest p1 pi pi4 pi02"
echo -e "${ALIASES_NC}"
echo -e "Update system with: ${ALIASES_LIGHT_RED}update${ALIASES_NC}"
echo ""
alias backup='sudo borgmatic create --verbosity 1 --files'
alias disk-usage='sudo du -h -d 2 .[^.]* * | sort -h'
alias anki='anki --no-sandbox'
alias cs='lxc list -c ns4s,user.comment:comment'
alias pc='pcmanfm . & disown'
alias media-window='bspc node -z top 0 +530'
# enable aliases for commands inside sudo
# TOOD check this is safe
alias sudo='sudo '
alias venv='source ./venv/bin/activate'
alias e='nvim'
alias er='nvim README.md'
alias et='nvim TODO.md'
alias en='nvim NOTES.md'
alias ee='nvim .'
alias es='nvim -S Session.vim'
alias g='git status'
alias gg='git add . && git commit -m "update" && git push'
alias gitknow='cd ~/knowledge-base && git add . && git status && git commit -m update && git push ; cd -'
alias ls='ls --color=auto -h --group-directories-first --time-style=+"%d.%m.%Y %H:%M" -F'
alias cp='cp -irv'
alias mkdir='mkdir -vp'
alias mv='mv -iv'
alias rm='rm -dv'
alias wget='wget --hsts-file="$XDG_DATA_HOME/wget-hsts"'
alias grep='grep --colour=auto'
alias egrep='egrep --colour=auto'
alias fgrep='fgrep --colour=auto'
alias hgrep='history | grep --color=auto'
alias bc='bc -q -l'
alias ytdl='youtube-dl --write-info-json --write-description --no-playlist'
alias ytdlb='youtube-dl --write-info-json --write-description --no-playlist -a'
alias ytdl-mp3='youtube-dl -f bestaudio --extract-audio --audio-format mp3 --embed-thumbnail --add-metadata'
alias pi='ssh pi@192.168.0.11'
alias pi02='ssh pi@192.168.0.12'
alias pi4='ssh pi@192.168.0.14'
alias p1='ssh p1.isnet.uk'
alias red='ssh ray@red.isnet.uk'
alias alice='ssh ray@alice.isnet.uk'
alias zirconia='ssh runcloud@zirconia.rayelliott.dev'
alias ultra='ssh gabbaell@mimas.usbx.me'
alias pest='ssh ray@77.68.75.71'
alias pacman="echo 'SHOULD BE USING update!!!!' && sudo ~/.src/archnews/archnews_wrap"
# lf gets confused by TERMINFO env var when running in tmux
# https://github.com/gokcehan/lf/issues/138#issuecomment-464477665
if [ -n "$TERMINFO" ] ; then
alias lf="TERMINFO= lf -last-dir-path=~/.cache/lf-last-dir"
else
alias lf="lf -last-dir-path=~/.cache/lf-last-dir"
fi
cdlf() {
cd "$(cat ~/.cache/lf-last-dir)"
}
lfcd() {
lf -last-dir-path="$HOME"/.cache/lf-last-dir
cdlf
}
update() {
echo -e "Executing \"${ALIASES_GREEN}pacman -Syu${ALIASES_NC}\" via \"${ALIASES_BLUE}archnews_wrap${ALIASES_NC}\" wrapper"
sudo ~/.src/archnews/archnews_wrap -Syu && cat /dev/null > /home/ray/.checkupdates
}
# functions
# $1 - output directory
# $2 - size
# $3 - filename
smartresize() {
mogrify -path "$3" -filter Triangle -define filter:support=2 -thumbnail "$2" -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB "$1"
}
re() {
git clone ssh://git@git.rayelliott.dev:3222/rayelliott/"$1".git $2
}
mc() {
mkdir "$1" && cd "$1"
}
newsh() {
set -e
if [ -f "$1" ] ; then
echo "Error: file exists: $1"
exit 1
fi
echo "#!/bin/sh" > "$1"
echo "" >> "$1"
echo "$2" >> "$1"
chmod +x "$1"
nvim "$1" +3
}