From 086e78b68b29babf238ad7580c29b1bc3f716f88 Mon Sep 17 00:00:00 2001 From: Jack Thorne Date: Wed, 5 Nov 2014 16:15:03 -0800 Subject: [PATCH 1/3] This adds two functions to modify your PATH. Both functions check to see if the directories that will be inserted into your PATH are currently on the system. This is good for having one zshrc file and deploying it to myltiple enviroments. --- lib/functions.zsh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/functions.zsh b/lib/functions.zsh index 17f5f9cbf..15bb8e07c 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -73,3 +73,27 @@ function env_default() { env | grep -q "^$1=" && return 0 export "$1=$2" && return 3 } + +# +# Prepends the PATH varible with the input path +# +# Arguments: +# 1. path - The path that will be prepened +# Return value: +# 0 if PATH is exported to ENV +# +function prepend_path() { + [[ -d "$1" ]] && export PATH="$1":$PATH && return 0 +} + +# +# Prepends the PATH varible with the input path +# +# Arguments: +# 1. path - The path that will be prepened +# Return value: +# 0 if PATH is exported to ENV +# +function postpend_path() { + [[ -d "$1" ]] && export PATH=$PATH:"$1" && return 0 +} From 778f31eaacc4295a128d91c5fc28e3e024e17c67 Mon Sep 17 00:00:00 2001 From: Jack Thorne Date: Thu, 26 Feb 2015 10:47:59 -0800 Subject: [PATCH 2/3] fix variable typo --- lib/functions.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/functions.zsh b/lib/functions.zsh index 15bb8e07c..2c8b25581 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -75,7 +75,7 @@ function env_default() { } # -# Prepends the PATH varible with the input path +# Prepends the PATH variable with the input path # # Arguments: # 1. path - The path that will be prepened @@ -87,7 +87,7 @@ function prepend_path() { } # -# Prepends the PATH varible with the input path +# Prepends the PATH variable with the input path # # Arguments: # 1. path - The path that will be prepened From 3cb7cede65a83737127a61c02d0f1074fd63687c Mon Sep 17 00:00:00 2001 From: Jack Thorne Date: Thu, 26 Feb 2015 10:51:20 -0800 Subject: [PATCH 3/3] change postponed to append --- lib/functions.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/functions.zsh b/lib/functions.zsh index 2c8b25581..570c19e66 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -87,13 +87,13 @@ function prepend_path() { } # -# Prepends the PATH variable with the input path +# Append the PATH variable with the input path # # Arguments: -# 1. path - The path that will be prepened +# 1. path - The path that will be append # Return value: # 0 if PATH is exported to ENV # -function postpend_path() { +function append_path() { [[ -d "$1" ]] && export PATH=$PATH:"$1" && return 0 }