Advertisement
vstraylight

Bash code to set prompt and screen title

Oct 2nd, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.57 KB | None | 0 0
  1. # This will change your prompt and screen/tmux tab title based on how many
  2. # fields there are in the FQDN.  For a normal 3 field FQDN, it will use field1
  3. # like normal.  For 4+ fields it will set it to field1.field2.
  4. #
  5. # Thanks to Paul Jimenez <pj at place dot org> for the sed regex.
  6.  
  7. # Rename screen window
  8. function rename_screen_tab () { echo -ne "\x1bk$@\x1b\\"; return 0; }
  9.  
  10. # Set up the prompt and screen tab name
  11. MYHOST=`echo $HOSTNAME | sed 's/[.][^.]*[.][^.]*$//'`
  12. [[ $TERM == "screen" ]] && PROMPT_COMMAND='rename_screen_tab ${MYHOST}'
  13. PS1="\d \A \w\n\u@$MYHOST > "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement