From 891aec3ee62a253dd6b563a169d0c257343ed8c2 Mon Sep 17 00:00:00 2001 From: Wryn Wagner Date: Wed, 4 Nov 2020 12:57:36 -0700 Subject: [PATCH] zsh rc cleanup --- zsh/config | 26 +++++++++++++++ zsh/google | 13 ++++++++ zsh/linux/archfun | 6 ---- zsh/linux/dmenu | 28 +++++++++++++++++ zsh/linux/dmenu_stuff | 17 ---------- zsh/rc | 73 ++++++++++++------------------------------- zsh/utility | 8 ++++- 7 files changed, 94 insertions(+), 77 deletions(-) create mode 100644 zsh/config create mode 100644 zsh/google delete mode 100644 zsh/linux/archfun create mode 100644 zsh/linux/dmenu delete mode 100644 zsh/linux/dmenu_stuff diff --git a/zsh/config b/zsh/config new file mode 100644 index 0000000..f6da0eb --- /dev/null +++ b/zsh/config @@ -0,0 +1,26 @@ +# --- General ZSH Settings ----------------------------------- +HISTFILE=~/.histfile +HISTSIZE=1000 +SAVEHIST=1000 + +setopt appendhistory autocd beep notify +unsetopt nomatch + +bindkey -v + + +# --- Autocompletion Settings -------------------------------- +zmodload -i zsh/complist; +zstyle ':completion:*' completer _complete _ignored _approximate +zstyle ':completion:*' max-errors 4 +zstyle ':completion:*' menu select; +bindkey -M menuselect '^M' .accept-line; # don't require 'return' to select menu item + +zstyle :compinstall filename "$HOME/.zshrc" + +autoload -Uz compinit +compinit + + +# --- Enable completion in kitty-terminal -------------------- +which kitty >/dev/null && kitty + complete setup zsh | source /dev/stdin diff --git a/zsh/google b/zsh/google new file mode 100644 index 0000000..69e1b85 --- /dev/null +++ b/zsh/google @@ -0,0 +1,13 @@ +#!/bin/zsh + +alias gdrive="RCLONE_GOOGLE_DRIVE_MOUNT" + +RCLONE_GOOGLE_DRIVE_MOUNT() { + local RCLONE_REMOTE_NAME='google-drive'; + + clear; + figlet GOOGLE DRIVE CONNECTION | lolcat; + echo -e "\e[3m(C-c to close)\e[0m"; + + rclone mount "$RCLONE_REMOTE_NAME:$1" "$HOME/GoogleDrive" +} diff --git a/zsh/linux/archfun b/zsh/linux/archfun deleted file mode 100644 index 294d2c9..0000000 --- a/zsh/linux/archfun +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/zsh - -# dependency :: feh -alias bgrandomizer="feh --randomize --bg-fill $HOME/.wallpaper/1/* $HOME/.wallpaper/2/* $HOME/.wallpaper/3/*"; -# temp -alias bgrandomizer="feh --randomize --bg-fill $HOME/.wallpaper/* $HOME/.wallpaper/* $HOME/.wallpaper/*"; diff --git a/zsh/linux/dmenu b/zsh/linux/dmenu new file mode 100644 index 0000000..f75bd57 --- /dev/null +++ b/zsh/linux/dmenu @@ -0,0 +1,28 @@ +#!/bin/zsh + +function DMENU__NEW_COMMAND() { + local BIN="$HOME/.local/custom_dmenu"; + local HELP_STRING='\ncorrect syntax:\nDMENU__NEW_COMMAND [ name or "test" ] [ command .. args ]\n'; + + [[ "$1" == help ]] && { + echo $HELP_STRING; + return 0; + } + + [ ! -d $BIN ] && mkdir $BIN; + + # fail if no command is provided + [ ! $2 ] && return 1; + + [[ "$1" != "test" ]] && { + echo "${@:2}" > "$BIN/$1" 2>/dev/null \ + && chmod +x "$BIN/$1" \ + && echo "Command '$1' saved! ('${@:2}')" \ + || { echo "Something went wrong :c \n"; echo "$HELP_STRING"; } + } || { + echo; + echo -e "saved to : \e[32m$BIN/$1\e[0m"; + echo -e "executes : \e[31m${@:2}\e[0m"; + echo; + } +} diff --git a/zsh/linux/dmenu_stuff b/zsh/linux/dmenu_stuff deleted file mode 100644 index 7ae6cf2..0000000 --- a/zsh/linux/dmenu_stuff +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/zsh - -# Make a new dmenu shortcut -DMENU_CUSTOM_BIN="$HOME/.local/custom_dmenu"; - -[ ! -d $DMENU_CUSTOM_BIN ] && mkdir $DMENU_CUSTOM_BIN; - -function new_dmenu_command() { - local DMENU_BIN="$HOME/.local/custom_dmenu"; - - # fail withouut both arguments - [ ! $2 ] && return 1; - - echo "${@:2}" - echo "${@:2}" > $DMENU_BIN/$1 2>/dev/null - chmod +x $DMENU_BIN/$1 -} diff --git a/zsh/rc b/zsh/rc index fcdb9af..100e99e 100644 --- a/zsh/rc +++ b/zsh/rc @@ -1,67 +1,34 @@ #!/bin/zsh -# -# - -# The following lines were added by compinstall -zstyle ':completion:*' completer _complete _ignored _approximate -zstyle ':completion:*' max-errors 4 -zstyle :compinstall filename '/home/w0ryn/.zshrc' - -autoload -Uz compinit -compinit -# End of lines added by compinstall - -# Lines configured by zsh-newuser-install -HISTFILE=~/.histfile -HISTSIZE=1000 -SAVEHIST=1000 -setopt appendhistory autocd beep notify -unsetopt nomatch -bindkey -v -# End of lines configured by zsh-newuser-install - - -zmodload -i zsh/complist; -bindkey -M menuselect '^M' .accept-line; - -# Completion for Kitty -which kitty >/dev/null && kitty + complete setup zsh | source /dev/stdin - -# -# source "$HOME/.wryn/env/env.zsh" RC_DIR="$DOTWRYN/zsh" -# source .wryn/zsh files +# zsh plugins for file in $(find $RC_DIR -maxdepth 1 -type f ! -name 'rc'); do source $file; done; -# osx -if [[ "$OSTYPE" == "darwin"* ]]; then - for file in $(find $RC_DIR/osx -type f); do source $file; done; -fi - -# linux +# linux-specific plugins if [[ "$OSTYPE" == "linux-gnu" ]]; then for file in $(find $RC_DIR/linux -type f); do source $file; done; fi -# --- ViM as default editor ----------------------------------- -export EDITOR='vim' -export VISUAL='vim' +# osx-specific plugins +if [[ "$OSTYPE" == "darwin"* ]]; then + for file in $(find $RC_DIR/osx -type f); do source $file; done; +fi -# --- Welcome message ----------------------------------------- + +# --- vi / vim as default editor (vim preferred) ------------------- +which vi >/dev/null 2>&1 && { + export EDITOR='vi'; + export VISUAL='vi'; +} + +which vim >/dev/null 2>&1 && { + export EDITOR='vim'; + export VISUAL='vim'; +} + + +# --- welcome message ---------------------------------------------- exec figlet "Welcome, beautiful" | lolcat; echo; cowsay -p "damn u sexy" | lolcat; - -alias restart='clear; source ~/.zshrc; echo' - -# --- !@#$ Aliases -------------------------------------------- -alias clera='clear'; -alias sl='sl -alF | lolcat'; - -# --- ZSH Completion Styles ----------------------------------- -zmodload -i zsh/complist; - -zstyle ':completion:*' menu select; -bindkey -M menuselect '^M' .accept-line; # don't require 'return' to select menu item diff --git a/zsh/utility b/zsh/utility index 243b538..c6972c5 100644 --- a/zsh/utility +++ b/zsh/utility @@ -1,6 +1,8 @@ #!/bin/zsh # --- Basic Alias --------------------------------------------- +alias restart='clear; source ~/.zshrc; echo' + alias pd='pushd'; alias qd='popd'; alias lspd='dirs'; @@ -11,6 +13,10 @@ alias cdo='cd $(xclip -o)'; # [cd] to directory [o]n clipboard alias color_demo='msgcat --color=test' +# --- !@#$ Aliases -------------------------------------------- +alias sl='sl -alF | lolcat'; + + # --- GIT ----------------------------------------------------- alias gitbranchcleanup='git branch -d $(git branch | sed -E "/develop|master|\*/d")' alias fix='vim $(git diff --name-only | uniq) -p'; @@ -30,7 +36,7 @@ OPEN_CURRENT_GIT_REPOSITORY_IN_WEB_BROWSER() { # --- Miscellaneous ------------------------------------------- -alias rgv='EDIT_RIP_GREP_FILE_MATCHES'; +alias erg='EDIT_RIP_GREP_FILE_MATCHES'; EDIT_RIP_GREP_FILE_MATCHES() { [ $EDITOR = "vim" ] \ && $EDITOR -p $(rg -l $1) \