From 4e05be7020d9ab8195ed975f2afd4bb6dcf9f4e2 Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Thu, 30 Mar 2017 16:30:22 -0500 Subject: [PATCH] Set prompt for sub-shells --- yadm | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/yadm b/yadm index 0d82f00..57c28a0 100755 --- a/yadm +++ b/yadm @@ -433,10 +433,25 @@ function encrypt() { } function enter() { - require_repo - echo "Entering repo" - $SHELL - echo "Leaving repo" + require_shell + require_repo + + shell_opts="" + shell_path="" + if [[ "$SHELL" =~ bash$ ]]; then + shell_opts="--norc" + shell_path="\w" + elif [[ "$SHELL" =~ [cz]sh$ ]]; then + shell_opts="-f" + shell_path="%~" + fi + + echo "Entering yadm repo" + + yadm_prompt="yadm shell ($YADM_REPO) $shell_path > " + PROMPT="$yadm_prompt" PS1="$yadm_prompt" "$SHELL" $shell_opts + + echo "Leaving yadm repo" } function git_command() { @@ -796,6 +811,9 @@ function require_ls() { LS_PROGRAM=ls fi } +function require_shell() { + [ -x "$SHELL" ] || error_out "\$SHELL does not refer to an executable." +} function bootstrap_available() { [ -f "$YADM_BOOTSTRAP" ] && [ -x "$YADM_BOOTSTRAP" ] && return return 1