Skip to content

Commit 6961611

Browse files
committedJun 23, 2023
Make path unique after so again
1 parent 102c462 commit 6961611

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed
 

‎bin/uniq-path.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
env_var_name=$1
4+
5+
old_IFS="$IFS"
6+
IFS=':'
7+
read -ra path_array <<< "${!env_var_name}"
8+
IFS="$old_IFS"
9+
10+
declare -A unique_paths
11+
unique_path_array=()
12+
13+
for path in "${path_array[@]}"; do
14+
if [ -z "${unique_paths[$path]}" ]; then
15+
unique_paths[$path]=1
16+
unique_path_array+=("$path")
17+
fi
18+
done
19+
20+
new_env_var=$(IFS=':'; echo "${unique_path_array[*]}")
21+
22+
echo "$new_env_var"

‎inc/aliases.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ alias rm-rf='rm -rf'
4545
alias rm-tags='rm -f cscope.* ncscope.* tags'
4646

4747
# rc aliases
48-
alias so=". ${PROFILE}"
48+
alias uniqueify="/bin/bash --noprofile --norc $ENV_ROOT/bin/uniq-path.sh"
49+
alias uniqueify_PATH="export PATH=`uniqueify PATH`"
50+
alias uniqueify_LD_LIBRARY_PATH="export LD_LIBRARY_PATH=`uniqueify LD_LIBRARY_PATH`"
51+
alias so=". ${PROFILE}; sleep 1; uniqueify_PATH; uniqueify_LD_LIBRARY_PATH;"
4952
alias so.tmux="tmux source $HOME/.tmux.conf"
5053
alias shrc="vim ${PROFILE}"
5154
alias vimrc="vim $HOME/.vimrc"

‎inc/tcsh/aliases.csh

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ alias rm-rf 'rm -rf'
4646
alias rm-tags 'rm -f cscope.* ncscope.* tags'
4747

4848
# rc aliases
49-
alias so "source ${PROFILE}"
49+
alias uniqueify "/bin/bash --noprofile --norc $ENV_ROOT/bin/uniq-path.sh"
50+
alias uniqueify_PATH "export PATH=`uniqueify PATH`"
51+
alias uniqueify_LD_LIBRARY_PATH "export LD_LIBRARY_PATH=`uniqueify LD_LIBRARY_PATH`"
52+
alias so ". ${PROFILE}; sleep 1; uniqueify_PATH; uniqueify_LD_LIBRARY_PATH;"
5053
alias shrc "vim ${PROFILE}"
5154
alias vimrc "vim ~/.vimrc"
5255
alias gvimrc "gvim ~/.gvimrc"

‎seeds/bashrc

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# common
1+
# common
22
source $ENV_ROOT/inc/base.sh
33
# core
44
source $ENV_ROOT/inc/bash/variables.bash
@@ -25,6 +25,5 @@
2525
source $ENV_ROOT/inc/rdp-remote.sh
2626
source $ENV_ROOT/inc/docker.sh
2727
source $ENV_ROOT/inc/launcher.sh
28-
source $ENV_ROOT/inc/settings.sh
2928
source $ENV_ROOT/inc/production.sh
3029
source $ENV_ROOT/inc/pdf.sh

0 commit comments

Comments
 (0)
Please sign in to comment.