summaryrefslogtreecommitdiff
path: root/zsh
diff options
context:
space:
mode:
Diffstat (limited to 'zsh')
-rw-r--r--zsh/profile/zprofile.voidx2502
-rw-r--r--zsh/zprofile24
-rwxr-xr-xzsh/zscripts/aliasrc.zsh8
-rwxr-xr-xzsh/zscripts/hosts/aliasrc.voidx250.zsh2
-rwxr-xr-xzsh/zscripts/hosts/colors.voidx250.zsh2
-rwxr-xr-xzsh/zscripts/keybindrc.zsh14
-rwxr-xr-xzsh/zscripts/zplug.zsh83
-rwxr-xr-xzsh/zshrc23
8 files changed, 92 insertions, 66 deletions
diff --git a/zsh/profile/zprofile.voidx250 b/zsh/profile/zprofile.voidx250
index 1012463..4b00faa 100644
--- a/zsh/profile/zprofile.voidx250
+++ b/zsh/profile/zprofile.voidx250
@@ -1,5 +1,5 @@
#!/usr/bin/env zsh
-export XDG_DATA_DIRS="/var/lib/flatpak/exports/share:$XDG_DATA_DIRS"
+export XDG_DATA_DIRS="/var/lib/flatpak/exports/share:$XDG_DATA_DIRS" # .desktop files
source /home/timmy/.config/zsh/zprofile
diff --git a/zsh/zprofile b/zsh/zprofile
index b37c4ac..618514d 100644
--- a/zsh/zprofile
+++ b/zsh/zprofile
@@ -1,33 +1,37 @@
#!/usr/bin/env zsh
-# Default programs:
+# Default programs
export EDITOR='nvim'
export TERMINAL='st'
export BROWSER='launch firefox'
+export SUDO='doas'
-# Clean up home directory
+# Use sudo=${SUDO-sudo}
+[ $EUID = 0 ] && export SUDO='' # When running as root, don't use sudo
+
+# Make programs follow the XDG base directory specification
export XDG_CACHE_HOME="$HOME/.cache"
export XAUTHORITY="$XDG_CACHE_HOME/Xauthority"
export XDG_CONFIG_HOME="$HOME/.config"
export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc"
-export INPUTRC="$XDG_CONFIG_HOME/zsh/inputrc"
export MBSYNCRC="$XDG_CONFIG_HOME/mbsync/config"
-export NOTMUCH_COFIG="$XDG_CONFIG_HOME/notmuch/config"
-export XINITRC="$XDG_CONFIG_HOME/x11/xinitrc" # User env
+export NOTMUCH_CONFIG="$XDG_CONFIG_HOME/notmuch/config"
+export X11CONFIG="$XDG_CONFIG_HOME/x11" # Used for X11 scripts
export ZDOTDIR="$XDG_CONFIG_HOME/zsh"
export XDG_DATA_HOME="$HOME/.local/share"
export CARGO_HOME="$XDG_DATA_HOME/cargo"
export GNUPGHOME="$XDG_DATA_HOME/gnupg"
export PASSWORD_STORE_DIR="$XDG_DATA_HOME/password-store"
-export ZDATADIR="$XDG_DATA_HOME/zsh" # User env
export _JAVA_OPTIONS="-Djava.util.prefs.userRoot=$XDG_DATA_HOME/java"
-export LESSHISTFILE='-'
+export XDG_STATE_HOME="$HOME/.local/state"
+ HISTFILE="$XDG_STATE_HOME/zsh/zhistory" # Zsh internal variable, doesn't need to be available to general environment
+export LESSHISTFILE='-' # Disable this, but it would be considered a state file
# Path
-for lbin in "$HOME/.local/bin"{/,/*/}; do export PATH="${lbin%/}:$PATH"; done # Add ~/.local/bin and all sub dirs
+for lbin in "$HOME/.local/bin"{/,/*/}; do export PATH="${lbin%/}:$PATH"; done 2>/dev/null # Add ~/.local/bin and all sub dirs
export PATH="$HOME/.local/opt:$PATH"
export PATH="$CARGO_HOME/bin:$PATH"
@@ -35,7 +39,7 @@ export PATH="$CARGO_HOME/bin:$PATH"
export QT_QPA_PLATFORMTHEME='qt5ct'
# Misc Zsh setup
-mkdir -p "$ZDATADIR"
+mkdir -p "$HISTFILE"
# Autostart X after login
-[ -z $DISPLAY ] && [[ $EUID != 0 ]] && [[ $TTY =~ /dev/tty(1|C0) ]] && startx $XINITRC
+[ -z $DISPLAY ] && [[ $UID != 0 ]] && [[ $TTY =~ /dev/tty(1|C0) ]] && startx "$X11CONFIG/xinitrc"
diff --git a/zsh/zscripts/aliasrc.zsh b/zsh/zscripts/aliasrc.zsh
index e008cc8..411a84d 100755
--- a/zsh/zscripts/aliasrc.zsh
+++ b/zsh/zscripts/aliasrc.zsh
@@ -4,7 +4,7 @@
alias \
htop="htim" \
mutt="neomutt" \
- sudo="doas" \
+ sudo="${SUDO-sudo}" \
# Shorten program names
alias \
@@ -58,7 +58,7 @@ alias \
# 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" \
+ startdwm="startx $X11CONFIG/xinitrc dwm" \
+ startpfwm="startx $X11CONFIG/xinitrc picframewm" \
+ startx="startx $X11CONFIG/xinitrc" \
diff --git a/zsh/zscripts/hosts/aliasrc.voidx250.zsh b/zsh/zscripts/hosts/aliasrc.voidx250.zsh
index 4681ace..4bb85ea 100755
--- a/zsh/zscripts/hosts/aliasrc.voidx250.zsh
+++ b/zsh/zscripts/hosts/aliasrc.voidx250.zsh
@@ -1,6 +1,6 @@
#!/bin/sh
-# Replacement programs
+# Package Management
alias \
xi="sudo xbps-install" \
xq="xbps-query -R --search" \
diff --git a/zsh/zscripts/hosts/colors.voidx250.zsh b/zsh/zscripts/hosts/colors.voidx250.zsh
index cf710f3..910f1f9 100755
--- a/zsh/zscripts/hosts/colors.voidx250.zsh
+++ b/zsh/zscripts/hosts/colors.voidx250.zsh
@@ -1,3 +1,5 @@
+#!/usr/bin/env zsh
+
if [ -n "$DISPLAY" ]; then
declare col{br,at}=green
declare col{name,host}=76
diff --git a/zsh/zscripts/keybindrc.zsh b/zsh/zscripts/keybindrc.zsh
index 1f0e93a..67dfcd5 100755
--- a/zsh/zscripts/keybindrc.zsh
+++ b/zsh/zscripts/keybindrc.zsh
@@ -1,8 +1,8 @@
#!/usr/bin/env zsh
# Vi mode + requirements for ALL keybindings to work correctly
-bindkey -v
-export KEYTIMEOUT=1
+bindkey -v # Select viins keymap
+KEYTIMEOUT=1
# Keybindings
autoload edit-command-line; zle -N edit-command-line # Edit line in Vim buffer
@@ -19,10 +19,10 @@ bindkey '^[[M' delete-word # Ctrl-Delete - delete currect word in front of the
bindkey '\e[A' history-search-backward # Up arrow - seach history backwards
bindkey '\e[B' history-search-forward # Down arrow - seach history forwards
# Ctrl-vi keys emulate arrow keys
-bindkey '^H' emacs-backward-word # Ctrl-L - go back one word
-bindkey '^J' history-search-forward # Ctrl-J - seach history backwards
-bindkey '^K' history-search-backward # Ctrl-K - seach history forwards
-bindkey '^L' emacs-forward-word # Ctrl-H - go forward one word
+#bindkey '^H' emacs-backward-word # Ctrl-L - go back one word
+#bindkey '^J' history-search-forward # Ctrl-J - seach history backwards
+#bindkey '^K' history-search-backward # Ctrl-K - seach history forwards
+#bindkey '^L' emacs-forward-word # Ctrl-H - go forward one word
# Basic auto/tab complete
autoload -U compinit
@@ -39,4 +39,4 @@ bindkey -M menuselect '^j' vi-down-line-or-history
bindkey -v '^?' backward-delete-char
# Ignore ctrl-d to exit shell
-setopt ignore_eof
+setopt IGNORE_EOF
diff --git a/zsh/zscripts/zplug.zsh b/zsh/zscripts/zplug.zsh
index e1fa3c6..6b86104 100755
--- a/zsh/zscripts/zplug.zsh
+++ b/zsh/zscripts/zplug.zsh
@@ -1,28 +1,28 @@
#!/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
+local zplugs="${ZDOTDIR:-~/.}${ZDOTDIR:+/}zplugs" # Declare videos using `local` to keep variables away from interactive shell
+local zplugins="${ZPLUGINSDIR:-/usr/local/share/zsh/zplugins}"
+[[ $EUID != 0 ]] && local sudo=${SUDO-sudo}
function __zplugInstall() {
touch "$zplugs"
- local pluglist=( `cat "$zplugs"` )
+ local pluglist=( `grep -v '#' "$zplugs"` )
+ local confirm plug
shift
- for plug in "$@"; do
- pluglist[$((${#pluglist[@]}+1))]=$plug
- done
+ for plug in "$@"; do; pluglist+=(${plug}); done
- mkdir -p "$zplugins"
+ $sudo 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=""
+ if ! `$sudo git -C "$zplugins" clone "$plug" "$(basename -s'.git' "$plug")"`; then
+ # Runs if git has an error
+ printf "Remove \"$plug\"? [y|n]: "
+ read confirm
+ case $confirm in
+ y|yes) pluglist=(${pluglist#$plug}) && echo "Repo Deleted" ;;
+ *) echo "Repo Kept" ;;
+ esac
fi
echo
done
@@ -31,18 +31,22 @@ function __zplugInstall() {
}
function __zplugUninstall() {
- mkdir -p "$zplugins"
- local pluglist=( `cat "$zplugs"` )
+ local pluglist=( `cat "$zplugs"` ) pluglistbn=()
+ local confirm i plug plugids plugig
+
[ -z "$pluglist" ] && echo "No packages are installed!" && return
+
+ $sudo mkdir -p "$zplugins"
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
+ printf "Choose zsh plugin(s) to remove: "
+ read plugids
+ [ -z "$plugids" ] && echo "No plugins selected\nAborting" && return
echo "\nListing selected plugins:"
for plugid in $=plugids; do
@@ -50,20 +54,19 @@ function __zplugUninstall() {
echo "Error: input \"$plugid\" is not a valid plugin identifier"
return
fi
- printf " "
- echo "${pluglistbn[$plugid]}"
+ echo "\t${pluglistbn[$plugid]}"
done
- echo
- vared -p "Really remove all of these plugins? [y|n]: " -c confirm
+ printf "\nReally remove all of these plugins? [y|n]: "
+ read 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]}"
+ printf '\t'
+ $sudo rm -vrf "$zplugins/${pluglistbn[$plugid]}"
pluglist[$plugid]=""
done
for plug in ${pluglist[@]}; do echo "$plug"; done | sort -u > "$zplugs"
@@ -71,11 +74,12 @@ function __zplugUninstall() {
}
function __zplugUpgrade() {
- mkdir -p "$zplugins"
+ local plugdir
+ $sudo mkdir -p "$zplugins"
echo "Upgrading all packages...\n"
for plugdir in "$zplugins"/*; do;
basename "$plugdir"
- git -C "$plugdir" pull;
+ $sudo git -C "$plugdir" pull;
echo
done
echo "Done"
@@ -90,13 +94,23 @@ function __zplugList() {
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
+ install, add, i [packages] : Install plugins from config file & add any new plugins
+ uninstall, remove, r : Interactively remove plugins
+ upgrade, update, u : Update all installed plugins
+ list, l : List all installed plugins
+ help, h : Show this help menu
+
+ All plugins are listed in $zplugs
+ All plugins are installed in $zplugins
+
+ To install a plugin, just put it in the zplug file and run \"zplug install\"
+ or just run \"zplug install [plugin]\" where [plugin] is a link to download the
+ plugin using git
+
+ For instance, \"https://github.com/zdharma-continuum/fast-syntax-highlighting\" is
+ a valid plugin link for the fast-syntax-highlighting plugin.
- To use zplug, just put \"zplugInitialize\" as the last line of your zshrc!"
+ To use your plugins, just put \"zplugInitialize\" as the last line of your zshrc!"
}
function zplug() {
@@ -112,5 +126,6 @@ function zplug() {
}
function zplugInitialize() {
- for plugin in "$zplugins"/*/*.zsh; do source "$plugin"; done
+ local plugin
+ for plugin in "$zplugins"/*/*.zsh; do source "$plugin"; done 2>/dev/null
}
diff --git a/zsh/zshrc b/zsh/zshrc
index 1cf9e59..bef8f9c 100755
--- a/zsh/zshrc
+++ b/zsh/zshrc
@@ -1,26 +1,31 @@
#!/usr/bin/env zsh
# Zsh scripts
-unsetopt nomatch # Disable error message when no files can be found
-for zscript in "$XDG_CONFIG_HOME/zsh/zscripts"{/[^\!]*.zsh,/hosts/*.$HOST.zsh,/!*.zsh}; do source "$zscript"; done
+for zscript in "$XDG_CONFIG_HOME/zsh/zscripts"{/[^\!]*.zsh,/hosts/*.$HOST.zsh,/!*.zsh}; do source "$zscript"; done 2>/dev/null
# Colors! + Prompt
autoload -U colors && colors
PS1="%B%F{${colbr:-red}}[%F{${colname:-yellow}}%n%F{${colat:-green}}@%F{${colhost:-blue}}%m %F{${coldir:-magenta}}%U%~%u%F{${colbr:-red}}]%f%b%(!.#.$) "
+# Cd settings
+setopt AUTO_CD # `cd` is implied
+#setopt CDABLE_VARS # '~/' is implied for `cd` (doesn't work?)
+
# History settings
-HISTFILE="$ZDATADIR/zhistory"
HISTSIZE=500 # Max lines of history loaded into memory
SAVEHIST=10000000 # Max lines of history saved to the histfile
-setopt INC_APPEND_HISTORY # Create entries after each command, not after zsh exits
-setopt SHARE_HISTORY # Share history between zsh sessions
-setopt HIST_REDUCE_BLANKS
+setopt EXTENDED_HISTORY # Save superfluous info with command to reduce disk writes
setopt HIST_IGNORE_DUPS # Successive duplicate entries ignored
setopt HIST_IGNORE_SPACE # Entries with leading space ignored
-setopt EXTENDED_HISTORY # Save superfluous info with command to reduce disk writes
+setopt HIST_REDUCE_BLANKS
+setopt INC_APPEND_HISTORY # Create entries after each command, not after zsh exits
+setopt SHARE_HISTORY # Share history between zsh sessions
+
+# Zsh completion settings
+setopt MENU_COMPLETE # Insert first option immediately in completion menu instead of just showing menu
-# Other settings
-setopt autocd # 'cd' is implied
+# Input/output settings
+setopt INTERACTIVE_COMMENTS # Comments work as expected in interactive shell
# tmp thing
[ $TTY = /dev/tty2 ] && "/home/timmy/.local/opt/shell-color-scripts/colorscripts/$(ls /home/timmy/.local/opt/shell-color-scripts/colorscripts 2>/dev/null | shuf -n1)" 2>/dev/null