summaryrefslogtreecommitdiff
path: root/config/essentials/shell
diff options
context:
space:
mode:
Diffstat (limited to 'config/essentials/shell')
-rw-r--r--config/essentials/shell/aliases.sh18
-rw-r--r--config/essentials/shell/functions.sh74
2 files changed, 90 insertions, 2 deletions
diff --git a/config/essentials/shell/aliases.sh b/config/essentials/shell/aliases.sh
index 68b66f2..77c7684 100644
--- a/config/essentials/shell/aliases.sh
+++ b/config/essentials/shell/aliases.sh
@@ -3,6 +3,7 @@
# The most important one
alias vi='nvim'
+alias cd='z'
# Zsh specific aliases
if [ $SHELL = "/bin/zsh" ]
@@ -149,6 +150,7 @@ alias wd='dict'
# ssh
alias sha='ssh-add'
alias sshs='eval "$(ssh-agent)" && ssh-add'
+alias sshids='ssh-add -L | xargs -I{} grep "{}" -l $(find "$HOME/.ssh" -type f -iname '\''*.pub'\'') | sed "s;$HOME/.ssh/;;;s;\.pub$;;"'
alias whatsmyip='curl -s "ifconfig.co"'
alias icognito='unset HISTFILE'
alias webcam='v4l2-ctl --set-fmt-video=width=1280,height=720; mpv --demuxer-lavf-format=video4linux2 --demuxer-lavf-o-set=input_format=mjpeg av://v4l2:/dev/video0 --profile=low-latency --untimed --no-resume-playback'
@@ -167,7 +169,14 @@ alias wgdown='doas wg-quick down wg0'
alias npi="npm init --yes"
# Python
-alias penv='python3 -m venv env'
+
+if which uv > /dev/null 2>&1
+then
+ alias penv='uv venv env'
+ alias pip='uv pip'
+else
+ alias penv='python3 -m venv env'
+fi
alias phttp='python3 -m http.server'
alias pipreq='pip install -r requirements.txt'
@@ -331,3 +340,10 @@ alias update-mirrors='reflector -p https | rankmirrors -n 10 -p -w - | doas tee
alias tmpd='cd $(mktemp -d)'
alias brs='$BROWSER'
+which bat > /dev/null 2>&1 &&
+ alias cat="bat -p"
+
+alias glf='git pull --ff'
+alias glnf='git pull --no-ff'
+alias quickvms='/media/cricket/vms/quickemu/"$(find '\''/media/cricket/vms/quickemu/'\'' -type f -iname '\''*.conf'\'' -printf '\''%f
+'\'' | sed '\''s/\.conf$//'\'' | fzf)".conf 2> /dev/null'
diff --git a/config/essentials/shell/functions.sh b/config/essentials/shell/functions.sh
index 299b5e8..9f7f4ce 100644
--- a/config/essentials/shell/functions.sh
+++ b/config/essentials/shell/functions.sh
@@ -50,7 +50,7 @@ og()
_googoo_fzf_opt "$1"
cd "$(goo d "$dest" | fzf $opt)"
}
-ogo()
+oog()
{
_googoo_fzf_opt "$1"
cd "$(dirname "$(goo f "$dest" | fzf $opt)")"
@@ -68,7 +68,10 @@ sms() { ssh -t phone sendmsg "$1" "'$2'"; }
trcp() { scp "$1" db:/media/basilisk/downloads/transmission/torrents/; }
rln() { ln -s "$(readlink -f "$1")" "$2"; }
getgit() { git clone git@db:"$1"; }
+
esc() { eval "$EDITOR '$(which $1)'"; }
+compdef esc="which"
+
delfile() { curl -s "${2:-https://upfast.cronyakatsuki.xyz/delete/$1}"; }
upfile() { curl -s -F "file=@\"$1\"" "${2:-https://0x0.st}"; }
to_webm() { ffmpeg -y -i "$1" -vcodec libvpx -cpu-used -12 -deadline realtime "${1%.*}".webm; }
@@ -292,3 +295,72 @@ edit_in_dir() {
[ -f "$file" ] || return 1
$EDITOR "$file"
}
+
+# Download a file from google drive
+# link like this: https://drive.usercontent.google.com/download?id=1TiJDEftTtF1KTMBI950Bj487ndYqkwpQ&export=download
+gdown () {
+ agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/12$(head /dev/urandom | tr -dc '0-1' | cut -c1).0.0.0 Safari/537.36"
+ uuid=$(curl -sL "$1" -A "$agent" | sed -nE 's|.*(uuid=[^"]*)".*|\1|p')
+ aria2c -x16 -s16 "$1&confirm=t&$uuid" -U "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36" --summary-interval=0 -d "${2:-.}"
+}
+
+# toggle wireguard vpn on $1 -> interface
+wgtoggle() {
+ d="${1:-wg0}"
+ ip -br a | awk '{print $1}' | grep "$d" > /dev/null &&
+ doas wg-quick down "$d" ||
+ doas wg-quick up "$d"
+}
+
+# serve a file through dufs
+serve() {
+ if [ "$1" ]
+ then
+ logn "Serving $1"
+ docker container run \
+ --rm \
+ --volume "$(readlink -f "$1")":/data \
+ --publish 80:5000 sigoden/dufs /data
+ else
+
+ logn "Receiving files.."
+ docker container run \
+ --rm \
+ --volume /tmp/data:/data \
+ --publish 80:5000 sigoden/dufs /data --allow-upload
+ fi
+}
+
+ssh_keyadd() { ssh-keygen -f "$HOME"/.ssh/"$1" -P "$(pass generate -f keys/"$HOST"/ssh/"$1" | tail -n 1)" -t ed25519; }
+
+
+fchange()
+{
+ [ "$1" ] || return 1
+ inotifywait -m -e create,modify,delete --format "%f" "${2:-.}" |
+ while read -r EVENT
+ do
+ eval "$1"
+ done
+}
+
+unhappy.exe() {
+ [ "$1" ] &&
+ smiles=("[: " ".-." " :]" "._.") ||
+ smiles=("]: " ".-." " :[" "._.")
+
+ while true
+ do
+ for s in $smiles
+ do
+ printf '\r%s' "$s"
+ sleep 1
+ done
+ done
+}
+
+ssh_port()
+{
+ ssh -f -N -L 0.0.0.0:"$3":localhost:"$1" "$2"
+ >&2 printf "Forwarded port '%s' on '%s' to '%s'.\n" "$1" "$2" "$3"
+}