dynamic aliases

This commit is contained in:
Piotr Domański 2024-02-20 15:49:52 +01:00
parent 06e662079e
commit 016450ecbb
9 changed files with 36 additions and 182 deletions

View file

@ -1,11 +1,7 @@
# parallels
alias stoppar='pkill -SIGHUP -f /Applications/Parallels\ Desktop.app'
alias startpar='open -a Parallels\ Desktop'
alias startparra='hc && open -a Parallels\ Desktop'
alias stopparra='hc && pkill -SIGHUP -f /Applications/Parallels\ Desktop.app'
# docker
alias startdocker='open -a Docker'
alias stopdocker="pkill -SIGHUP -f /Applications/Docker.app 'docker serve'"
alias sd='startdocker'
alias ssd='startdocker'
# macos specific aliases
if [ "$(uname)" = "Darwin" ]; then
alias stoppar='pkill -SIGHUP -f /Applications/Parallels\ Desktop.app'
alias startpar='open -a Parallels\ Desktop'
alias startparra='hc && open -a Parallels\ Desktop'
alias stopparra='hc && pkill -SIGHUP -f /Applications/Parallels\ Desktop.app'
fi

View file

@ -1,3 +1,14 @@
# managing aliases
alias aliases='cat ~/.config/aliasrc/*'
alias editalias='vim ~/.config/aliasrc'
alias aliasrc='cd ~/.config/aliasrc'
alias scriptrc='cd ~/.config/scriptrc'
function falias() {
local al
al=$(alias | fzf)
if [ -n "$al" ]; then
echo $al
fi
}

View file

@ -1,3 +0,0 @@
# fun
alias ='cat'
alias toansi='python3 $HOME/Projects/Personal/image-to-ansi/image-to-ansi.py'

View file

@ -1,59 +0,0 @@
# Personal
alias my='cd ~/Projects/Personal'
alias ot='cd ~/Projects/Other'
# KRAKEN
alias set_kraken='sudo colctl --fan_speed 40 --pump_speed 80 -m Breathing -c 255,255,255 -cc 2 -c0 255,255,255 -c1 0,0,0'
alias fast_kraken='sudo colctl --fan_speed 60 --pump_speed 90 -m Breathing -c 255,255,255 -cc 2 -c0 255,255,255 -c1 0,0,0'
alias max_kraken='sudo colctl --fan_speed 100 --pump_speed 100 -m Breathing -c 255,255,255 -cc 2 -c0 255,255,255 -c1 0,0,0'
# sorter
alias srt='py /home/doman/Projects/Personal/folder_observer/observer.py -v --sort-old'
# sync
alias syncpi='~/Projects/Personal/services/syncpi.sh'
# reload vertical
alias rr="~/Projects/Personal/scripts/reload_vertical.sh"
# resizer
alias res="python3 ~/Projects/Personal/scripts/resizer.py"
# android scrcpy and sndcpy
alias andek="python3 ~/Projects/Personal/scripts/andek.py"
# skirmish
alias skm="cd ~/Projects/Personal/skirmish-online"
# xdg-open
[ "$(uname)" = "Darwin" ] || alias open='xdg-open'
# stats
alias startstats='python /home/doman/Projects/Personal/scripts/stats.py'
# fasttyper
alias ff='fasttyper'
fff () {
while true; do
fortune | python -c "import sys; print(sys.stdin.read().split('--')[0].strip())" | python -m fasttyper || break
done
}
# genpswd
alias genpswd="python -c \"import random, pyperclip; pyperclip.copy(''.join([chr(random.randrange(40,127)) for _ in range(40)]))\""
# cds
alias cm="cd /run/media/${USER}/*/"
alias dwn="cd ${HOME}/Downloads"
alias dcs="cd ${HOME}/Documents"
alias pct="cd ${HOME}/Pictures"
# killing
alias killq="gsettings set org.gnome.desktop.wm.keybindings close \"['<Ctrl>q']\""
alias nokillq="gsettings set org.gnome.desktop.wm.keybindings close \"['<Ctrl>F13']\""
# fooder
alias fd='cd ~/Projects/Personal/fooder/api && source .venv/bin/activate'
# ssh
sshcd () { ssh -t "$1" "cd \"$2\"; exec \$SHELL -l"; }

View file

@ -2,56 +2,43 @@
alias cp='cp -v'
alias mv='mv -v'
alias rm='rm -v'
alias ff='fasttyper'
# exit
alias e='exit'
# program shortcuts
alias dc='docker-compose'
alias e='exit'
alias grep='grep --color=auto'
alias killdocker='docker kill $(docker ps -q)'
alias cleardocker='docker system prune && docker volume prune'
alias balancedocker='sudo btrfs filesystem balance /var/lib/docker'
# ls
alias ls='exa --icons -g'
alias ll='ls -lh'
alias lls='ls -lhrs modified'
alias la='ls -a'
alias lla='ls -lha'
alias l='ls'
lst() { exa --no-icons --sort=time | head --lines=1; }
# python
alias py='python3'
alias py3='python3'
alias pip='python3 -m pip'
alias ipy='ipython --TerminalInteractiveShell.editing_mode=vi --TerminalInteractiveShell.timeoutlen=0.2'
# vim
alias vim='nvim'
alias v='vim'
alias vv='vifm'
# kitty
if [ "$TERM" = "xterm-kitty" ]; then
alias kssh='kitty +kitten ssh'
fi
# pacman and yay
alias spa='sudo pacman -S'
alias spaa='sudo pacman -S --overwrite="*"'
alias spu='sudo pacman -Syyuu'
alias spm='sudo pacman -Syy'
alias spr='sudo pacman -R'
alias ys='yay -S'
alias yss='yay -S --overwrite="*"'
alias yr='yay -R'
alias yu='yay -Syyuu'
# copy piped to clipboard
cpy() { py -c "import sys, pyperclip; pyperclip.copy(sys.stdin.read().strip())"; }
# brew
alias bu='brew update && brew update --cask'
alias bup='brew upgrade && brew upgrade --cask'
alias bd='brew doctor'
alias bp='brew pin'
alias bi='brew install'
alias bic='brew install --cask'
# pandoc
alias npandoc='pandoc --from markdown --template ~/.config/pandoc/eisvogel.tex'
# other
lst() { \ls --sort=time | head --lines=1; }
# history
hlst() { history | tail --lines=1 | cut -d " " -f 4-; }
cpy() { python -c "import sys, pyperclip; pyperclip.copy(sys.stdin.read().strip())"; }
lstc() { lst | cpy; }
hlstc() { hlst | cpy; }

View file

@ -1,15 +0,0 @@
# Studies - Nextcloud
alias stu='cd ~/Nextcloud/Studia'
alias strak='stu && cd TRAK'
alias sinz='stu && cd INZ'
alias skoda='stu && cd KODA'
alias smgr='stu && cd MGR'
alias sporr='stu && cd PORR'
alias spti='stu && cd PTI'
alias strak='stu && cd TRAK'
alias saso='stu && cd ASO'
# Studies - Projects
alias stud='cd ~/Projects/Studies'
alias eng='stud && cd eng'
alias mgr='stud && cd mgr'

View file

@ -1,4 +0,0 @@
# thinkpad
alias fsize='gsettings set org.gnome.desktop.interface text-scaling-factor'
alias sfont='fsize "1.0"'
alias bfont='fsize "1.9"'

View file

@ -1,59 +0,0 @@
# Work directories
WORK="$HOME/Projects/Work"
UTIL="$HOME/Projects/Work/utility"
PUB="$HOME/Projects/Work/publikator/"
AR="$HOME/Projects/Work/arriva_server/"
NEG="$HOME/Projects/Work/negocjator/"
SZ="$HOME/Projects/Work/szyna/"
# Workflow
alias work="cd $WORK"
alias util="cd $UTIL && make"
alias pub="cd $PUB"
alias neg="cd $NEG"
alias sz="cd $SZ"
alias ar="cd $AR"
alias activate_venv="[ -f .venv/bin/activate ] && source .venv/bin/activate"
alias display_makefile_help="[ -f Makefile ] && make"
# dynamic aliases
create_work_aliases() {
for d in $PUB/*; do
if [ -d "$d" ]; then
last_part=$(basename $d | tr "_" " " | awk '{print $NF}')
last_part=${last_part:0:1}
last_part=$(echo $last_part | tr '[:upper:]' '[:lower:]')
alias pub$last_part="cd $d && display_makefile_help && activate_venv"
fi
done
for d in $NEG/*; do
if [ -d "$d" ]; then
last_part=$(basename $d | tr "_" " " | awk '{print $NF}')
last_part=${last_part:0:1}
last_part=$(echo $last_part | tr '[:upper:]' '[:lower:]')
alias neg$last_part="cd $d && display_makefile_help && activate_venv"
fi
done
for d in $SZ/*; do
if [ -d "$d" ]; then
last_part=$(basename $d | tr "_" " " | awk '{print $NF}')
last_part=${last_part:0:2}
last_part=$(echo $last_part | tr '[:upper:]' '[:lower:]')
alias sz$last_part="cd $d && display_makefile_help && activate_venv"
fi
done
for d in $AR/*; do
if [ -d "$d" ]; then
last_part=$(basename $d | tr "_" " " | awk '{print $NF}')
last_part=${last_part:0:1}
last_part=$(echo $last_part | tr '[:upper:]' '[:lower:]')
alias ar$last_part="cd $d && display_makefile_help && activate_venv"
fi
done
}
create_work_aliases

2
.zshrc
View file

@ -220,7 +220,7 @@ fi
# Load scripts
if [ -d "$HOME/.config/scriptrc" ]; then
for SCRIPTFILE in $HOME/.config/scriptrc/*sh; do
for SCRIPTFILE in $HOME/.config/scriptrc/*.sh; do
source $SCRIPTFILE
done
fi