]> git.phdru.name Git - dotfiles.git/blobdiff - bin/xtitle
Fix(bin/cp_recode_fname): Fix misspelled message
[dotfiles.git] / bin / xtitle
index 6df8cdc282266507ad66b887b28e82fbdc0dbcaa..9fc678e5b25e8f62ebb8096e0e0bd30028010179 100755 (executable)
@@ -1,18 +1,19 @@
-#! /usr/bin/env bash
+#! /bin/sh
 
 case "$TERM" in
    *rxvt*|screen*|*term*|vt100)
       if [ -z "$1" ]; then
-         TITLE="${USER}@${HOSTNAME}:$(echo ${PWD} | sed -e "s|^${HOME}|~|")"
+         TITLE="${USER}@`hostname`:$(echo ${PWD} | sed -e "s|^${HOME}|~|")"
       else
          TITLE="$@"
       fi
-      echo -ne "\033]0;${TITLE}\007" # Set xterm caption
-   ;;
-esac
-
-case "$TERM" in
-   screen*)
-      echo -ne "\033k${TITLE}\033\\" # Set screen caption
+      XTITLE="\033]0;${TITLE}\007" # Set xterm title/icon
+      case "$TERM" in
+         screen*)
+            XTITLE="\033P${XTITLE}\033\\\\" # Set xterm title/icon under screen/tmux 
+            XTITLE="${XTITLE}\033k${TITLE}\033\\\\" # Set screen/tmux caption
+         ;;
+      esac
+      echo -n "$XTITLE"
    ;;
 esac