From f8e906c634ca84a356edc24498e2a4336d2c138b Mon Sep 17 00:00:00 2001 From: Ezri Brimhall Date: Tue, 7 May 2024 15:55:54 -0600 Subject: [PATCH] Alias cleanup --- .config/zsh/alias.zsh | 142 ++++++++++++++++++++---------------------- 1 file changed, 68 insertions(+), 74 deletions(-) diff --git a/.config/zsh/alias.zsh b/.config/zsh/alias.zsh index 6582d7e..5080219 100644 --- a/.config/zsh/alias.zsh +++ b/.config/zsh/alias.zsh @@ -1,7 +1,6 @@ # Simple shell aliasing alias emacs="TERM=screen-256color emacsclient -t" -alias sumacs="sudo emacs -nw" alias systemctl="sudo systemctl" alias userctl="\systemctl --user" @@ -14,10 +13,7 @@ alias cp="cp -i --reflink=auto" alias mv="mv -i" alias rm="rm -i" -alias screenclip="scrot -o >(xclip -sel clip -t image/png)" - alias virsh="\virsh -c qemu:///system" -alias sandbox-virsh="\virsh -c qemu+ssh://sandbox/system" alias ls='ls --color=tty' alias ll='ls -lh' @@ -32,94 +28,92 @@ alias sign='gpg --sign-with ezri@ezri.dev --detach-sign' alias verify='gpg --verify' function didifuckingstutter { - echo $fg[blue]Apologies, Captain. Right away.$fg[default] - # Run the last command as root - last_cmd=$(fc -ln -1) - # if last command was emacs, use TRAMP rather than running as root - if [[ $last_cmd =~ "^emacs .*" ]]; then - cmd="emacsclient -t /sudo::$(echo $last_cmd | cut -d' ' -f2-)" - echo "> $fg[white]$cmd$fg[default]" - $=cmd - else - cmd="sudo $(fc -ln -1)" - echo "> $fg[white]$cmd$fg[default]" - sudo -p "$fg[red]I'll need your authorization:$fg[default] " $last_cmd - fi + echo $fg[blue]Apologies, right away.$fg[default] + # Run the last command as root + last_cmd=$(fc -ln -1) + # if last command was emacs, use TRAMP rather than running as root + if [[ $last_cmd =~ "^emacs .*" ]]; then + cmd="emacsclient -t /sudo::$(echo $last_cmd | cut -d' ' -f2-)" + echo "> $fg[white]$cmd$fg[default]" + $=cmd + else + cmd="sudo $(fc -ln -1)" + echo "> $fg[white]$cmd$fg[default]" + sudo -p "$fg[red]I'll need your authorization:$fg[default] " $last_cmd + fi } function pygrep { - success=0 - for pid in $(pgrep python); do - if cut -d '' -f2 < /proc/$pid/cmdline | rev | cut -d'/' -f1 | rev | grep "$1.py" &> /dev/null; then - echo $pid - success=1 - fi - done - if ! (( success )); then - return 1 + success=0 + for pid in $(pgrep python); do + if cut -d '' -f2 /dev/null; then + echo $pid + success=1 fi + done + if ! ((success)); then + return 1 + fi } function create-discord-timestamp { - date --date="$(echo $@)" +'' | tee >(tr -d '\n' | cbcopy) + date --date="$(echo $@)" +'' | tee >(tr -d '\n' | cbcopy) } function copy-text { - echo -n $@ | cbcopy + echo -n $@ | cbcopy } function cbcopy { - x_args='-sel clip' - if [[ $1 == '--primary' ]] || [[ $1 == '-p' ]]; then - wl_args='--primary' - x_args='' - fi - if [[ -x $(command -v wl-copy) ]]; then - # Prioritize wayland - wl-copy $wl_args - return $? - fi - if [[ -x $(command -v xclip) ]]; then - # Next do Xorg - xclip $x_args - return $? - fi - if [[ -x $(command -v pbcopy) ]]; then - pbcopy - return $? - fi - echo "No known clipboard commands available" - return 1 + x_args='-sel clip' + if [[ $1 == '--primary' ]] || [[ $1 == '-p' ]]; then + wl_args='--primary' + x_args='' + fi + if [[ -x $(command -v wl-copy) ]]; then + # Prioritize wayland + wl-copy $wl_args + return $? + fi + if [[ -x $(command -v xclip) ]]; then + # Next do Xorg + xclip $x_args + return $? + fi + if [[ -x $(command -v pbcopy) ]]; then + pbcopy + return $? + fi + echo "No known clipboard commands available" + return 1 } function cbpaste { - x_args='-sel clip' - if [[ $1 == '--primary' ]] || [[ $1 == '-p' ]]; then - wl_args='--primary' - x_args='' - fi - if [[ -x $(command -v wl-copy) ]]; then - # Prioritize wayland - wl-paste $wl_args - return $? - fi - if [[ -x $(command -v xclip) ]]; then - # Next do Xorg - xclip -o $x_args - return $? - fi - if [[ -x $(command -v pbcopy) ]]; then - pbpaste - return $? - fi - echo "No known clipboard commands available" > /dev/stderr - return 1 + x_args='-sel clip' + if [[ $1 == '--primary' ]] || [[ $1 == '-p' ]]; then + wl_args='--primary' + x_args='' + fi + if [[ -x $(command -v wl-copy) ]]; then + # Prioritize wayland + wl-paste $wl_args + return $? + fi + if [[ -x $(command -v xclip) ]]; then + # Next do Xorg + xclip -o $x_args + return $? + fi + if [[ -x $(command -v pbcopy) ]]; then + pbpaste + return $? + fi + echo "No known clipboard commands available" >/dev/stderr + return 1 } -alias aggietimed='aggietimed -s /run/user/1000/aggietimed.sock -pos 190910 --action' - function mkcd { - [[ -e $1 ]] || mkdir -p $1 - cd $1 + [[ -e $1 ]] || mkdir -p $1 + cd $1 }