From 80ecba539640a5ba151737f4b33e4af5eeef964b Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 11 Sep 2024 00:00:03 -0700 Subject: [PATCH 1/4] shell: add and source plugins Currently only zoxide --- .config/shell/plugins | 15 +++++++++++++++ .config/shell/shrc | 4 ++++ 2 files changed, 19 insertions(+) create mode 100644 .config/shell/plugins diff --git a/.config/shell/plugins b/.config/shell/plugins new file mode 100644 index 0000000..11ff103 --- /dev/null +++ b/.config/shell/plugins @@ -0,0 +1,15 @@ +#!/bin/sh +# shell plugins for POSIX + +# Enable zoxide if it exists +if command zoxide > /dev/null 2>&1 || ${SKIP_ZOXIDE:-false}; then + # Check what shell we're using based on variables that get set by non-posix shells - https://stackoverflow.com/a/3327022 + if [ -n "${ZSH_NAME+set}" ]; then # zsh + eval "$(zoxide init zsh)" + elif [ -n "${BASH+set}" ]; then # bash + eval "$(zoxide init bash)" + else + # assume posix + eval "$(zoxide init posix --hook prompt)" + fi +fi diff --git a/.config/shell/shrc b/.config/shell/shrc index d027687..ea751f2 100644 --- a/.config/shell/shrc +++ b/.config/shell/shrc @@ -82,6 +82,10 @@ ${SKIP_FUNCTIONS:-false} || fnupdate ### Options >>> set -o vi +# <<< +### "Plugins" >>> +${SKIP_SH_PLUGINS:-false} || careful_source "$SHELL_CONFIG_DIR/plugins" + # <<< # <<< From cd5ab32ac6e2efe3f0d4d7e03eb4f271a86dda35 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 11 Sep 2024 00:12:48 -0700 Subject: [PATCH 2/4] bash: remove `colors` function it was moved into `prcolors` a while ago --- .bashrc | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/.bashrc b/.bashrc index b134f33..3eee8e9 100644 --- a/.bashrc +++ b/.bashrc @@ -17,34 +17,7 @@ export SHELL_CONFIG_DIR="${SHELL_CONFIG_DIR:-"${XDG_CONFIG_HOME:-"$HOME/.config" # Source standard shell configuration [ -f "$SHELL_CONFIG_DIR/shrc" ] && source "$SHELL_CONFIG_DIR/shrc" -### Manjaro default bashrc >>> -colors() { - local fgc bgc vals seq0 - - printf "Color escapes are %s\n" '\e[${value};...;${value}m' - printf "Values 30..37 are \e[33mforeground colors\e[m\n" - printf "Values 40..47 are \e[43mbackground colors\e[m\n" - printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n" - - # foreground colors - for fgc in {30..37}; do - # background colors - for bgc in {40..47}; do - fgc=${fgc#37} # white - bgc=${bgc#40} # black - - vals="${fgc:+$fgc;}${bgc}" - vals=${vals%%;} - - seq0="${vals:+\e[${vals}m}" - printf " %-9s" "${seq0:-(default)}" - printf " ${seq0}TEXT\e[m" - printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m" - done - echo; echo - done -} - +### (mostly) Manjaro default bashrc >>> [ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion # Change the window title of X terminals From f0342093853fc53a9bcfe6a2d22dff4823785b12 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 11 Sep 2024 00:13:32 -0700 Subject: [PATCH 3/4] zsh: prefer zoxide to zsh --- .zshrc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.zshrc b/.zshrc index 346561c..d5ac516 100644 --- a/.zshrc +++ b/.zshrc @@ -66,7 +66,9 @@ ${SKIP_PLUGINS:-false} || { zinit load "jeffreytse/zsh-vi-mode" zinit load "zsh-users/zsh-history-substring-search" zinit load "zsh-users/zsh-completions" - zinit load "agkozak/zsh-z" + if ! command -v zoxide &> /dev/null || ${SKIP_ZOXIDE:-false}; then + zinit load "agkozak/zsh-z" + fi # Plugins for use with Nix zinit load "chisui/zsh-nix-shell" From b7d187caaae56d8d98b26cec9e6c3feb0574d660 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Wed, 11 Sep 2024 00:13:44 -0700 Subject: [PATCH 4/4] shell/plugins: fix zoxide check issue --- .config/shell/plugins | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.config/shell/plugins b/.config/shell/plugins index 11ff103..c4c6641 100644 --- a/.config/shell/plugins +++ b/.config/shell/plugins @@ -2,7 +2,7 @@ # shell plugins for POSIX # Enable zoxide if it exists -if command zoxide > /dev/null 2>&1 || ${SKIP_ZOXIDE:-false}; then +if command -v zoxide > /dev/null 2>&1 || ${SKIP_ZOXIDE:-false}; then # Check what shell we're using based on variables that get set by non-posix shells - https://stackoverflow.com/a/3327022 if [ -n "${ZSH_NAME+set}" ]; then # zsh eval "$(zoxide init zsh)" @@ -12,4 +12,6 @@ if command zoxide > /dev/null 2>&1 || ${SKIP_ZOXIDE:-false}; then # assume posix eval "$(zoxide init posix --hook prompt)" fi + # make an alias (feels wrong to do it here, but feels worse to split it into ./aliases) + alias z=zoxide fi