From 2d53cd8270d3f8005546b557e75a9a23bb3f084f Mon Sep 17 00:00:00 2001 From: hugodu69 Date: Wed, 6 Feb 2019 03:39:25 +0100 Subject: [PATCH] readme verifie et install un sym link pour vimrc screenrc et zshrc --- .screenrc | 7 ++++- .vimrc | 7 ++++- .zshrc | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.txt | 75 +++++++++++++++++++++++++++++++++++++++++++--------- 4 files changed, 151 insertions(+), 15 deletions(-) create mode 100644 .zshrc diff --git a/.screenrc b/.screenrc index 3bf9920..e0d5892 100644 --- a/.screenrc +++ b/.screenrc @@ -1,3 +1,8 @@ +#hugogogo# following lines are from hugogogo + + + + # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # ADDS BY HUGOGOGO # @@ -52,4 +57,4 @@ screen - +#hugogogo# diff --git a/.vimrc b/.vimrc index ce4f3bb..787984b 100644 --- a/.vimrc +++ b/.vimrc @@ -1,3 +1,8 @@ +"hugogogo" following lines are from hugogogo + + + + " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " ADDS BY HUGOGOGO " @@ -122,4 +127,4 @@ command! End $s/$/\r\r<\/div>\r<\/div>\r<\/body>\r<\/html> - +"hugogogo" diff --git a/.zshrc b/.zshrc new file mode 100644 index 0000000..5120e24 --- /dev/null +++ b/.zshrc @@ -0,0 +1,77 @@ +#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# diff --git a/README.txt b/README.txt index c86d5f6..9c81758 100644 --- a/README.txt +++ b/README.txt @@ -1,17 +1,66 @@ +# # put this folder "config" into the $HOME directory -# and execute the following commands or -# just run this README.txt file as an -# executable with sh README.txt +# and run sh README.txt +# +# it will check if .vimrc, .screenrc and .zshrc already +# exists in the $HOME directory and if not it will create +# a sym link in $HOME to those in this config folder +# otherwise if it exist it will add the content of those +# in this config folder to the one already there in $HOME +# -ln -s $HOME/config/.screenrc $HOME/.screenrc -ln -s $HOME/config/.vimrc $HOME/.vimrc +SCREEN="$HOME/.screenrc" +MYSCREEN="$HOME/config/.screenrc" +VIM="$HOME/.vimrc" +MYVIM="$HOME/config/.vimrc" +ZSH="$HOME/.zshrc" +MYZSH="$HOME/config/.zshrc" -# it will create a symbolic lynk to the -# .vimrc and .screenrc files -# located in the config folder -# of course if there already are .vimrc -# and .screenrc files in home directory -# it will not work, so you need to check -# manually what you need to transfer from -# these files to the already existing ones +# ------------------------------------------------------------- +# action on the .screenrc file +# ------------------------------------------------------------- + +if [ -f $SCREEN ]; +then + if grep -q '#hugogogo#' $SCREEN; + then + sed '/#hugogogo#/,/#hugogogo#/d' $SCREEN > $SCREEN.tmp && mv $SCREEN.tmp $SCREEN + fi + cat $MYSCREEN >> $SCREEN +else + ln -s $MYSCREEN $SCREEN +fi + + +# ------------------------------------------------------------- +# action on the .vimrc file +# ------------------------------------------------------------- + +if [ -f $VIM ]; +then + if grep -q '"hugogogo"' $VIM; + then + sed '/"hugogogo"/,/"hugogogo"/d' $VIM > $VIM.tmp && mv $VIM.tmp $VIM + fi + cat $MYVIM >> $VIM +else + ln -s $MYVIM $VIM +fi + + +# ------------------------------------------------------------- +# action on the .zshrc file +# ------------------------------------------------------------- + +if [ -f $ZSH ]; +then + if grep -q '#hugogogo#' $ZSH; + then + sed '/#hugogogo#/,/#hugogogo#/d' $ZSH > $ZSH.tmp && mv $ZSH.tmp $ZSH + fi + cat $MYZSH >> $ZSH +else + ln -s $MYZSH $ZSH +fi +