mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-09 02:24:03 +01:00
screen: Bugfix extracted cmd, add customizable TITLE var
Bugfix:
zsh doc:
"If the history mechanism is active, the string that the user typed is
passed as the first argument, otherwise it is an empty string."
The title of a screen window should not depend on the history. So this
patch uses the third passed argument ("the third argument contains the
full text that is being executed.").
TITLE variable:
This combines automatic title set with customizable titles. It's often
useful in a screen session to set a manual title. By using
TITLE=YOUR_TITLE, it will replace the generated prefix but still display
the executed command. "TITLE=" will cause the screen plugin to generate
the title prefix again.
Signed-off-by: Markus Pargmann <mpargmann@allfex.org>
This commit is contained in:
parent
397c085a19
commit
efda505417
1 changed files with 18 additions and 6 deletions
|
|
@ -39,16 +39,28 @@ if [[ "$TERM" == screen* ]]; then
|
||||||
# called by zsh before executing a command
|
# called by zsh before executing a command
|
||||||
function preexec()
|
function preexec()
|
||||||
{
|
{
|
||||||
local -a cmd; cmd=(${(z)1}) # the command string
|
local -a cmd; cmd=(${(z)3}) # the command string
|
||||||
|
if [ "$TITLE" != "" ]
|
||||||
|
then
|
||||||
|
eval "tab_title=$TITLE:$TAB_TITLE_EXEC"
|
||||||
|
eval "tab_hardstatus=$TITLE:$TAB_HARDSTATUS_EXEC"
|
||||||
|
else
|
||||||
eval "tab_title=$TAB_TITLE_PREFIX:$TAB_TITLE_EXEC"
|
eval "tab_title=$TAB_TITLE_PREFIX:$TAB_TITLE_EXEC"
|
||||||
eval "tab_hardstatus=$TAB_HARDSTATUS_PREFIX:$TAB_HARDSTATUS_EXEC"
|
eval "tab_hardstatus=$TAB_HARDSTATUS_PREFIX:$TAB_HARDSTATUS_EXEC"
|
||||||
|
fi
|
||||||
screen_set $tab_title $tab_hardstatus
|
screen_set $tab_title $tab_hardstatus
|
||||||
}
|
}
|
||||||
# called by zsh before showing the prompt
|
# called by zsh before showing the prompt
|
||||||
function precmd()
|
function precmd()
|
||||||
{
|
{
|
||||||
|
if [ "$TITLE" != "" ]
|
||||||
|
then
|
||||||
|
eval "tab_title=$TITLE:$TAB_TITLE_PROMPT"
|
||||||
|
eval "tab_hardstatus=$TITLE:$TAB_HARDSTATUS_PROMPT"
|
||||||
|
else
|
||||||
eval "tab_title=$TAB_TITLE_PREFIX:$TAB_TITLE_PROMPT"
|
eval "tab_title=$TAB_TITLE_PREFIX:$TAB_TITLE_PROMPT"
|
||||||
eval "tab_hardstatus=$TAB_HARDSTATUS_PREFIX:$TAB_HARDSTATUS_PROMPT"
|
eval "tab_hardstatus=$TAB_HARDSTATUS_PREFIX:$TAB_HARDSTATUS_PROMPT"
|
||||||
|
fi
|
||||||
screen_set $tab_title $tab_hardstatus
|
screen_set $tab_title $tab_hardstatus
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
Loading…
Add table
Add a link
Reference in a new issue