From 66bff0b5ef46550866c959bb745a61363dc5331f Mon Sep 17 00:00:00 2001 From: Timmy Keller Date: Thu, 16 Jun 2022 15:19:16 -0500 Subject: zplug commit --- zsh/zscripts/!rootcolors.zsh | 2 +- zsh/zscripts/.lfub.zsh | 27 ++++++++ zsh/zscripts/aliasrc.zsh | 4 ++ zsh/zscripts/colors.voidx250.zsh | 7 -- zsh/zscripts/hosts/colors.voidx250.zsh | 7 ++ zsh/zscripts/keybindrc.zsh | 3 - zsh/zscripts/lfub.zsh | 27 -------- zsh/zscripts/zplug.zsh | 116 +++++++++++++++++++++++++++++++++ 8 files changed, 155 insertions(+), 38 deletions(-) create mode 100755 zsh/zscripts/.lfub.zsh delete mode 100755 zsh/zscripts/colors.voidx250.zsh create mode 100755 zsh/zscripts/hosts/colors.voidx250.zsh delete mode 100755 zsh/zscripts/lfub.zsh create mode 100755 zsh/zscripts/zplug.zsh (limited to 'zsh/zscripts') diff --git a/zsh/zscripts/!rootcolors.zsh b/zsh/zscripts/!rootcolors.zsh index 6ad30a7..d146aa5 100755 --- a/zsh/zscripts/!rootcolors.zsh +++ b/zsh/zscripts/!rootcolors.zsh @@ -1,3 +1,3 @@ #!/usr/bin/env zsh -[ $(id -u) = 0 ] && declare col{br,name,at,host,dir}=red && clear # Clear to get rid of last login message +[ $EUID = 0 ] && declare col{br,name,at,host,dir}=red && clear # Clear to get rid of last login message diff --git a/zsh/zscripts/.lfub.zsh b/zsh/zscripts/.lfub.zsh new file mode 100755 index 0000000..83b00c1 --- /dev/null +++ b/zsh/zscripts/.lfub.zsh @@ -0,0 +1,27 @@ +#!/bin/sh +# This is a wrapper script for lb that allows it to create image previews with +# ueberzug. This works in concert with the lf configuration file and the +# lf-cleaner script. + +cleanuplf() { + exec 3>&- + \rm "$FIFO_UEBERZUG" +} + +lfub() { + dircache=/tmp/$USER-lflastdir + lfopt="--last-dir-path=$dircache" + if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then + lf "$lfopt" "$@" + else + export FIFO_UEBERZUG="/tmp/ueberzug-$$" + mkfifo "$FIFO_UEBERZUG" + ueberzug layer -s <"$FIFO_UEBERZUG" -p json & + exec 3>"$FIFO_UEBERZUG" + trap cleanuplf HUP INT QUIT TERM PWR EXIT + lf "$lfopt" "$@" 3>&- + fi + [ -f "$dircache" ] && dir="$(cat "$dircache")" && [ -d "$dir" ] && cd "$dir" +} + +alias lf="lfub" diff --git a/zsh/zscripts/aliasrc.zsh b/zsh/zscripts/aliasrc.zsh index cd77a71..e008cc8 100755 --- a/zsh/zscripts/aliasrc.zsh +++ b/zsh/zscripts/aliasrc.zsh @@ -22,6 +22,7 @@ alias \ vrc="nvim ~/.config/nvim/init.vim" \ xrc="cd ~/.config/x11" \ zrc="cd ~/.config/zsh" \ + zhist="vim ~/.local/share/zsh/zhistory" \ # Power scripts alias \ @@ -51,10 +52,13 @@ alias \ # Miscellaneous alias \ + yt-dlp-album="yt-dlp -x -o '%(uploader)s (%(upload_date>%Y)s) - %(playlist_title)s%%%(playlist_index)s - %(title)s.%(ext)s'" \ yt-dlp="yt-dlp -o '%(uploader)s - %(title)s.%(ext)s'" \ # Clean home directory alias \ + mbsync="mbsync --config $MBSYNCRC" \ startdwm="startx $XDG_CONFIG_HOME/x11/xinitdwmrc" \ + startpfwm="startx $XDG_CONFIG_HOME/x11/xinitpicframewmrc" \ startx="startx $XINITRC" \ diff --git a/zsh/zscripts/colors.voidx250.zsh b/zsh/zscripts/colors.voidx250.zsh deleted file mode 100755 index cf710f3..0000000 --- a/zsh/zscripts/colors.voidx250.zsh +++ /dev/null @@ -1,7 +0,0 @@ -if [ -n "$DISPLAY" ]; then - declare col{br,at}=green - declare col{name,host}=76 - coldir=40 -else - declare col{br,name,at,host,dir}=green -fi diff --git a/zsh/zscripts/hosts/colors.voidx250.zsh b/zsh/zscripts/hosts/colors.voidx250.zsh new file mode 100755 index 0000000..cf710f3 --- /dev/null +++ b/zsh/zscripts/hosts/colors.voidx250.zsh @@ -0,0 +1,7 @@ +if [ -n "$DISPLAY" ]; then + declare col{br,at}=green + declare col{name,host}=76 + coldir=40 +else + declare col{br,name,at,host,dir}=green +fi diff --git a/zsh/zscripts/keybindrc.zsh b/zsh/zscripts/keybindrc.zsh index 29913ae..1f0e93a 100755 --- a/zsh/zscripts/keybindrc.zsh +++ b/zsh/zscripts/keybindrc.zsh @@ -4,9 +4,6 @@ bindkey -v export KEYTIMEOUT=1 -# Unbind some default keybindings -#bindkey -r "^U" "^W" "^G" "^J" "^Q" "^R" "^[[200~" - # Keybindings autoload edit-command-line; zle -N edit-command-line # Edit line in Vim buffer bindkey '^E' edit-command-line # Ctrl-e - edit line in Vim buffer diff --git a/zsh/zscripts/lfub.zsh b/zsh/zscripts/lfub.zsh deleted file mode 100755 index 83b00c1..0000000 --- a/zsh/zscripts/lfub.zsh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# This is a wrapper script for lb that allows it to create image previews with -# ueberzug. This works in concert with the lf configuration file and the -# lf-cleaner script. - -cleanuplf() { - exec 3>&- - \rm "$FIFO_UEBERZUG" -} - -lfub() { - dircache=/tmp/$USER-lflastdir - lfopt="--last-dir-path=$dircache" - if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then - lf "$lfopt" "$@" - else - export FIFO_UEBERZUG="/tmp/ueberzug-$$" - mkfifo "$FIFO_UEBERZUG" - ueberzug layer -s <"$FIFO_UEBERZUG" -p json & - exec 3>"$FIFO_UEBERZUG" - trap cleanuplf HUP INT QUIT TERM PWR EXIT - lf "$lfopt" "$@" 3>&- - fi - [ -f "$dircache" ] && dir="$(cat "$dircache")" && [ -d "$dir" ] && cd "$dir" -} - -alias lf="lfub" diff --git a/zsh/zscripts/zplug.zsh b/zsh/zscripts/zplug.zsh new file mode 100755 index 0000000..e1fa3c6 --- /dev/null +++ b/zsh/zscripts/zplug.zsh @@ -0,0 +1,116 @@ +#!/usr/bin/env zsh + +local zplugs="${ZDOTDIR:-~/.}${ZDOTDIR+/}zplugs" +local zplugins="${ZDATADIR:-.local/share/zsh}/zplugins" + +unsetopt nomatch # Disable error message when no file can be found + +function __zplugInstall() { + touch "$zplugs" + local pluglist=( `cat "$zplugs"` ) + shift + for plug in "$@"; do + pluglist[$((${#pluglist[@]}+1))]=$plug + done + + mkdir -p "$zplugins" + + for plug in ${pluglist[@]}; do + [ -d "$zplugins/$(basename -s'.git' "$plug")" ] && continue + if ! `git -C "$zplugins" clone "$plug" "$(basename -s'.git' "$plug")"`; then + vared -p "Remove \"$plug\"? [y|n]: " -c confirm + [ "$confirm" =~ (y|yes) ] && pluglist=(${pluglist#$plug}) \ + && echo "Repo Deleted" \ + || echo "Repo Kept" + confirm="" + fi + echo + done + for plug in ${pluglist[@]}; do echo "$plug"; done | sort -u > "$zplugs" + echo "All plugins installed and saved to $zplugs!\nDone" +} + +function __zplugUninstall() { + mkdir -p "$zplugins" + local pluglist=( `cat "$zplugs"` ) + [ -z "$pluglist" ] && echo "No packages are installed!" && return + echo "Listing all packages in $zplugins ..." + local pluglistbn=() + for i in {1..${#pluglist[@]}}; do + pluglistbn[$i]="$(basename -s'.git' "${pluglist[$i]}")" + printf '%3d) %s\n' $i "${pluglistbn[$i]}" + done + + echo + vared -p "Choose zsh plugin(s) to remove: " -c plugids + + echo "\nListing selected plugins:" + for plugid in $=plugids; do + if [ -z ${pluglist[$plugid]} ]; then + echo "Error: input \"$plugid\" is not a valid plugin identifier" + return + fi + printf " " + echo "${pluglistbn[$plugid]}" + done + + echo + vared -p "Really remove all of these plugins? [y|n]: " -c confirm + case $confirm in + y|yes) ;; + n|no) echo "Aborted" && return ;; + *) echo "Input not understood\nAborted" && return ;; + esac + for plugid in $=plugids; do + printf " " + rm -vrf "$zplugins/${pluglistbn[$plugid]}" + pluglist[$plugid]="" + done + for plug in ${pluglist[@]}; do echo "$plug"; done | sort -u > "$zplugs" + echo "\nDone" +} + +function __zplugUpgrade() { + mkdir -p "$zplugins" + echo "Upgrading all packages...\n" + for plugdir in "$zplugins"/*; do; + basename "$plugdir" + git -C "$plugdir" pull; + echo + done + echo "Done" +} + +function __zplugList() { + mkdir -p "$zplugins" + echo "Listing all packages...\n" + ls "$zplugins" | nl -s') ' -w3 + echo "\nDone" +} + +function __zplugHelp() { + echo "Usage: zplug [install/add/i|uninstall/remove/r|upgrade/update/u|list/l|help/h] + zplug install, add, i [packages] : Add any packages listed to $zplugs file and install all plugins + zplug uninstall, remove, r : Interactively remove packages. Removes package from config file as well + zplug upgrade, update, u : Update all installed packages + zplug list, l : List all installed packages + zplug help, h : Show this help menu + + To use zplug, just put \"zplugInitialize\" as the last line of your zshrc!" +} + +function zplug() { + local cmd=${1:-h} + case $cmd in + install|add|i) __zplugInstall $@ ;; + uninstall|remove|r) __zplugUninstall ;; + upgrade|update|u) __zplugUpgrade ;; + list|l) __zplugList ;; + help|h) __zplugHelp ;; + *) echo "zplug: input \"$1\" not recognized!" && __zplugHelp ;; + esac +} + +function zplugInitialize() { + for plugin in "$zplugins"/*/*.zsh; do source "$plugin"; done +} -- cgit v1.2.3