78 lines
2.7 KiB
Bash
78 lines
2.7 KiB
Bash
#hugogogo# following lines are from hugogogo
|
|
|
|
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
# #
|
|
# #
|
|
# ADDS BY HUGOGOGO #
|
|
# if you modify this section, please copy paste the #
|
|
# modification into the .zshrc file in $HOME/config #
|
|
# #
|
|
# #
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
|
|
# ----------------------------------------------------
|
|
# send the path of the working directory and action to
|
|
# screen as a title
|
|
# ----------------------------------------------------
|
|
#
|
|
# the preexec hook is run after "enter" is press and
|
|
# just before the command is run
|
|
#
|
|
# the precmd hook is executed just before each prompt
|
|
#
|
|
# a command confirmed on the prompt is then passed to
|
|
# preexec in three arguments, the first beeing the
|
|
# string typed (so "$1" is what was typed in prompt)
|
|
#
|
|
# variables are declared local to exist only in this hook
|
|
# there mustn't have space around the "=" to assign a value
|
|
#
|
|
# ps is a UNIX command that show informations about processes
|
|
# "-o stat" show only the status (T=sleeping and R=running)
|
|
# "-o cmd" show the command ("vim index.html")
|
|
# "h" hide the header
|
|
# "T" show all precesses (included the sleeping ones)
|
|
#
|
|
# "\ekTITLE\e\\" is a sequence recognised by GNU screen
|
|
# to set the title (see "info screen -n 'dynamyc titles'")
|
|
#
|
|
# "%~" is expanded into the current directory path
|
|
# "%1~" is expanded into the last argument of the path
|
|
# "-P" is an option of print that "turns on prompt expansions"
|
|
# DOCUMENTATION:
|
|
# http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html
|
|
#
|
|
preexec () {
|
|
local isSleep=$(ps -o stat hT | grep T)
|
|
local action=$1
|
|
if [[ $isSleep == 'T' ]]; then
|
|
action=$(ps -o stat -o cmd hT | sed -n 's/^T[ ]*//p')
|
|
fi
|
|
if [[ $TERM == screen* ]]; then
|
|
print -Pn '\ek%2~/ $action\e\\'
|
|
fi
|
|
}
|
|
precmd () {
|
|
local isSleep=$(ps -o stat hT | grep T)
|
|
local sleep=""
|
|
local action=$(history | tail -1 | sed 's#[0-9 ]*##')
|
|
if [[ $isSleep == 'T' ]]; then
|
|
sleep="*$(ps -o stat -o cmd hT | sed -n 's/^T[ ]*//p')*"
|
|
fi
|
|
if [[ $TERM == screen* ]]; then
|
|
print -Pn '\ek%2~/ $action $sleep\e\\'
|
|
fi
|
|
}
|
|
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
# #
|
|
# END OF HUGOGOGO'S ADDS #
|
|
# #
|
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
|
|
|
|
|
|
|
#hugogogo#
|