diff --git a/.github/workflows/automated_tests.yml b/.github/workflows/automated_tests.yml index 71b16af..3a108d7 100644 --- a/.github/workflows/automated_tests.yml +++ b/.github/workflows/automated_tests.yml @@ -93,7 +93,7 @@ jobs: # ls -al # Confirm files exist - for file in .zshrc .bashrc .gitconfig .shell .ssh/config .shell/050-linux.sh; do + for file in .zshrc .bashrc .gitconfig .shell .ssh/config .shell/sourced/080-linux.sh; do if [ ! -e $file ]; then echo "$file not found" exit 1 @@ -101,7 +101,7 @@ jobs: done # Confirm files don't exist - for file in Library .shell/050-macos.sh; do + for file in Library .shell/sourced/080-macos.sh; do if [ -e $file ]; then echo "$file found" exit 1 @@ -118,7 +118,7 @@ jobs: cd /Users/runner # Confirm files exist - for file in .zshrc .bashrc .gitconfig .shell .ssh/config Library .shell/050-macos.sh; do + for file in .zshrc .bashrc .gitconfig .shell .ssh/config Library .shell/sourced/080-macos.sh; do if [ ! -e $file ]; then echo "$file not found" exit 1 @@ -126,7 +126,7 @@ jobs: done # Confirm files don't exist - for file in .shell/050-linux.sh; do + for file in .shell/sourced/080-linux.sh; do if [ -e $file ]; then echo "$file found" exit 1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 93c5fea..483c47f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -61,4 +61,4 @@ repos: entry: shellcheck language: system types: [shell] - exclude: '.*\.bats|dotfiles/shell|dotfiles/\.zshrc' + exclude: "dotfiles/dot_zshrc|.*\\.zsh$" diff --git a/dotfiles/.chezmoiremove b/dotfiles/.chezmoiremove new file mode 100644 index 0000000..696e354 --- /dev/null +++ b/dotfiles/.chezmoiremove @@ -0,0 +1,4 @@ +.DS_Store +.zsh/plugins/zsh-github-cli +.zsh/plugins/up.zsh +.local/scripts diff --git a/dotfiles/dot_bashrc.tmpl b/dotfiles/dot_bashrc.tmpl index 5a664f1..06af1e3 100644 --- a/dotfiles/dot_bashrc.tmpl +++ b/dotfiles/dot_bashrc.tmpl @@ -30,7 +30,7 @@ done # Locations containing files *.bash to be sourced to your environment configFileLocations=( - "${HOME}/.shell" + "${HOME}/.shell/sourced" ) for configFileLocation in "${configFileLocations[@]}"; do diff --git a/dotfiles/dot_local/scripts/executable_debian-startup.sh.tmpl b/dotfiles/dot_local/scripts/executable_debian-startup.sh.tmpl deleted file mode 100644 index 19cbc29..0000000 --- a/dotfiles/dot_local/scripts/executable_debian-startup.sh.tmpl +++ /dev/null @@ -1,99 +0,0 @@ -{{- if eq .chezmoi.os "linux" -}} -#!/usr/bin/env bash - -# A script that would run with terminal startup on debian machines -# Displays resource usage, etc. -# -# apt install figlet lolcat -# chmod +x deb-startup -# mv dev-startup /etc/update-motd.d/50-sysinfo -# truncate -s 0 /etc/motd && rm /etc/update-motd.d/10-uname - -### Hostname -########################################################### -if [ -x "$(command -v figlet)" ]; then - if [ -x "$(command -v lolcat)" ]; then - figlet "$(hostname)" | lolcat -f - else - figlet "$(hostname)" - fi -else - echo "$(hostname)" -fi - -### System info -########################################################### -IFS=" " read -r LOAD1 LOAD5 LOAD15 <<<"$(cat /proc/loadavg | awk '{ print $1,$2,$3 }')" -# get free memory -IFS=" " read -r USED AVAIL TOTAL <<<"$(free -htm | grep "Mem" | awk {'print $3,$7,$2'})" -# get processes -PROCESS=$(ps -eo user= | sort | uniq -c | awk '{ print $2 " " $1 }') -PROCESS_ALL=$(echo "$PROCESS" | awk {'print $2'} | awk '{ SUM += $1} END { print SUM }') -PROCESS_ROOT=$(echo "$PROCESS" | grep root | awk {'print $2'}) -PROCESS_USER=$(echo "$PROCESS" | grep -v root | awk {'print $2'} | awk '{ SUM += $1} END { print SUM }') -# get processors -PROCESSOR_NAME=$(grep "model name" /proc/cpuinfo | cut -d ' ' -f3- | awk {'print $0'} | head -1) -PROCESSOR_COUNT=$(grep -ioP 'processor\t:' /proc/cpuinfo | wc -l) - -W="\e[0;39m" -G="\e[1;32m" - -temp="" -if [ -x "$(command -v landscape-sysinfo)" ]; then - temp=$(landscape-sysinfo --sysinfo-plugins Temperature | sed 's/ *$//g' | sed 's/Temperature: //g') -fi - -echo -e " -${W}system info: -$W Distro : $W$(cat /etc/*release | grep "PRETTY_NAME" | cut -d "=" -f 2- | sed 's/"//g') -$W Kernel : $W$(uname -sr) -$W Uptime : $W$(uptime -p) -$W Load : $G$LOAD1$W (1m), $G$LOAD5$W (5m), $G$LOAD15$W (15m) -$W Processes :$W $G$PROCESS_ROOT$W (root), $G$PROCESS_USER$W (user), $G$PROCESS_ALL$W (total) -$W CPU : $W$PROCESSOR_NAME ($G$PROCESSOR_COUNT$W vCPU) -$W Memory : $G$USED$W used, $G$AVAIL$W avail, $G$TOTAL$W total$W" - -### Disk -########################################################### - -# config -max_usage=90 -bar_width=50 -# colors -white="\e[39m" -green="\e[1;32m" -red="\e[1;31m" -dim="\e[2m" -undim="\e[0m" - -# disk usage: ignore zfs, squashfs & tmpfs -mapfile -t dfs < <(df -H -x zfs -x squashfs -x tmpfs -x devtmpfs -x overlay --output=target,pcent,size | tail -n+2) -printf "\ndisk usage:\n" - -for line in "${dfs[@]}"; do - # get disk usage - usage=$(echo "$line" | awk '{print $2}' | sed 's/%//') - used_width=$(((usage * bar_width) / 100)) - # color is green if usage < max_usage, else red - if [ "${usage}" -ge "${max_usage}" ]; then - color=$red - else - color=$green - fi - # print green/red bar until used_width - bar="[${color}" - for ((i = 0; i < used_width; i++)); do - bar+="=" - done - # print dimmmed bar until end - bar+="${white}${dim}" - for ((i = used_width; i < bar_width; i++)); do - bar+="=" - done - bar+="${undim}]" - # print usage line & bar - echo "${line}" | awk '{ printf("%-31s%+3s used out of %+4s\n", $1, $2, $3); }' | sed -e 's/^/ /' - echo -e "${bar}" | sed -e 's/^/ /' -done - -{{- end }} diff --git a/dotfiles/dot_shell/010-options.zsh b/dotfiles/dot_shell/010-options.zsh deleted file mode 100644 index ac07bc4..0000000 --- a/dotfiles/dot_shell/010-options.zsh +++ /dev/null @@ -1,92 +0,0 @@ -# shellcheck disable=SC2016,SC2154,SC2086,SC1087,SC2157 -# ####################### COMPLETIONS ####################### -# Force rehash when command not found -_force_rehash() { - ((CURRENT == 1)) && rehash - return 1 -} -zstyle ':completion:*' completer _complete _match _approximate -zstyle ':completion:*:match:*' original only -zstyle ':completion:*:approximate:*' max-errors 1 numeric - -zstyle ':completion:*' use-cache on -zstyle ':completion:*' cache-path "${HOME}/.zsh/cache" - -zstyle ':completion:*' list-colors '' -zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' -zstyle ':completion:*' completer _oldlist _expand _force_rehash _complete _match # forces zsh to realize new commands -zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' # matches case insensitive for lowercase -zstyle ':completion:*' insert-tab pending # pasting with tabs doesn't perform completion -zstyle ':completion:*' menu select=2 # menu if nb items > 2 -zstyle ':completion:*' special-dirs true # Show dotfiles in completions - -zstyle ':completion:*:functions' ignored-patterns '_*' #Ignore completion functions for commands you don't have -zstyle ':completion:*' squeeze-slashes true #f you end up using a directory as argument, this will remove the trailing slash (useful in ln) - -# Tweak the UX of the autocompletion menu to match even if we made a typo and enable navigation using the arrow keys -zstyle ':completion:*' menu select # select completions with arrow keys -zstyle ':completion:*' group-name '' # group results by category - -zstyle ':completion:::::' completer _expand _complete _ignored _approximate # enable approximate matches for completion - -# Make zsh know about hosts already accessed by SSH -zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })' - -setopt auto_menu # show completion menu on successive tab press -setopt complete_in_word -setopt always_to_end - -# ####################### KEYBINDINGS ####################### - -# alt-x : insert last command result -zmodload -i zsh/parameter -insert-last-command-output() { - LBUFFER+="$(eval ${history[$((HISTCMD - 1))]})" -} -zle -N insert-last-command-output -bindkey '^[x' insert-last-command-output - -# hist zsh plugin undo -bindkey "^_" undo - -# [Ctrl-r] - Search backward incrementally for a specified string. -# The string may begin with ^ to anchor the search to the beginning of the line. -bindkey '^r' history-incremental-search-backward - -# Navigate by words with alt+right/left arrows -bindkey "^[^[[C" forward-word -bindkey "^[^[[D" backward-word - -# History Search with alt+up/down arrows -bindkey '^[^[[A' history-substring-search-up -bindkey '^[^[[B' history-substring-search-down - -# [PageUp] - Up a line of history -if [[ -n "$terminfo[kpp]" ]]; then - bindkey "$terminfo[kpp]" up-line-or-history -fi -# [PageDown] - Down a line of history -if [[ -n "$terminfo[knp]" ]]; then - bindkey "$terminfo[knp]" down-line-or-history -fi -# start typing + [Up-Arrow] - fuzzy find history forward -if [[ -n "$terminfo[kcuu1]" ]]; then - bindkey "$terminfo[kcuu1]" history-substring-search-up -fi -# start typing + [Down-Arrow] - fuzzy find history backward -if [[ -n "$terminfo[kcud1]" ]]; then - bindkey "$terminfo[kcud1]" history-substring-search-down -fi -if [[ -n "$terminfo[khome]" ]]; then - # [Home] - Go to beginning of line - bindkey "$terminfo[khome]" beginning-of-line - - # OPTION+left - bindkey '[D' beginning-of-line -fi -if [[ -n "$terminfo[kend]" ]]; then - # [End] - Go to end of line - bindkey "$terminfo[kend]" end-of-line - # OPTION+right - bindkey '[C' end-of-line -fi diff --git a/dotfiles/dot_shell/sourced/001-bind-keys.zsh b/dotfiles/dot_shell/sourced/001-bind-keys.zsh new file mode 100644 index 0000000..9b38295 --- /dev/null +++ b/dotfiles/dot_shell/sourced/001-bind-keys.zsh @@ -0,0 +1,43 @@ +# ####################### KEYBINDINGS ####################### + +# alt-x : insert last command result +zmodload -i zsh/parameter +insert-last-command-output() { + LBUFFER+="$(eval ${history[$((HISTCMD - 1))]})" +} +zle -N insert-last-command-output +bindkey '^[x' insert-last-command-output + +# hist zsh plugin undo +bindkey "^_" undo + +# [Ctrl-r] - Search backward incrementally for a specified string. +# The string may begin with ^ to anchor the search to the beginning of the line. +bindkey '^r' history-incremental-search-backward + +# Navigate by words with alt+right/left arrows +bindkey "^[^[[C" forward-word +bindkey "^[^[[D" backward-word + +# [PageUp] - Up a line of history +if [[ -n "$terminfo[kpp]" ]]; then + bindkey "$terminfo[kpp]" up-line-or-history +fi +# [PageDown] - Down a line of history +if [[ -n "$terminfo[knp]" ]]; then + bindkey "$terminfo[knp]" down-line-or-history +fi + +if [[ -n "$terminfo[khome]" ]]; then + # [Home] - Go to beginning of line + bindkey "$terminfo[khome]" beginning-of-line + + # OPTION+left + bindkey '[D' beginning-of-line +fi +if [[ -n "$terminfo[kend]" ]]; then + # [End] - Go to end of line + bindkey "$terminfo[kend]" end-of-line + # OPTION+right + bindkey '[C' end-of-line +fi diff --git a/dotfiles/dot_shell/010-options.bash b/dotfiles/dot_shell/sourced/001-options.bash similarity index 100% rename from dotfiles/dot_shell/010-options.bash rename to dotfiles/dot_shell/sourced/001-options.bash diff --git a/dotfiles/dot_shell/sourced/001-options.zsh b/dotfiles/dot_shell/sourced/001-options.zsh new file mode 100644 index 0000000..4b5d8ba --- /dev/null +++ b/dotfiles/dot_shell/sourced/001-options.zsh @@ -0,0 +1,83 @@ +# Set Options +############################################# +setopt always_to_end # When completing a word, move the cursor to the end of the word +setopt append_history # this is default, but set for share_history +setopt auto_cd # cd by typing directory name if it's not a command +setopt auto_list # automatically list choices on ambiguous completion +setopt auto_menu # show completion menu on successive tab press +setopt auto_menu # automatically use menu completion +setopt auto_pushd # Make cd push each old directory onto the stack +setopt complete_in_word +setopt completeinword # If unset, the cursor is set to the end of the word +# setopt correct_all # autocorrect commands +setopt extended_glob # treat #, ~, and ^ as part of patterns for filename generation +setopt extended_history # save each command's beginning timestamp and duration to the history file +setopt glob_dots # dot files included in regular globs +setopt hash_list_all # when command completion is attempted, ensure the entire path is hashed +setopt hist_expire_dups_first # # delete duplicates first when HISTFILE size exceeds HISTSIZE +setopt hist_find_no_dups # When searching history don't show results already cycled through twice +setopt hist_ignore_dups # Do not write events to history that are duplicates of previous events +setopt hist_ignore_space # remove command line from history list when first character is a space +setopt hist_reduce_blanks # remove superfluous blanks from history items +setopt hist_verify # show command with history expansion to user before running it +setopt histignorespace # remove commands from the history when the first character is a space +setopt inc_append_history # save history entries as soon as they are entered +setopt interactivecomments # allow use of comments in interactive code (bash-style comments) +setopt longlistjobs # display PID when suspending processes as well +setopt no_beep # silence all bells and beeps +setopt nocaseglob # global substitution is case insensitive +setopt nonomatch ## try to avoid the 'zsh: no matches found...' +setopt noshwordsplit # use zsh style word splitting +setopt notify # report the status of backgrounds jobs immediately +setopt numeric_glob_sort # globs sorted numerically +setopt prompt_subst # allow expansion in prompts +setopt pushd_ignore_dups # Don't push duplicates onto the stack +setopt share_history # share history between different instances of the shell + +#Disable autocorrect +unsetopt correct_all +unsetopt correct + +HISTFILE=${HOME}/.zsh_history +HISTSIZE=100000 +SAVEHIST=${HISTSIZE} + +DISABLE_CORRECTION="true" + +# automatically remove duplicates from these arrays +############################################# +typeset -U path cdpath fpath manpath + +# shellcheck disable=SC2016,SC2154,SC2086,SC1087,SC2157 +# ####################### COMPLETIONS ####################### +# Force rehash when command not found +_force_rehash() { + ((CURRENT == 1)) && rehash + return 1 +} +zstyle ':completion:*' completer _complete _match _approximate +zstyle ':completion:*:match:*' original only +zstyle ':completion:*:approximate:*' max-errors 1 numeric + +zstyle ':completion:*' use-cache on +zstyle ':completion:*' cache-path "${HOME}/.zsh/cache" + +zstyle ':completion:*' list-colors '' +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' +zstyle ':completion:*' completer _oldlist _expand _force_rehash _complete _match # forces zsh to realize new commands +zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' # matches case insensitive for lowercase +zstyle ':completion:*' insert-tab pending # pasting with tabs doesn't perform completion +zstyle ':completion:*' menu select=2 # menu if nb items > 2 +zstyle ':completion:*' special-dirs true # Show dotfiles in completions + +zstyle ':completion:*:functions' ignored-patterns '_*' #Ignore completion functions for commands you don't have +zstyle ':completion:*' squeeze-slashes true #f you end up using a directory as argument, this will remove the trailing slash (useful in ln) + +# Tweak the UX of the autocompletion menu to match even if we made a typo and enable navigation using the arrow keys +zstyle ':completion:*' menu select # select completions with arrow keys +zstyle ':completion:*' group-name '' # group results by category + +zstyle ':completion:::::' completer _expand _complete _ignored _approximate # enable approximate matches for completion + +# Make zsh know about hosts already accessed by SSH +zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })' diff --git a/dotfiles/dot_shell/sourced/001-plugins.zsh b/dotfiles/dot_shell/sourced/001-plugins.zsh new file mode 100644 index 0000000..d8811e0 --- /dev/null +++ b/dotfiles/dot_shell/sourced/001-plugins.zsh @@ -0,0 +1,108 @@ + +# Load Plugins +# https://github.com/mattmc3/zsh_unplugged - Build your own zsh plugin manager +############################################# +# clone your plugin, set up an init.zsh, source it, and add to your fpath +_pluginload_() { + local giturl="$1" + local plugin_name=${${1##*/}%.git} + local plugindir="${ZPLUGINDIR:-$HOME/.zsh/plugins}/$plugin_name" + + # clone if the plugin isn't there already + if [[ ! -d "${plugindir}" ]]; then + command git clone --depth 1 --recursive --shallow-submodules "${giturl}" "${plugindir}" + [[ $? -eq 0 ]] || { echo "plugin-load: git clone failed $1" && return 1; } + fi + + # symlink an init.zsh if there isn't one so the plugin is easy to source + if [[ ! -f $plugindir/init.zsh ]]; then + local initfiles=( + # look for specific files first + $plugindir/$plugin_name.plugin.zsh(N) + $plugindir/$plugin_name.zsh(N) + $plugindir/$plugin_name(N) + $plugindir/$plugin_name.zsh-theme(N) + # then do more aggressive globbing + $plugindir/*.plugin.zsh(N) + $plugindir/*.zsh(N) + $plugindir/*.zsh-theme(N) + $plugindir/*.sh(N) + ) + [[ ${#initfiles[@]} -gt 0 ]] || { >&2 echo "plugin-load: no plugin init file found" && return 1; } + command ln -s ${initfiles[1]} $plugindir/init.zsh + fi + + # source the plugin + source $plugindir/init.zsh + + # modify fpath + fpath+=$plugindir + [[ -d $plugindir/functions ]] && fpath+=$plugindir/functions +} + +# set where we should store Zsh plugins +ZPLUGINDIR=${HOME}/.zsh/plugins + +# add your plugins to this list +plugins=( + # core plugins + zsh-users/zsh-autosuggestions + zsh-users/zsh-completions + + # # user plugins + marlonrichert/zsh-hist # Run hist -h for help + reegnz/jq-zsh-plugin # Write interactive jq queries (Requires jq and fzf) + MichaelAquilina/zsh-you-should-use # Recommends aliases when typed + rupa/z # Tracks your most used directories, based on 'frequency' + darvid/zsh-poetry # activates poetry venvs + + # Additional completions + zpm-zsh/ssh + + # prompts + # denysdovhan/spaceship-prompt + romkatv/powerlevel10k + + # load these last + # zsh-users/zsh-syntax-highlighting + zdharma-continuum/fast-syntax-highlighting + zsh-users/zsh-history-substring-search +) + +# load your plugins (clone, source, and add to fpath) +for repo in ${plugins[@]}; do + _pluginload_ https://github.com/${repo}.git +done +unset repo + +# Update ZSH Plugins +function zshup () { + local plugindir="${ZPLUGINDIR:-$HOME/.zsh/plugins}" + for d in $plugindir/*/.git(/); do + echo "Updating ${d:h:t}..." + command git -C "${d:h}" pull --ff --recurse-submodules --depth 1 --rebase --autostash + done +} + +# CONFIGURE PLUGINS +############################################# +ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=242' # Use a lighter gray for the suggested text +ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE="20" +FAST_HIGHLIGHT[use_brackets]=1 + + +# History Search with alt+up/down arrows + + +# start typing + [Up-Arrow] - fuzzy find history forward +if [[ -n "$terminfo[kcuu1]" ]]; then + bindkey "$terminfo[kcuu1]" history-substring-search-up +else + bindkey '^[^[[A' history-substring-search-up +fi +# start typing + [Down-Arrow] - fuzzy find history backward +if [[ -n "$terminfo[kcud1]" ]]; then + bindkey "$terminfo[kcud1]" history-substring-search-down +else + bindkey '^[^[[B' history-substring-search-down +fi diff --git a/dotfiles/dot_shell/060-exports.sh.tmpl b/dotfiles/dot_shell/sourced/010-exports.sh.tmpl similarity index 94% rename from dotfiles/dot_shell/060-exports.sh.tmpl rename to dotfiles/dot_shell/sourced/010-exports.sh.tmpl index b21f92a..5a77833 100644 --- a/dotfiles/dot_shell/060-exports.sh.tmpl +++ b/dotfiles/dot_shell/sourced/010-exports.sh.tmpl @@ -7,7 +7,6 @@ export EDITOR="$(command -v code nano | head -n 1)" {{ if .use_secrets -}} export HOMEBREW_GITHUB_API_TOKEN="{{ range (onepassword "oktogknogbneoifxxtnefno2cu").fields }}{{ if eq .label "HOMEBREW_GITHUB_API_TOKEN" }}{{ .value }}{{ end }}{{ end }}" -export GITHUB_TOKEN="{{ range (onepassword "oktogknogbneoifxxtnefno2cu").fields }}{{ if eq .label "PERSONAL_GITHUB_TOKEN" }}{{ .value }}{{ end }}{{ end }}" # Valentina env variables for local development on natenate test server # natenate-test-bot diff --git a/dotfiles/dot_shell/020-alerting.sh b/dotfiles/dot_shell/sourced/020-alerting.sh similarity index 100% rename from dotfiles/dot_shell/020-alerting.sh rename to dotfiles/dot_shell/sourced/020-alerting.sh diff --git a/dotfiles/dot_shell/020-colors.sh b/dotfiles/dot_shell/sourced/020-colors.sh similarity index 100% rename from dotfiles/dot_shell/020-colors.sh rename to dotfiles/dot_shell/sourced/020-colors.sh diff --git a/dotfiles/dot_shell/020-prompt.bash b/dotfiles/dot_shell/sourced/030-prompt.bash similarity index 100% rename from dotfiles/dot_shell/020-prompt.bash rename to dotfiles/dot_shell/sourced/030-prompt.bash diff --git a/dotfiles/dot_shell/020-prompt.zsh b/dotfiles/dot_shell/sourced/030-prompt.zsh similarity index 100% rename from dotfiles/dot_shell/020-prompt.zsh rename to dotfiles/dot_shell/sourced/030-prompt.zsh diff --git a/dotfiles/dot_shell/030-common_aliases.sh.tmpl b/dotfiles/dot_shell/sourced/060-common_aliases.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/030-common_aliases.sh.tmpl rename to dotfiles/dot_shell/sourced/060-common_aliases.sh.tmpl diff --git a/dotfiles/dot_shell/030-common_functions.sh b/dotfiles/dot_shell/sourced/060-common_functions.sh similarity index 100% rename from dotfiles/dot_shell/030-common_functions.sh rename to dotfiles/dot_shell/sourced/060-common_functions.sh diff --git a/dotfiles/dot_shell/040-better-defaults.sh.tmpl b/dotfiles/dot_shell/sourced/070-better-defaults.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/040-better-defaults.sh.tmpl rename to dotfiles/dot_shell/sourced/070-better-defaults.sh.tmpl diff --git a/dotfiles/dot_shell/050-linux.sh.tmpl b/dotfiles/dot_shell/sourced/080-linux.sh.tmpl similarity index 69% rename from dotfiles/dot_shell/050-linux.sh.tmpl rename to dotfiles/dot_shell/sourced/080-linux.sh.tmpl index 52c64d9..be19ab5 100644 --- a/dotfiles/dot_shell/050-linux.sh.tmpl +++ b/dotfiles/dot_shell/sourced/080-linux.sh.tmpl @@ -17,9 +17,10 @@ alias logs='journalctl -fu' alias logs-all='journalctl -u' alias ctl='systemctl' -# Show banner on terminal startup -if [[ -f "${HOME}/.local/scripts/debian-startup.sh" ]]; then - ${HOME}/.local/scripts/debian-startup.sh +# Run startup scripts + +if [[ -f "${HOME}/.ssh/scripts/debian-startup.sh" ]]; then + "${HOME}"/.ssh/scripts/debian-startup.sh fi {{- end }} diff --git a/dotfiles/dot_shell/050-macos.sh.tmpl b/dotfiles/dot_shell/sourced/080-macos.sh.tmpl similarity index 97% rename from dotfiles/dot_shell/050-macos.sh.tmpl rename to dotfiles/dot_shell/sourced/080-macos.sh.tmpl index ad62ed3..f11a308 100644 --- a/dotfiles/dot_shell/050-macos.sh.tmpl +++ b/dotfiles/dot_shell/sourced/080-macos.sh.tmpl @@ -28,7 +28,8 @@ f() { flushdns() { # Clears the DNS cache to help fix networking errors - sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder + sudo killall -HUP mDNSResponder + sudo dscacheutil -flushcache } ql() { diff --git a/dotfiles/dot_shell/090-homelab.sh.tmpl b/dotfiles/dot_shell/sourced/090-homelab.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/090-homelab.sh.tmpl rename to dotfiles/dot_shell/sourced/090-homelab.sh.tmpl diff --git a/dotfiles/dot_shell/090-personal.sh.tmpl b/dotfiles/dot_shell/sourced/090-personal.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/090-personal.sh.tmpl rename to dotfiles/dot_shell/sourced/090-personal.sh.tmpl diff --git a/dotfiles/dot_shell/third-party/1password.sh.tmpl b/dotfiles/dot_shell/sourced/third-party/1password.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/third-party/1password.sh.tmpl rename to dotfiles/dot_shell/sourced/third-party/1password.sh.tmpl diff --git a/dotfiles/dot_shell/third-party/ansible.sh b/dotfiles/dot_shell/sourced/third-party/ansible.sh similarity index 100% rename from dotfiles/dot_shell/third-party/ansible.sh rename to dotfiles/dot_shell/sourced/third-party/ansible.sh diff --git a/dotfiles/dot_shell/third-party/atuin.sh b/dotfiles/dot_shell/sourced/third-party/atuin.sh similarity index 100% rename from dotfiles/dot_shell/third-party/atuin.sh rename to dotfiles/dot_shell/sourced/third-party/atuin.sh diff --git a/dotfiles/dot_shell/third-party/chezmoi.sh b/dotfiles/dot_shell/sourced/third-party/chezmoi.sh similarity index 100% rename from dotfiles/dot_shell/third-party/chezmoi.sh rename to dotfiles/dot_shell/sourced/third-party/chezmoi.sh diff --git a/dotfiles/dot_shell/third-party/crowdsec.sh.tmpl b/dotfiles/dot_shell/sourced/third-party/crowdsec.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/third-party/crowdsec.sh.tmpl rename to dotfiles/dot_shell/sourced/third-party/crowdsec.sh.tmpl diff --git a/dotfiles/dot_shell/third-party/docker.sh b/dotfiles/dot_shell/sourced/third-party/docker.sh similarity index 100% rename from dotfiles/dot_shell/third-party/docker.sh rename to dotfiles/dot_shell/sourced/third-party/docker.sh diff --git a/dotfiles/dot_shell/third-party/ffmpeg.sh.tmpl b/dotfiles/dot_shell/sourced/third-party/ffmpeg.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/third-party/ffmpeg.sh.tmpl rename to dotfiles/dot_shell/sourced/third-party/ffmpeg.sh.tmpl diff --git a/dotfiles/dot_shell/third-party/git.sh b/dotfiles/dot_shell/sourced/third-party/git.sh similarity index 100% rename from dotfiles/dot_shell/third-party/git.sh rename to dotfiles/dot_shell/sourced/third-party/git.sh diff --git a/dotfiles/dot_shell/third-party/homebrew.sh.tmpl b/dotfiles/dot_shell/sourced/third-party/homebrew.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/third-party/homebrew.sh.tmpl rename to dotfiles/dot_shell/sourced/third-party/homebrew.sh.tmpl diff --git a/dotfiles/dot_shell/third-party/imaginary.sh.tmpl b/dotfiles/dot_shell/sourced/third-party/imaginary.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/third-party/imaginary.sh.tmpl rename to dotfiles/dot_shell/sourced/third-party/imaginary.sh.tmpl diff --git a/dotfiles/dot_shell/third-party/iterm.sh.tmpl b/dotfiles/dot_shell/sourced/third-party/iterm.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/third-party/iterm.sh.tmpl rename to dotfiles/dot_shell/sourced/third-party/iterm.sh.tmpl diff --git a/dotfiles/dot_shell/third-party/jdfile.sh.tmpl b/dotfiles/dot_shell/sourced/third-party/jdfile.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/third-party/jdfile.sh.tmpl rename to dotfiles/dot_shell/sourced/third-party/jdfile.sh.tmpl diff --git a/dotfiles/dot_shell/third-party/ls_colors.sh.tmpl b/dotfiles/dot_shell/sourced/third-party/ls_colors.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/third-party/ls_colors.sh.tmpl rename to dotfiles/dot_shell/sourced/third-party/ls_colors.sh.tmpl diff --git a/dotfiles/dot_shell/third-party/nomad.sh.tmpl b/dotfiles/dot_shell/sourced/third-party/nomad.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/third-party/nomad.sh.tmpl rename to dotfiles/dot_shell/sourced/third-party/nomad.sh.tmpl diff --git a/dotfiles/dot_shell/third-party/npm.sh b/dotfiles/dot_shell/sourced/third-party/npm.sh similarity index 100% rename from dotfiles/dot_shell/third-party/npm.sh rename to dotfiles/dot_shell/sourced/third-party/npm.sh diff --git a/dotfiles/dot_shell/third-party/pipx.sh.tmpl b/dotfiles/dot_shell/sourced/third-party/pipx.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/third-party/pipx.sh.tmpl rename to dotfiles/dot_shell/sourced/third-party/pipx.sh.tmpl diff --git a/dotfiles/dot_shell/third-party/poetry.sh.tmpl b/dotfiles/dot_shell/sourced/third-party/poetry.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/third-party/poetry.sh.tmpl rename to dotfiles/dot_shell/sourced/third-party/poetry.sh.tmpl diff --git a/dotfiles/dot_shell/third-party/pyenv.sh.tmpl b/dotfiles/dot_shell/sourced/third-party/pyenv.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/third-party/pyenv.sh.tmpl rename to dotfiles/dot_shell/sourced/third-party/pyenv.sh.tmpl diff --git a/dotfiles/dot_shell/third-party/tailscale.sh.tmpl b/dotfiles/dot_shell/sourced/third-party/tailscale.sh.tmpl similarity index 100% rename from dotfiles/dot_shell/third-party/tailscale.sh.tmpl rename to dotfiles/dot_shell/sourced/third-party/tailscale.sh.tmpl diff --git a/dotfiles/dot_shell/third-party/thefuck.sh b/dotfiles/dot_shell/sourced/third-party/thefuck.sh similarity index 100% rename from dotfiles/dot_shell/third-party/thefuck.sh rename to dotfiles/dot_shell/sourced/third-party/thefuck.sh diff --git a/dotfiles/dot_zshrc.tmpl b/dotfiles/dot_zshrc.tmpl index a214454..f385219 100644 --- a/dotfiles/dot_zshrc.tmpl +++ b/dotfiles/dot_zshrc.tmpl @@ -53,96 +53,6 @@ done unset _myPaths _path - -# Load Plugins -# https://github.com/mattmc3/zsh_unplugged - Build your own zsh plugin manager -############################################# -# clone your plugin, set up an init.zsh, source it, and add to your fpath -_pluginload_() { - local giturl="$1" - local plugin_name=${${1##*/}%.git} - local plugindir="${ZPLUGINDIR:-$HOME/.zsh/plugins}/$plugin_name" - - # clone if the plugin isn't there already - if [[ ! -d "${plugindir}" ]]; then - command git clone --depth 1 --recursive --shallow-submodules "${giturl}" "${plugindir}" - [[ $? -eq 0 ]] || { echo "plugin-load: git clone failed $1" && return 1; } - fi - - # symlink an init.zsh if there isn't one so the plugin is easy to source - if [[ ! -f $plugindir/init.zsh ]]; then - local initfiles=( - # look for specific files first - $plugindir/$plugin_name.plugin.zsh(N) - $plugindir/$plugin_name.zsh(N) - $plugindir/$plugin_name(N) - $plugindir/$plugin_name.zsh-theme(N) - # then do more aggressive globbing - $plugindir/*.plugin.zsh(N) - $plugindir/*.zsh(N) - $plugindir/*.zsh-theme(N) - $plugindir/*.sh(N) - ) - [[ ${#initfiles[@]} -gt 0 ]] || { >&2 echo "plugin-load: no plugin init file found" && return 1; } - command ln -s ${initfiles[1]} $plugindir/init.zsh - fi - - # source the plugin - source $plugindir/init.zsh - - # modify fpath - fpath+=$plugindir - [[ -d $plugindir/functions ]] && fpath+=$plugindir/functions -} - -# set where we should store Zsh plugins -ZPLUGINDIR=${HOME}/.zsh/plugins - -# add your plugins to this list -plugins=( - # core plugins - zsh-users/zsh-autosuggestions - zsh-users/zsh-completions - - # # user plugins - peterhurford/up.zsh # Cd to parent directories (ie. up 3) - marlonrichert/zsh-hist # Run hist -h for help - reegnz/jq-zsh-plugin # Write interactive jq queries (Requires jq and fzf) - MichaelAquilina/zsh-you-should-use # Recommends aliases when typed - rupa/z # Tracks your most used directories, based on 'frequency' - - # Additional completions - sudosubin/zsh-github-cli - zpm-zsh/ssh - - # prompts - # denysdovhan/spaceship-prompt - romkatv/powerlevel10k - - # Other - darvid/zsh-poetry # activates poetry venvs - - # load these last - # zsh-users/zsh-syntax-highlighting - zdharma-continuum/fast-syntax-highlighting - zsh-users/zsh-history-substring-search -) - -# load your plugins (clone, source, and add to fpath) -for repo in ${plugins[@]}; do - _pluginload_ https://github.com/${repo}.git -done -unset repo - -# Update ZSH Plugins -function zshup () { - local plugindir="${ZPLUGINDIR:-$HOME/.zsh/plugins}" - for d in $plugindir/*/.git(/); do - echo "Updating ${d:h:t}..." - command git -C "${d:h}" pull --ff --recurse-submodules --depth 1 --rebase --autostash - done -} - if [ -d "${HOME}/.zfunc" ]; then fpath+=${HOME}/.zfunc fi @@ -152,67 +62,13 @@ fi autoload -Uz compinit compinit -i -# CONFIGURE PLUGINS -############################################# -ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=242' # Use a lighter gray for the suggested text -ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE="20" -FAST_HIGHLIGHT[use_brackets]=1 - -# Set Options -############################################# -setopt always_to_end # When completing a word, move the cursor to the end of the word -setopt append_history # this is default, but set for share_history -setopt auto_cd # cd by typing directory name if it's not a command -setopt auto_list # automatically list choices on ambiguous completion -setopt auto_menu # automatically use menu completion -setopt auto_pushd # Make cd push each old directory onto the stack -setopt completeinword # If unset, the cursor is set to the end of the word -# setopt correct_all # autocorrect commands -setopt extended_glob # treat #, ~, and ^ as part of patterns for filename generation -setopt extended_history # save each command's beginning timestamp and duration to the history file -setopt glob_dots # dot files included in regular globs -setopt hash_list_all # when command completion is attempted, ensure the entire path is hashed -setopt hist_expire_dups_first # # delete duplicates first when HISTFILE size exceeds HISTSIZE -setopt hist_find_no_dups # When searching history don't show results already cycled through twice -setopt hist_ignore_dups # Do not write events to history that are duplicates of previous events -setopt hist_ignore_space # remove command line from history list when first character is a space -setopt hist_reduce_blanks # remove superfluous blanks from history items -setopt hist_verify # show command with history expansion to user before running it -setopt histignorespace # remove commands from the history when the first character is a space -setopt inc_append_history # save history entries as soon as they are entered -setopt interactivecomments # allow use of comments in interactive code (bash-style comments) -setopt longlistjobs # display PID when suspending processes as well -setopt no_beep # silence all bells and beeps -setopt nocaseglob # global substitution is case insensitive -setopt nonomatch ## try to avoid the 'zsh: no matches found...' -setopt noshwordsplit # use zsh style word splitting -setopt notify # report the status of backgrounds jobs immediately -setopt numeric_glob_sort # globs sorted numerically -setopt prompt_subst # allow expansion in prompts -setopt pushd_ignore_dups # Don't push duplicates onto the stack -setopt share_history # share history between different instances of the shell -HISTFILE=${HOME}/.zsh_history -HISTSIZE=100000 -SAVEHIST=${HISTSIZE} - -#Disable autocorrect -unsetopt correct_all -unsetopt correct -DISABLE_CORRECTION="true" - -# automatically remove duplicates from these arrays -############################################# -typeset -U path cdpath fpath manpath - -# Set a variable so I can check if I'm running zsh -export ZSH_VERSION=$(zsh --version | awk '{print $2}') # SOURCE Dotfiles ############################################# # Locations containing files *.bash to be sourced to your environment configFileLocations=( - "${HOME}/.shell" + "${HOME}/.shell/sourced" ) for configFileLocation in "${configFileLocations[@]}"; do @@ -229,6 +85,7 @@ done unset configFileLocations configFileLocation + if [ -f "${HOME}/.dotfiles.local" ]; then source "${HOME}/.dotfiles.local" fi