From 9af0f4b1ad73f856ec427c6a1e488cedd471939f Mon Sep 17 00:00:00 2001 From: Hugo LAMY Date: Tue, 1 Mar 2022 18:37:48 +0100 Subject: [PATCH] modifs de l'installation automatique et ajouts configs files autofill cpp --- .screenrc | 62 --------------- .zshrc | 77 ------------------- README.md | 32 ++++++++ asides/color.sh | 20 +++++ config_files/.screenrc | 47 ++++++++++++ .vimrc => config_files/.vimrc | 134 +++++++++++++++++++++------------ config_files/.zshrc | 77 +++++++++++++++++++ config_files/skeleton.cpp | 71 +++++++++++++++++ config_files/skeleton.hpp | 31 ++++++++ config_files/skeleton_color.h | 24 ++++++ config_files/skeleton_main.cpp | 6 ++ config_files/skeleton_makefile | 74 ++++++++++++++++++ install.sh | 59 +++++++++++++++ README.txt => old.bak | 24 +++--- git.txt => tutos/git.txt | 0 node.txt => tutos/node.txt | 0 php.txt => tutos/php.txt | 0 react.txt => tutos/react.txt | 0 screen.txt => tutos/screen.txt | 0 shell.txt => tutos/shell.txt | 0 sites.txt => tutos/sites.txt | 0 vim.txt => tutos/vim.txt | 0 uninstall.sh | 62 +++++++++++++++ 23 files changed, 603 insertions(+), 197 deletions(-) delete mode 100644 .screenrc delete mode 100644 .zshrc create mode 100644 README.md create mode 100644 asides/color.sh create mode 100644 config_files/.screenrc rename .vimrc => config_files/.vimrc (70%) create mode 100644 config_files/.zshrc create mode 100644 config_files/skeleton.cpp create mode 100644 config_files/skeleton.hpp create mode 100644 config_files/skeleton_color.h create mode 100644 config_files/skeleton_main.cpp create mode 100644 config_files/skeleton_makefile create mode 100644 install.sh rename README.txt => old.bak (78%) rename git.txt => tutos/git.txt (100%) rename node.txt => tutos/node.txt (100%) rename php.txt => tutos/php.txt (100%) rename react.txt => tutos/react.txt (100%) rename screen.txt => tutos/screen.txt (100%) rename shell.txt => tutos/shell.txt (100%) rename sites.txt => tutos/sites.txt (100%) rename vim.txt => tutos/vim.txt (100%) create mode 100644 uninstall.sh diff --git a/.screenrc b/.screenrc deleted file mode 100644 index 7591a56..0000000 --- a/.screenrc +++ /dev/null @@ -1,62 +0,0 @@ -#hugogogo# following lines are from hugogogo - - - - -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# # -# ADDS BY HUGOGOGO # -# # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - -startup_message off - -chdir $HOME/ - -#pour augmenter le scrollback de l'ecran -defscrollback 10000 -#pour afficher une ligne avec des infos -hardstatus on -#pour qu'elle s'affiche en bas -hardstatus alwayslastline -#tout ce qui n'est pas precede de % s'affiche tel quel -#tout ce qui est entre {} formate le texte -# = format texte inchange -# KW couleur arriere bright black, couleur texte bright white -# %n numero de windows -# %t title de windows -# %= remplis les espaces vides -# %c current time -# %d day -# %m month -# %y year -hardstatus string "%{= KW}%n %t %=%c %D %d-%m-%y" -#hide hardstatus: ctrl-a f -bind f eval "hardstatus ignore" -#show hardstatus: ctrl-a f -bind F eval "hardstatus alwayslastline" - -#screen open a new windows -# -t assigne un titre -# vim appel vim avec l'option -n pour eviter les .swp -screen -t shell vim -n $HOME/config/shell.txt -screen -t git vim -n $HOME/config/git.txt -screen -t screen vim -n $HOME/config/screen.txt -screen -t node vim -n $HOME/config/node.txt -screen -t react vim -n $HOME/config/react.txt -screen -t php vim -n $HOME/config/php.txt -screen -t sites vim -n $HOME/config/sites.txt -screen -t vim vim -n $HOME/config/vim.txt - -screen - -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # -# # -# END OF HUGOGOGO'S ADDS # -# # -# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # - - - - -#hugogogo# diff --git a/.zshrc b/.zshrc deleted file mode 100644 index 5120e24..0000000 --- a/.zshrc +++ /dev/null @@ -1,77 +0,0 @@ -#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.md b/README.md new file mode 100644 index 0000000..7d785ca --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +0. this config directory contain config files for severall linux configuration + +- it will place them as a symlink where they need to be (eg. `.vimrc` into `$HOME/`) +- then any modification to them will be a modification to the file in this folder +- so you can save them all by just saving this folder + +1. you should put this folder `huhuhu_config` into the $HOME directory + +this is for .screenrc configuration to work + +2. then run bash install.sh + +it will check if a list of config files already exists : + +- .vimrc +- .screenrc +- .zshrc already + +and for each of them : + +- if it already exist, it will copy the existing file or folder into .bak[nb]. ([nb] is an number, starting to 0) +- then it will create a sym link in $HOME to those in this config folder + +3. to uninstall run bash uninstall.sh + +- it check if the current config file exist, is a symlink, and contain the key phrase `#hugogogo#` +- if so, it will delete it, and replace it by the last config backup file found + +4. if you want to add a config file : + +- put it into `config_files` +- and add it both into `install.sh` and `uninstall.sh` diff --git a/asides/color.sh b/asides/color.sh new file mode 100644 index 0000000..4fd93c3 --- /dev/null +++ b/asides/color.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# COLORS + RED="\e[0;31m" + GREEN="\e[0;32m" + YELLOW="\e[0;33m" + BLUE="\e[0;34m" + MAGENTA="\e[0;35m" + CYAN="\e[0;36m" + WHITE="\e[0;37m" + + B_RED="\e[1;31m" + B_GREEN="\e[1;32m" + B_YELLOW="\e[1;33m" + B_BLUE="\e[1;34m" + B_MAGENTA="\e[1;35m" + B_CYAN="\e[1;36m" + B_WHITE="\e[1;37m" + + ENDCO="\e[0m" diff --git a/config_files/.screenrc b/config_files/.screenrc new file mode 100644 index 0000000..0cb731a --- /dev/null +++ b/config_files/.screenrc @@ -0,0 +1,47 @@ +#hugogogo# + +startup_message off + +chdir $HOME/ + +#pour augmenter le scrollback de l'ecran +defscrollback 10000 + +#pour afficher une ligne avec des infos +hardstatus on + +#pour qu'elle s'affiche en bas +hardstatus alwayslastline + +#tout ce qui n'est pas precede de % s'affiche tel quel +#tout ce qui est entre {} formate le texte +# = format texte inchange +# KW couleur arriere bright black, couleur texte bright white +# %n numero de windows +# %t title de windows +# %= remplis les espaces vides +# %c current time +# %d day +# %m month +# %y year +hardstatus string "%{= KW}%n %t %=%c %D %d-%m-%y" +#hide hardstatus: ctrl-a f +bind f eval "hardstatus ignore" +#show hardstatus: ctrl-a f +bind F eval "hardstatus alwayslastline" + +#screen open a new windows +# -t assigne un titre +# vim appel vim avec l'option -n pour eviter les .swp +screen -t shell vim -n $HOME/huhuhu_config/tutos/shell.txt +screen -t git vim -n $HOME/huhuhu_config/tutos/git.txt +screen -t screen vim -n $HOME/huhuhu_config/tutos/screen.txt +screen -t node vim -n $HOME/huhuhu_config/tutos/node.txt +screen -t react vim -n $HOME/huhuhu_config/tutos/react.txt +screen -t php vim -n $HOME/huhuhu_config/tutos/php.txt +screen -t sites vim -n $HOME/huhuhu_config/tutos/sites.txt +screen -t vim vim -n $HOME/huhuhu_config/tutos/vim.txt + +screen + +#hugogogo# diff --git a/.vimrc b/config_files/.vimrc similarity index 70% rename from .vimrc rename to config_files/.vimrc index 91bb20f..7238fdd 100644 --- a/.vimrc +++ b/config_files/.vimrc @@ -1,63 +1,58 @@ -"hugogogo" following lines are from hugogogo - - - - -" " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " -" " -" ADDS BY HUGOGOGO " -" " -" " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " +"#hugogogo# "--------------------------------------------------------------- -" settings de base +" base settings "--------------------------------------------------------------- -"" Show (partial) command in status line. + +" Show (partial) command in status line. "set showcmd -"" Show matching brackets. +" Show matching brackets. set showmatch -"" Do case insensitive matching +" Do case insensitive matching set ignorecase -"" Do smart case matching +" Do smart case matching set smartcase -"" Incremental search +" Incremental search "set incsearch -"" Automatically save before commands like :next and :make +" Automatically save before commands like :next and :make "set autowrite -"" Hide buffers when they are abandoned +" Hide buffers when they are abandoned set hidden -"" Enable mouse usage (all modes) -"set mouse=a +" Enable mouse usage (all modes) +set mouse=a -"" turns on syntax hilighting +" turns on syntax hilighting syntax on -"" use coloration 'torte' -"" and specify no coloration in the background +" use coloration 'torte' +" and specify no coloration in the background colo elflord highlight Normal ctermbg=NONE highlight nonText ctermbg=NONE -""regle une tabulation egale a quatre espaces +" show existing tab with 4 spaces width set tabstop=4 -"" indent chaque nouvelle ligne comme la precedente +" when indenting with '>', use 4 spaces width +set shiftwidth=4 + +" indent new line like the previous one set autoindent -"" ajoute les numeros de ligne +" show line number set number -"" whitespace characters are made visible +" whitespace characters are made visible "set list -"" le texte passe a la ligne automatiquement +" don't allow wrap set nowrap @@ -65,24 +60,40 @@ set nowrap "--------------------------------------------------------------- " pour pouvoir utiliser la norminette partout "--------------------------------------------------------------- + let g:norminette_exec = '~/.local/bin/norminette' "--------------------------------------------------------------- -" pour deplacer des lignes avec Ctrl + fleches Up et Down +" to move lines with Ctrl + arrow "--------------------------------------------------------------- -nnoremap :m+== -nnoremap :m-2== -inoremap :m+==gi -inoremap :m-2==gi -vnoremap :m'>+gv=gv -vnoremap :m-2gv=gv + +nnoremap :m+ +nnoremap :m-2 +nnoremap >>k +nnoremap <<k + +inoremap :m+gi +inoremap :m-2gi +inoremap >>gi +inoremap <<gi + +vnoremap :m'>+gv +vnoremap :m-2gv +vnoremap >gv +vnoremap <gv + +" move selection inside lines with Ctrl-Shift + left/right +vnoremap `<i_mz"_xgvx`zPgvoo +vnoremap `>gvxpgvoo + "--------------------------------------------------------------- -" pour gerer les swap files +" put swap files in a special directory "--------------------------------------------------------------- + " directory indique a vim où mettre les swap files a la place du " dossier courrant, le double slash demande a vim de donner au " swap file un nom avec son chemin d'acces pour eviter que deux @@ -91,9 +102,47 @@ vnoremap :m-2gv=gv set directory=~/.vim/swapfiles// + +"--------------------------------------------------------------- +" to autofill new files +"--------------------------------------------------------------- + +" to autofill a new Class.hpp file +function! HPPFile() + silent! 0r $HOME/.vim/templates/skeleton.hpp + %s/FileName/\=expand("%:t:r")/g + %s/FILENAME/\=toupper(expand("%:t:r"))/g +endfunction +" to autofill a new Class.cpp file +function! CPPFile() + silent! 0r $HOME/.vim/templates/skeleton.cpp + %s/FileName/\=expand("%:t:r")/g +endfunction +" to autofill a new main.cpp file +function! MAINCPPFile() + silent! 0r $HOME/.vim/templates/skeleton_main.cpp +endfunction +" to autofill a new Makefile file +function! MAKEFile() + silent! 0r $HOME/.vim/templates/skeleton_makefile +endfunction +" to autofill a new color.h file +function! COLORFile() + silent! 0r $HOME/.vim/templates/skeleton_color.h +endfunction + +" autofill calls +autocmd BufNewFile *.hpp call HPPFile() +autocmd BufNewFile *.cpp if @% == 'main.cpp' | call MAINCPPFile() | else | call CPPFile() +autocmd BufNewFile Makefile call MAKEFile() +autocmd BufNewFile color.h call COLORFile() + + + "--------------------------------------------------------------- " pour mettre en gras dans des fichiers txt "--------------------------------------------------------------- + " BufEnter s'active quand un buffer est ouvert ou modifie " setf = setfiletype defini un filetype text SI n'existe pas " (!= 'set filetype=type') defini un new ft meme si existe @@ -114,12 +163,14 @@ au filetype text syn match AsteriskBold "\*\*.*\*\*" contains=Asterisks "--------------------------------------------------------------- " remplis les elements de base d'un fichier html "--------------------------------------------------------------- + command! Html 0s/^/\r\r\t\r\t\t\r\t\t\r\t\t<\/title>\r\t\t<meta name="description" content="description du site web">\r\t\t<meta name="keywords" content="truc, bidule, chouette">\r\t\t<link href=".\/style.css" type="text\/css" rel="stylesheet">\r\t\t<script type="text\/javascript" src="script.js" defer><\/script>\r\t<\/head>\r\t<body>\r\r\t<\/body>\r<\/html> "--------------------------------------------------------------- " pour transformer un text html et/ou css en version affichable "--------------------------------------------------------------- + "remplace < et > par < et > command! Compare %s/</\</g <bar> %s/>/\>/g "remplir les lignes vides avec des <br> @@ -169,14 +220,3 @@ command! Start 0s/^/<!DOCTYPE html>\r<html>\r<head>\r<style>\r#cadre {\r positio "ajoute toutes les lignes de la fin command! End $s/$/\r\r<\/div>\r<\/div>\r<\/body>\r<\/html> - -" " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " -" " -" END OF HUGOGOGO'S ADDS " -" " -" " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " - - - - -"hugogogo" diff --git a/config_files/.zshrc b/config_files/.zshrc new file mode 100644 index 0000000..052b788 --- /dev/null +++ b/config_files/.zshrc @@ -0,0 +1,77 @@ +#hugogogo# + +# ---------------------------------------------------- +# aliases +# ---------------------------------------------------- + +alias open="xdg-open" + + + + +# ---------------------------------------------------- +# configs from old file +# ---------------------------------------------------- + +#export ZSH="/mnt/nfs/homes/hulamy/.oh-my-zsh" +#plugins=(git) +#source $ZSH/oh-my-zsh.sh +#ZSH_THEME="robbyrussell" + + + + +# ---------------------------------------------------- +# 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 +# } + diff --git a/config_files/skeleton.cpp b/config_files/skeleton.cpp new file mode 100644 index 0000000..c8fceb8 --- /dev/null +++ b/config_files/skeleton.cpp @@ -0,0 +1,71 @@ +#include "FileName.hpp" + +#define COPLIEN_COLOR B_CYAN + +/********************************************* + * CONSTRUCTORS + *********************************************/ + +FileName::FileName( std::string foo = FileName::_bar ) : _foo(foo) { +// std::cout << COPLIEN_COLOR "FileName constructor" RESET "\n"; + return; +} + +FileName::FileName( FileName const & src ) { +// std::cout << COPLIEN_COLOR "FileName copy constructor" RESET "\n"; + *this = src; + return; +} + +/********************************************* + * DESTRUCTORS + *********************************************/ + +FileName::~FileName() { +// std::cout << COPLIEN_COLOR "FileName destructor" RESET "\n"; + return; +} + +/********************************************* + * OPERATORS + *********************************************/ + +FileName & FileName::operator=( FileName const & rhs ) { +// Base::operator=(rhs); + if ( this != &rhs ) + { +// _foo = rhs.getFoo(); + } + return *this; +} + +//std::ostream & operator<<(std::ostream & o, FileName const & rhs) +//{ +// o << rhs.getFoo(); +// return (o); +//} + +/********************************************* + * ACCESSORS + *********************************************/ + +//std::string FileName::getFoo() const {return _foo;} + +/********************************************* + * PUBLIC MEMBER FUNCTIONS + *********************************************/ + +//void FileName::function(const std::string & foo) {} + +/********************************************* + * NESTED CLASS + *********************************************/ + +//void FileName::Class::function() {} + +/********************************************* + * STATICS + *********************************************/ + +//std::string const FileName::_bar = "bar"; + diff --git a/config_files/skeleton.hpp b/config_files/skeleton.hpp new file mode 100644 index 0000000..1013b1b --- /dev/null +++ b/config_files/skeleton.hpp @@ -0,0 +1,31 @@ +#ifndef FILENAME_HPP +# define FILENAME_HPP + +# include "color.h" +# include <iostream> +# include <string> + +class FileName { + +public: + + FileName(); + FileName( FileName const & src ); + ~FileName(); + FileName & operator=( FileName const & rhs ); + +// std::string getFoo() const; + +protected: + +// std::string const _foo; + +private: + +// static std::string const FileName::_bar; + +}; + +//std::ostream & operator<<(std::ostream & o, FileName const & rhs); + +#endif diff --git a/config_files/skeleton_color.h b/config_files/skeleton_color.h new file mode 100644 index 0000000..e313f5f --- /dev/null +++ b/config_files/skeleton_color.h @@ -0,0 +1,24 @@ +#ifndef COLOR_H +# define COLOR_H + +# define GRAY "\e[0;30m" +# define RED "\e[0;31m" +# define GREEN "\e[0;32m" +# define YELLOW "\e[0;33m" +# define BLUE "\e[0;34m" +# define PURPLE "\e[0;35m" +# define CYAN "\e[0;36m" +# define WHITE "\e[0;37m" + +# define B_GRAY "\e[1;30m" +# define B_RED "\e[1;31m" +# define B_GREEN "\e[1;32m" +# define B_YELLOW "\e[1;33m" +# define B_BLUE "\e[1;34m" +# define B_PURPLE "\e[1;35m" +# define B_CYAN "\e[1;36m" +# define B_WHITE "\e[1;37m" + +# define RESET "\e[0m" + +#endif diff --git a/config_files/skeleton_main.cpp b/config_files/skeleton_main.cpp new file mode 100644 index 0000000..92d2220 --- /dev/null +++ b/config_files/skeleton_main.cpp @@ -0,0 +1,6 @@ +#include <iostream> +#include <string> + +int main() { + return 0; +} diff --git a/config_files/skeleton_makefile b/config_files/skeleton_makefile new file mode 100644 index 0000000..08cb4bb --- /dev/null +++ b/config_files/skeleton_makefile @@ -0,0 +1,74 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # +# . name = value \ . += append to a variable # +# VARIABLES . value . != set result of command # +# . name is case sensitive . ?= set if not already set # +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # + +NAME = a.out + +#TYPE = c +TYPE = cpp + +ifeq "$(TYPE)" "c" + CC = c + EXT = c +else ifeq "$(TYPE)" "cpp" + CC = c++ + EXT = cpp +endif + +CFLAGS = -Wall -Wextra -Werror $(INCLUDES) +ifeq "$(TYPE)" "cpp" + CFLAGS += -std=c++98 +endif + +VPATH = $(D_SRCS) + +LIBS = + +INCLUDES = -I$(D_HEADERS) + +D_SRCS = . +SRCS = main.cpp + +D_HEADERS = . +HEADERS = + +D_OBJS = builds +OBJS = $(SRCS:%.$(EXT)=$(D_OBJS)/%.o) + +ifeq "$(D_OBJS)" "." + RM_OBJS = rm -f $(OBJS) +else + RM_OBJS = rm -rf $(D_OBJS) +endif + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # +# . target: prerequisites . $@ : target # +# RULES . recipe . $< : 1st prerequisite # +# . recipe . $^ : all prerequisites # +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # + +all: $(NAME) + +$(D_OBJS)/%.o: %.$(EXT) | $(D_OBJS) + $(CC) $(CFLAGS) -c $< -o $@ + +$(D_OBJS): + mkdir $@ + +$(OBJS): $(HEADERS:%=$(D_HEADERS)/%) + +$(NAME): $(OBJS) + $(CC) $(OBJS) -o $@ $(LIBS) + +clean: + $(RM_OBJS) + +fclean: clean + rm -f $(NAME) + +re: fclean all + +.PHONY : all clean fclean re diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..695ded8 --- /dev/null +++ b/install.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# COLORS +source color.sh + +KEY_PHRASE="#hugogogo#" +HERE=$(pwd) +D_CONFIG_FILES="config_files" + +# create those folders if necessary : +mkdir -p ~/.vim/templates +mkdir -p ~/.vim/swapfiles + +# receive 1 argument : absolute path to config file +function save_bak +{ + file_to="$1" + file_name="$(basename $1)" + path_file_to="$(dirname $1)" + number=0 + while [ -f $file_to.hubak$number ] + do + ((number+=1)) + done + echo -en $YELLOW"in " + echo -en $CYAN"\"$path_file_to/\"" + echo -en $YELLOW", mv " + echo -en $CYAN"\"$file_name\"" + echo -en $YELLOW" to " + echo -en $CYAN"\"$file_name.hubak$number\""$ENDCO"\n" + mv $file_to $file_to.hubak$number +} + +# receive 1 argument : absolute path to config file +function install +{ + file_to="$1" + file_name="$(basename $1)" + path_file_to="$(dirname $1)" + if [ -f $file_to ] + then + save_bak $file_to + fi + echo -en $YELLOW"create symlink of " + echo -en $CYAN"\"$file_name\"" + echo -en $YELLOW" in " + echo -en $CYAN"\"$path_file_to\""$ENDCO"\n" + ln -s $HERE/$D_CONFIG_FILES/$file_name $file_to +} + +# argument : directory where the config file should go +install "$home/.screenrc" +install "$home/.vimrc" +install "$home/.zshrc" +install "$home/.vim/templates/skeleton_color.h" +install "$home/.vim/templates/skeleton.cpp" +install "$home/.vim/templates/skeleton.hpp" +install "$home/.vim/templates/skeleton_main.cpp" +install "$home/.vim/templates/skeleton_makefile" diff --git a/README.txt b/old.bak similarity index 78% rename from README.txt rename to old.bak index 45d9e1d..0c976eb 100644 --- a/README.txt +++ b/old.bak @@ -1,31 +1,34 @@ # -# put this folder "config" into the $HOME directory +# put this folder "huhuhu_config" into the $HOME directory # 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 +# exists in the $HOME directory : +# - if it already exist, it will copy the existing file or +# folder into <file>.bak[0.9] +# - then it will create a sym link in $HOME to those in +# this config folder # SCREEN="$HOME/.screenrc" -MYSCREEN="$HOME/config/.screenrc" +MYSCREEN="$HOME/huhuhhu_config/.screenrc" VIM="$HOME/.vimrc" -MYVIM="$HOME/config/.vimrc" +MYVIM="$HOME/huhuhu_config/.vimrc" # create the ~/.vim/swapfiles folder if necessary : mkdir -p ~/.vim/swapfiles ZSH="$HOME/.zshrc" -MYZSH="$HOME/config/.zshrc" +MYZSH="$HOME/huhuhu_config/.zshrc" # ------------------------------------------------------------- # action on the .screenrc file # ------------------------------------------------------------- -if [ -f $SCREEN ]; then +if [ -f $SCREEN ] +then + if [ ! -L $SCREEN ]; then if grep -q '#hugogogo#' $SCREEN; then @@ -34,9 +37,8 @@ if [ -f $SCREEN ]; then fi cat $MYSCREEN >> $SCREEN fi -else - ln -s $MYSCREEN $SCREEN fi +ln -s $MYSCREEN $SCREEN # ------------------------------------------------------------- diff --git a/git.txt b/tutos/git.txt similarity index 100% rename from git.txt rename to tutos/git.txt diff --git a/node.txt b/tutos/node.txt similarity index 100% rename from node.txt rename to tutos/node.txt diff --git a/php.txt b/tutos/php.txt similarity index 100% rename from php.txt rename to tutos/php.txt diff --git a/react.txt b/tutos/react.txt similarity index 100% rename from react.txt rename to tutos/react.txt diff --git a/screen.txt b/tutos/screen.txt similarity index 100% rename from screen.txt rename to tutos/screen.txt diff --git a/shell.txt b/tutos/shell.txt similarity index 100% rename from shell.txt rename to tutos/shell.txt diff --git a/sites.txt b/tutos/sites.txt similarity index 100% rename from sites.txt rename to tutos/sites.txt diff --git a/vim.txt b/tutos/vim.txt similarity index 100% rename from vim.txt rename to tutos/vim.txt diff --git a/uninstall.sh b/uninstall.sh new file mode 100644 index 0000000..4ea2f3e --- /dev/null +++ b/uninstall.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# COLORS +source color.sh + +KEY_PHRASE="#hugogogo#" + +# receive 1 argument : absolute path to config file +function restore_bak +{ + file_to="$1" + file_name="$(basename $1)" + path_file_to="$(dirname $1)" + number=0 + while [ -f $file_to.hubak$number ] + do + ((number+=1)) + done + ((number-=1)) + echo -en $YELLOW"in " + echo -en $CYAN"\"$path_file_to/\"" + echo -en $YELLOW", mv " + echo -en $CYAN"\"$file_name.hubak$number\"" + echo -en $YELLOW" to " + echo -en $CYAN"\"$file_name\""$ENDCO"\n" + mv $file_to.hubak$number $file_to +} + +# receive 1 argument : absolute path to config file +function uninstall +{ + file_to="$1" + file_name="$(basename $1)" + path_file_to="$(dirname $1)" + # -L check if is symlink + if [ -f $file_to ] && [ -L $file_to ] + then + if grep -q $KEY_PHRASE $file + then + if [ -f $file_to.hubak0 ] + then + echo -en $YELLOW"in " + echo -en $CYAN"\"$path_file_to/\"" + echo -en $YELLOW", rm symlink " + echo -en $CYAN"\"$file_name\""$ENDCO"\n" + rm $file_to + restore_bak $file_to + fi + fi + fi +} + + +# argument : directory where the config file should go +uninstall "$HOME/.screenrc" +uninstall "$HOME/.vimrc" +uninstall "$HOME/.zshrc" +uninstall "$home/.vim/templates/skeleton_color.h" +uninstall "$home/.vim/templates/skeleton.cpp" +uninstall "$home/.vim/templates/skeleton.hpp" +uninstall "$home/.vim/templates/skeleton_main.cpp" +uninstall "$home/.vim/templates/skeleton_makefile"