all repos — dot @ e01393235ef52fc05f2a4a3768f22e73eb12cd73

Shell, editor and terminal configuration, and the tools that go with them

bin/vi (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
#!/bin/bash

set -euo pipefail

# remove self from path
PATH_save="$PATH"
PATH=$( \
	echo "$PATH" \
	| tr ':' '\n' \
	| grep -vE "$(sed 's/\//\\\//g' <<<"$HOME")"'\/\.?bin' \
	| paste -sd ':' - \
)
export PATH

path-of() {
  command -v "$1"
}

editor() {
  path-of "nvim" \
    || path-of "vim" \
    || path-of "vi"
}

export PATH="$PATH_save"
exec "$(editor)" "$@"