Skip to content

Commit

Permalink
amend env check to include values, use pathmunge
Browse files Browse the repository at this point in the history
  • Loading branch information
neeasade committed Oct 27, 2019
1 parent bd4df9d commit d57d571
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
10 changes: 8 additions & 2 deletions shell/.sh.d/environment
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ iif() {
eval $1 >/dev/null && echo -n "${2-true}" || echo -n "${3-false}"
}

pathmunge () {
if ! echo $PATH | egrep -q "(^|:)$1($|:)" ; then
PATH=$PATH:$1
fi
}

set_editor() {
export EDITOR="$@"
export GIT_EDITOR="$@"
Expand Down Expand Up @@ -63,7 +69,7 @@ PAGER="less"
# fi

NODE_PATH="$HOME/.npm-packages/lib/node_modules"
PATH="$PATH:$HOME/.npm-packages/bin"
pathmunge "$HOME/.npm-packages/bin"

GEM_HOME="$HOME/.gem"
BUNDLE_PATH="$HOME/.gem"
Expand All @@ -74,7 +80,7 @@ if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then
fi

succ() {
PATH="$HOME/$@:$PATH"
pathmunge "$HOME/$@"
}

XDG_CONFIG_HOME=$HOME/.config
Expand Down
2 changes: 1 addition & 1 deletion shell/.sh.d/functions
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ shot() {
}

shellshot() {
eval echo "$(elisp '(ns/windowshot)')" | pb 0x0
eval printf "$(elisp '(ns/windowshot)' | sed 's/%/%%/g')" | pb 0x0
}

fullshot() {
Expand Down
11 changes: 4 additions & 7 deletions shell/.sh.d/style
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,10 @@ env_prompt() {
return
fi

standard_env=$(bash -i -c 'compgen -v')
changed_vars=$(diff \
<(grep -vE '^BASH_' <<< "$standard_env") \
<(compgen -v | grep -vE '^(BASH_|standard_env|changed_vars|FUNCNAME)') \
| grep '^> ' | sed 's/> //')

changed_vars=$(echo "$changed_vars" | grep -E '^[A-Z]+$')
<(bash -ic '(set -o posix; set | grep -vE "^BASH_")') \
<((set -o posix; set) | grep -vE '^(BASH_|changed_vars|FUNCNAME|PPID|SHLVL)') \
| grep '^> ' | sed 's/> //' | grep -oE '^[A-Z]+\=')

if [ ! -z "$changed_vars" ]; then
echo "E "
Expand All @@ -73,7 +70,7 @@ envv() {
env_prompt >/dev/null

for v in $changed_vars; do
printf '%s=%q\n' $v "$(eval "echo \"\${${v}}\"")"
printf '%s%q\n' $v "$(eval "echo \"\${${v}}\"")"
done
}

Expand Down

0 comments on commit d57d571

Please sign in to comment.