mirror of
https://github.com/notwa/rc
synced 2025-02-05 15:43:22 -08:00
add an esoteric function to rotate PATHs
This commit is contained in:
parent
07c2d3809c
commit
8c218457e8
1 changed files with 13 additions and 0 deletions
13
home/shrc
13
home/shrc
|
@ -36,6 +36,19 @@ ADDPATH() { ### @- append a directory to `$PATH` if it isn't already present.
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ROPATH() {
|
||||||
|
[ $# -eq 0 ] || { printf '%s: expected exactly %s arguments, got %s\n' ROPATH 0 $# >&2; return 2; }
|
||||||
|
local segment= previous= newpath= oldpath="$PATH:"
|
||||||
|
while segment="${oldpath%%:*}"; [ "$segment" != "$oldpath" ]; do
|
||||||
|
[ -z "$segment" ] || [ -z "$previous" ] || newpath="$newpath$previous:"
|
||||||
|
[ -z "$segment" ] || previous="$segment"
|
||||||
|
oldpath="${oldpath#*:}"
|
||||||
|
done
|
||||||
|
[ -z "$previous" ] || printf 'rotated %s\n' "$previous" >&2
|
||||||
|
[ -z "$previous" ] || newpath="$previous:$newpath"
|
||||||
|
export PATH="${newpath%:}"
|
||||||
|
}
|
||||||
|
|
||||||
# {{{1 configurations
|
# {{{1 configurations
|
||||||
|
|
||||||
umask 022 # umask should be reset else pip might make faulty installations.
|
umask 022 # umask should be reset else pip might make faulty installations.
|
||||||
|
|
Loading…
Add table
Reference in a new issue