mirror of
https://github.com/lloeki/dotfiles.git
synced 2025-12-06 07:24:39 +01:00
modularisation term_title
This commit is contained in:
parent
d5cca2a992
commit
5cfd24a554
3 changed files with 30 additions and 18 deletions
28
bash/term_title
Normal file
28
bash/term_title
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Tell the terminal about the working directory at each prompt.
|
||||
if [ "$TERM_PROGRAM" == "Apple_Terminal" ] && [ -z "$INSIDE_EMACS" ]; then
|
||||
update_terminal_cwd() {
|
||||
# Identify the directory using a "file:" scheme URL,
|
||||
# including the host name to disambiguate local vs.
|
||||
# remote connections. Percent-escape spaces.
|
||||
local SEARCH=' '
|
||||
local REPLACE='%20'
|
||||
local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
|
||||
printf '\e]7;%s\a' "$PWD_URL"
|
||||
}
|
||||
PROMPT_COMMAND="update_terminal_cwd; $PROMPT_COMMAND"
|
||||
fi
|
||||
|
||||
set_term_title() {
|
||||
case $TERM in
|
||||
xterm*|rxvt*)
|
||||
local title="\033]2;$USER@${HOSTNAME%%.*}:${PWD/#$HOME/~}\a"
|
||||
;;
|
||||
*)
|
||||
local title=""
|
||||
;;
|
||||
esac
|
||||
printf "$title"
|
||||
}
|
||||
PROMPT_COMMAND="set_term_title; $PROMPT_COMMAND"
|
||||
|
||||
# vim: ft=sh
|
||||
Loading…
Add table
Add a link
Reference in a new issue