config/user/.config/zsh/alias

174 lines
3.6 KiB
Plaintext

# configure some coreutils
alias ls='ls -AhN --color=always --group-directories-first' \
rm='rm -r' \
mv='mv -i' \
cp='cp -i' \
mkdir='mkdir -p'
# cd up dirs
alias ...='cd ../..' \
....='cd ../../..' \
.....='cd ../../../..' \
......='cd ../../../../..' \
.......='cd ../../../../../..' \
........='cd ../../../../../../..' \
.........='cd ../../../../../../../..' \
..........='cd ../../../../../../../../..' \
...........='cd ../../../../../../../../../..'
# shortucts
## programs
alias music='ncmpcpp' \
e="$EDITOR" \
f='lf' \ e="$EDITOR" \
nw="$TERMINAL 2> /dev/null & disown" \
copy="xclip -selection clipboard" \
dl='curl -LO' \
drdr="dragon-drop -a -x"
## git
alias ga='git add' \
gA='git add -A' \
gch='git checkout' \
gC='git clone' \
gc='git commit' \
gca='git commit --amend' \
gd='git diff' \
gl='git log' \
gp='git push' \
gP='git pull' \
gprs='git pull --recurse-submodules'\
gr='git reset' \
gR='git reset --hard' \
gS='git status'
gnr () {
[ -z $1 ] && {
echo 'Please enter a repo name'
return 1
}
git init
git remote add origin 'gitea@git.jakubb.xyz:jakub/'"$1"'.git'
git add -A
git commit -m "init"
git push -u origin -o repo.private=false master
}
gnpr () {
[ -z $1 ] && {
echo 'Please enter a repo name'
return 1
}
git init
git remote add origin 'gitea@git.jakubb.xyz:jakub/'"$1"'.git'
git add -A
git commit -m "init"
git push -u origin -o repo.private=true master
}
gnhr () {
[ -z $1 ] && {
echo 'Please enter a repo name'
return 1
}
git init
git remote add origin 'gitea@git.jakubb.xyz:34mdh/'"$1"'.git'
git add -A
git commit -m "init"
git push -u origin -o repo.private=false master
}
gnphr () {
[ -z $1 ] && {
echo 'Please enter a repo name'
return 1
}
git init
git remote add origin 'gitea@git.jakubb.xyz:34mdh/'"$1"'.git'
git add -A
git commit -m "init"
git push -u origin -o repo.private=true master
}
## make
alias mk='make' \
mkc='make clean' \
smi='sudo make install ' \
smic='sudo make install clean'
## clean up after patch
alias pc="rm *.orig; rm -i *.rej"
# updating
update-zsh-plugins() {
for dir in "${XDF_DATA_HOME:-$HOME/.local/share}/zsh/plugins"/*; do
git -C "$dir" pull
done
kill -42 "$( pidof dwmblocks )"
}
update-nvim-plugins() {
nvim --headless -c 'PackerSync'
kill -42 "$( pidof dwmblocks )"
}
update-all() {
update-zsh-plugins
#update-nvim-plugins
yay
}
alias upsh='update-zsh-plugins' \
upn='update-nvim-plugins' \
upa='update-all'
# quit shortcuts
alias ZZ='exit' \
ZQ='exit' \
q='exit' \
qw='exit' \
# use lf to cd
lf() {
export LF_CD_FILE=/var/tmp/.lfcd-$$
command lf-run $@
if [ -s "$LF_CD_FILE" ]; then
local DIR="$(realpath "$(cat "$LF_CD_FILE")")"
if [ "$DIR" != "$PWD" ]; then
cd "$DIR"
fi
rm "$LF_CD_FILE"
fi
unset LF_CD_FILE
}
# long commands
srch() {
if [ -z "$1" ]; then
echo 'Please enter a search pattern'
return 1
else
find -name '*'"$1"'*'
fi
}
alias rspw='systemctl restart --user pipewire-pulse.socket pipewire-pulse.service pipewire.socket pipewire.service' \
rfa="source ${XDG_CONFIG_HOME:-$HOME/.config}/zsh/alias" \
ushp='update-zsh-plugins' \
unp='update-nvim-plugins'
generate_password() {
if [ "$1" = '-s' ]; then
tr -dc 'A-Za-z0-9' </dev/urandom | head -c "$1" ; echo
else
tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' </dev/urandom | head -c "$1" ; echo
fi
}
alias hsn='hugo server --noHTTPCache'
# source personal aliases
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/zsh/personal/alias" ] && \
source "${XDG_CONFIG_HOME:-$HOME/.config}/zsh/personal/alias"