Explorar el Código

Update zsh prompt (update window title using preexec and precmd)

Emmanuel Bouthenot hace 12 años
padre
commit
fa8a9711a0
Se han modificado 1 ficheros con 23 adiciones y 2 borrados
  1. 23 2
      .zsh.d/config.d/prompt.zsh

+ 23 - 2
.zsh.d/config.d/prompt.zsh

@@ -82,9 +82,30 @@ pr_git_prompt() {
     echo -n "${git_prompt}"
 }
 
-function preexec {}
+function preexec {
+    # get the command basename
+    local cmd=${1##*\/}
+    if [ -n "${SSH_CLIENT}" ]; then
+        cmd="%n@%M: ${cmd}"
+    fi
+    if [ -n "$TMUX" ]; then
+        print -Pn "\ek%-3 ${cmd}\e"
+    else
+        print -Pn "\e]0;${cmd}\a"
+    fi
+}
 
-function precmd {}
+function precmd {
+    local cmd="%~"
+    if [ -n "${SSH_CLIENT}" ]; then
+        cmd="%n@%M: ${cmd}"
+    fi
+    if [ -n "$TMUX" ]; then
+        print -Pn "\ek%-3 ${cmd}\e"
+    else
+        print -Pn "\e]0;${cmd}\a"
+    fi
+}
 
 myprompt() {
     if [ "$TERM" = "dumb" ]; then