Created
June 28, 2019 13:05
-
-
Save elfmimi/60fde79c5065fba8c94f09add81f0ff5 to your computer and use it in GitHub Desktop.
path operation on bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function path_remove () { | |
local IFS=: | |
local i A=($PATH) | |
for i in ${!A[*]}; do if [[ "${A[$i]}" == "$1" ]] ; then unset A[$i]; fi; done | |
export PATH="${A[*]}" | |
} | |
; in one line format | |
; function path_remove () { local IFS=: ; local i A=($PATH) ; for i in ${!A[*]} ; do if [[ "${A[$i]}" == "$1" ]] ; then unset A[$i] ; fi ; done ; export PATH="${A[*]}" ; } | |
function path_append () { path_remove "$1"; export PATH="$PATH:$1"; } | |
function path_prepend () { path_remove "$1"; export PATH="$1:$PATH"; } | |
; example | |
; path_remove "$(cygpath -u 'C:\Program Files (x86)\Windows Kits\8.1\bin\x64')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment