Set prompt for sub-shells

This commit is contained in:
Tim Byrne 2017-03-30 16:30:22 -05:00
parent 1c34bc8e7f
commit 4e05be7020
No known key found for this signature in database
GPG Key ID: 14DB4FC2465A4B12
1 changed files with 22 additions and 4 deletions

26
yadm
View File

@ -433,10 +433,25 @@ function encrypt() {
} }
function enter() { function enter() {
require_repo require_shell
echo "Entering repo" require_repo
$SHELL
echo "Leaving 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() { function git_command() {
@ -796,6 +811,9 @@ function require_ls() {
LS_PROGRAM=ls LS_PROGRAM=ls
fi fi
} }
function require_shell() {
[ -x "$SHELL" ] || error_out "\$SHELL does not refer to an executable."
}
function bootstrap_available() { function bootstrap_available() {
[ -f "$YADM_BOOTSTRAP" ] && [ -x "$YADM_BOOTSTRAP" ] && return [ -f "$YADM_BOOTSTRAP" ] && [ -x "$YADM_BOOTSTRAP" ] && return
return 1 return 1