summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--10_Environment.zsh12
1 files changed, 12 insertions, 0 deletions
diff --git a/10_Environment.zsh b/10_Environment.zsh
index 0009773..faef244 100644
--- a/10_Environment.zsh
+++ b/10_Environment.zsh
@@ -70,4 +70,16 @@ SAVEHIST=42000
export GPG_TTY=`tty`
+# Display guess
+CURRENT_DISPLAY=$(finger | tail -n+2 | grep -E $USER'[[:blank:]]+.*[[:blank:]]+tty[0-9][[:blank:]]+($DISPLAY)' | head -n1 | cut -d'(' -f2 | cut -d')' -f1)
+if [ "$DISPLAY" = "" -o "$CURRENT_DISPLAY" = "" ]
+then
+ GUESS_DISPLAY=$(finger | tail -n+2 | grep -E $USER'[[:blank:]]+.*[[:blank:]]+tty[0-9]' | head -n1 | cut -d'(' -f2 | cut -d')' -f1)
+ if [ "$GUESS_DISPLAY" != "" ]
+ then
+ export DISPLAY=$GUESS_DISPLAY
+ else
+ unset DISPLAY
+ fi
+fi