diff --git a/lib/next-in-path.zsh b/lib/next-in-path.zsh new file mode 100644 index 0000000..2edf4e1 --- /dev/null +++ b/lib/next-in-path.zsh @@ -0,0 +1,12 @@ +# find next entry in PATH for wrapper scripts +# Usage: next-in-path +next-in-path() { + entries=( $(which -a $1) ) + index=${entries[(ie)$2]} + if [[ $index -le ${#entries} ]]; then + # found $0, use next entry + echo $entries[$((index + 1))] + else + echo $entries[1] + fi +} diff --git a/lib/term-wrapper-alacritty b/lib/term-wrapper-alacritty old mode 100644 new mode 100755 diff --git a/xdg-wrappers/mbsync b/xdg-wrappers/mbsync new file mode 100755 index 0000000..e0368ec --- /dev/null +++ b/xdg-wrappers/mbsync @@ -0,0 +1,3 @@ +#!/bin/zsh +source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh +$(next-in-path mbsync $0) -c ${XDG_CONFIG_HOME:-$HOME/.config}/mbsyncrc $@ diff --git a/xdg-wrappers/rg b/xdg-wrappers/rg new file mode 100755 index 0000000..fe26674 --- /dev/null +++ b/xdg-wrappers/rg @@ -0,0 +1,4 @@ +#!/bin/zsh +source ${$(realpath "$0"):h:h}/lib/next-in-path.zsh +export RIPGREP_CONFIG_PATH=${XDG_CONFIG_HOME:-$HOME/.config}/ripgreprc +$(next-in-path rg $0) $@