From 9c2642c687b943fdce3453a88522087b6d92b3e0 Mon Sep 17 00:00:00 2001 From: Joaquin Varela Date: Wed, 17 Aug 2016 15:55:27 -0300 Subject: [PATCH] Added env --- with | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/with b/with index 255df68..8b67381 100755 --- a/with +++ b/with @@ -4,9 +4,17 @@ # usage: with # opens an interactive shell instance that automatically prefixes all subsequent commands with program name -pmpt="$*>" +# prompt env checker function +function getpmpt(){ + if [ "$WITH_PROMPT" != "" ]; then + sed "s/%c/$*/g" <<< "$WITH_PROMPT" + else + echo "$*>" + fi +} prefix=$* +pmpt="$(getpmpt $prefix)" which $1 2>&1 > /dev/null program_installed=$? @@ -29,12 +37,12 @@ while [ true ]; do # remove with if [ $curr_command == - ]; then prefix=$( echo $prefix | awk '{$NF="";sub(/[ \t]+$/,"")}1' ) - pmpt="$prefix>" + pmpt="$(getpmpt $prefix)" # nesting withs elif [[ $curr_command == +* ]]; then parsed=${options#"+"} prefix=$( echo "$prefix" "$parsed" ) - pmpt="$prefix>" + pmpt="$(getpmpt $prefix)" # process shell commands elif [[ $curr_command == :* ]]; then parsed=${options#":"}