aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-01-27 13:03:09 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-01-27 13:03:56 +1300
commit8cc85ff3ffe5ebd1260ed276fc2b35621ccfba55 (patch)
treeb156c22a29e861b3fb5809365d10e1cfc1b8da26
parentUpdate submodules (diff)
downloaddotfiles-8cc85ff3ffe5ebd1260ed276fc2b35621ccfba55.tar.gz
dotfiles-8cc85ff3ffe5ebd1260ed276fc2b35621ccfba55.zip
Extend "fallback" prompt a bit
Include username/hostname if no SSH variables
-rw-r--r--bash/bashrc.d/prompt.bash5
-rw-r--r--ksh/kshrc.d/prompt.ksh5
-rw-r--r--sh/shrc.d/prompt.sh6
-rw-r--r--zsh/zshrc.d/prompt.zsh5
4 files changed, 18 insertions, 3 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index 2bd70c2f..f64355f7 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -81,10 +81,13 @@ prompt() {
# Revert to simple inexpensive prompts
off)
unset -v PROMPT_COMMAND PROMPT_DIRTRIM
- PS1='\$ '
+ PS1='$ '
PS2='> '
PS3='? '
PS4='+ '
+ if [[ -n $SSH_CLIENT || -n $SSH_CONNECTION ]] ; then
+ PS1=$(id -nu)'@'$(hostname -s)'$ '
+ fi
;;
# Git prompt function
diff --git a/ksh/kshrc.d/prompt.ksh b/ksh/kshrc.d/prompt.ksh
index 1dcbd864..3f526526 100644
--- a/ksh/kshrc.d/prompt.ksh
+++ b/ksh/kshrc.d/prompt.ksh
@@ -188,10 +188,13 @@ function prompt {
# Revert to simple inexpensive prompts
off)
- PS1='\$ '
+ PS1='$ '
PS2='> '
PS3='? '
PS4='+ '
+ if [[ -n $SSH_CLIENT || -n $SSH_CONNECTION ]] ; then
+ PS1=$(id -nu)'@'$(hostname -s)'$ '
+ fi
;;
# Abbreviated working directory
diff --git a/sh/shrc.d/prompt.sh b/sh/shrc.d/prompt.sh
index a481b5bb..f1b67fb4 100644
--- a/sh/shrc.d/prompt.sh
+++ b/sh/shrc.d/prompt.sh
@@ -3,3 +3,9 @@
# it to break the export and then just setting them as simple variables
unset PS1 PS2 PS3 PS4
PS1='$ ' PS2='> ' PS3='? ' PS4='+ '
+
+# If we have an SSH_CLIENT or SSH_CONNECTION environment variable, put the
+# username and hostname in PS1 too.
+if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_CONNECTION" ] ; then
+ PS1=$(id -nu)'@'$(hostname)'$ '
+fi
diff --git a/zsh/zshrc.d/prompt.zsh b/zsh/zshrc.d/prompt.zsh
index f374dbec..446e336e 100644
--- a/zsh/zshrc.d/prompt.zsh
+++ b/zsh/zshrc.d/prompt.zsh
@@ -44,10 +44,13 @@ prompt() {
# Revert to simple inexpensive prompts
off)
- PS1='\$ '
+ PS1='$ '
PS2='> '
PS3='? '
PS4='+ '
+ if [[ -n $SSH_CLIENT || -n $SSH_CONNECTION ]] ; then
+ PS1=$(id -nu)'@'$(hostname -s)'$ '
+ fi
;;
# Git prompt function