readme verifie et install un sym link pour vimrc screenrc et zshrc

This commit is contained in:
hugodu69
2019-02-06 03:39:25 +01:00
parent 0add5ade1e
commit 2d53cd8270
4 changed files with 151 additions and 15 deletions

View File

@@ -1,3 +1,8 @@
#hugogogo# following lines are from hugogogo
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# ADDS BY HUGOGOGO #
@@ -52,4 +57,4 @@ screen
#hugogogo#

7
.vimrc
View File

@@ -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"

77
.zshrc Normal file
View File

@@ -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#

View File

@@ -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