From b31396823e9f6cb980032c8f2bfd2935611eb676 Mon Sep 17 00:00:00 2001 From: Urbain Vaes Date: Tue, 14 Jul 2015 19:35:24 +0100 Subject: Wrap code to install git repositories in a plugin --- bookmarks | 3 +- install.sh | 158 +-------------------------------------------------------- repos.zsh | 38 ++++++++++++++ vim/.netrwhist | 3 +- zshrc | 23 +++++---- 5 files changed, 58 insertions(+), 167 deletions(-) create mode 100644 repos.zsh diff --git a/bookmarks b/bookmarks index cd6711e..516474d 100644 --- a/bookmarks +++ b/bookmarks @@ -4,5 +4,6 @@ dotfiles : /home/urbain/dotfiles phd : /home/urbain/Dropbox/phd code : /home/urbain/Dropbox/phd/code/spectral feature : /home/urbain/Dropbox/phd/code/spectral/feature -develop : /home/urbain/Dropbox/phd/code/spectral/develop presentation : /home/urbain/Dropbox/phd/presentations/spectral +develop : /home/urbain/Dropbox/phd/code/spectral/develop +github : /home/urbain/github diff --git a/install.sh b/install.sh index 0e7ba9c..0ae7862 100755 --- a/install.sh +++ b/install.sh @@ -4,120 +4,6 @@ home=/home/urbain dir=$home/dotfiles olddir=$home/dotfiles_old -declare -A repodirs -repodirs[alols/xcape]=$home/xcape -repodirs[Anthony25/gnome-terminal-colors-solarized]=$home/github/gnome-terminal-colors-solarized -repodirs[altercation/mutt-colors-solarized]=$home/github/mutt-colors-solarized -repodirs[seebi/dircolors-solarized]=$home/github/dircolors-solarized -repodirs[uvaes/fzf-marks]=$home/github/fzf-marks -repodirs[atweiden/fzf-extras]=$home/github/fzf-extras -repodirs[rupa/z]=$home/github/z -repodirs[junegunn/fzf]=$home/.fzf -repodirs[icholy/ttygif]=$home/github/ttygif -repodirs[tmux-plugins/tpm]=$home/.tmux/plugins/tpm -repodirs[junegunn/vim-plug]=$dir/vim/vim-plug -repodirs[tarjoilija/zgen]=$home/.zgen - -function after_vimplug { - cd .. - rm -rf autoload - mkdir -p autoload - cd autoload - ln -s ../vim-plug/plug.vim; -} - -declare -A actions -actions[Anthony25/gnome-terminal-colors-solarized]='' -actions[alols/xcape]='make' -actions[altercation/mutt-colors-solarized]='' -actions[icholy/ttygif]='make' -actions[junegunn/fzf]='./install' -actions[rupa/z]='make' -actions[atweiden/fzf-extras]='' -actions[junegunn/vim-plug]='after_vimplug' -actions[seebi/dircolors-solarized]='' -actions[tmux-plugins/tpm]='' -actions[uvaes/fzf-marks]='' - -function fetch_repo { - cd $1 - echo "Fetching origin of git repository stored in $1 ..." - git fetch -q origin master -} - -function clone_repo { - githubDir=https://github.com/$1 - echo "Cloning $repo in $2" - git clone -q $githubDir $2 - cd $2 -} - -function waitjobs { - for job in `jobs -p` - do - wait $job - done -} - -function install_repos { - echo -e "\n*** \e[1mInstalling git repositories\e[0m ***" - - for repo in "${!repodirs[@]}"; do - - repodir=${repodirs[$repo]} - action=${actions[$repo]} - - if [ ! -d $repodir ]; then - clone_repo $repo $repodir $action & - else - echo -e "\e[0mRepository $repo already installed in ${repodir}.\e[0m" - fi - done - waitjobs - echo "--> Done!"; echo - - echo -e "*** \e[1mExectutiong actions after installation\e[0m ***" - for repo in "${!repodirs[@]}"; do - cd ${repodirs[$repo]} - eval ${actions[$repo]} - done -} - -function update_repos { - echo -e "\n*** \e[1mUpdating git repositories\e[0m ***" - - for repo in "${!repodirs[@]}"; do - - repodir=${repodirs[$repo]} - - if [ -d $repodir ]; then - fetch_repo $repodir & - fi - done - - waitjobs - echo "--> Done!"; echo - - for repo in "${!repodirs[@]}"; do - - repodir=${repodirs[$repo]} - - if [ -d $repodir ]; then - cd $repodir - echo "Merging upstream updates of git repository stored in ${repo}..." - cat <(git log --reverse --pretty=format:"-- %h %s (%cr)" -4); echo -e "\e[36m" - output=$(git log HEAD..origin) - if [[ ! -z $output ]]; then - cat <(git log --reverse --pretty=format:"-- %h %s (%cr)" HEAD..origin); echo -e "\e[0m" - else - echo -e "-- No updates since last pull\e[0m" - fi - git merge -q origin/master - echo - fi - done -} - function install_dotfiles { echo -e "\n*** \e[1mInstalling dotfiles\e[0m ***" @@ -145,12 +31,6 @@ function install_dotfiles { } function clean { - echo -e "\n*** \e[1mCleaning repositories\e[0m ***" - for repo in "${!repodirs[@]}"; do - echo "Cleaning $repo in ${repodirs[$repo]}" - rm -rf ${repodirs[$repo]} - done - echo -e "\n*** \e[1mCleaning dotfiles\e[0m ***" for file in `ls`; do rm -rfv ~/.$file @@ -180,39 +60,5 @@ function update_dotfiles { fi } -if [[ $# = 0 ]]; then - update_dotfiles - install_dotfiles - update_repos -fi - -while [[ $# > 0 ]] -do - key="$1" - case $key in - -d|--dotfiles) - install_dotfiles - ;; - -i|--repositories) - install_repos - ;; - -u|--repositories) - update_repos - ;; - -p|--packages) - install_packages - ;; - -c|--clean) - clean - ;; - -a|--all) - clean - install_dotfiles - install_repos - update_repos - ;; - *) - ;; - esac - shift -done +update_dotfiles +install_dotfiles diff --git a/repos.zsh b/repos.zsh new file mode 100644 index 0000000..adf1a61 --- /dev/null +++ b/repos.zsh @@ -0,0 +1,38 @@ +home=/home/urbain +dir=$home/dotfiles +olddir=$home/dotfiles_old + +declare -A repodirs + +# General purpose programs +repodirs[alols/xcape]=$home/xcape +repodirs[icholy/ttygif]=$home/github/ttygif + +# Solarized for mutt +repodirs[altercation/mutt-colors-solarized]=$home/github/mutt-colors-solarized + +# My repositories + +# fzf-related +repodirs[uvaes/fzf-marks]=$home/github/fzf-marks +repodirs[atweiden/fzf-extras]=$home/github/fzf-extras +repodirs[junegunn/fzf]=$home/.fzf + +# Plugin managers for tmux/vim/zsh +repodirs[tmux-plugins/tpm]=$home/.tmux/plugins/tpm +repodirs[junegunn/vim-plug]=$dir/vim/vim-plug +repodirs[tarjoilija/zgen]=$home/.zgen + +function after_vimplug { + cd .. + rm -rf autoload + mkdir -p autoload + cd autoload + ln -s ../vim-plug/plug.vim; +} + +declare -A actions +actions[alols/xcape]='make' +actions[icholy/ttygif]='make' +actions[junegunn/fzf]='./install' +actions[junegunn/vim-plug]='after_vimplug' diff --git a/vim/.netrwhist b/vim/.netrwhist index 76938f5..41f3d6c 100644 --- a/vim/.netrwhist +++ b/vim/.netrwhist @@ -1,3 +1,4 @@ let g:netrw_dirhistmax =10 -let g:netrw_dirhist_cnt =1 +let g:netrw_dirhist_cnt =2 let g:netrw_dirhist_1='/home/urbain/Dropbox/phd/code/spectral/develop/cpp' +let g:netrw_dirhist_2='/home/urbain/dotfiles' diff --git a/zshrc b/zshrc index 432f0c0..5d27d39 100644 --- a/zshrc +++ b/zshrc @@ -20,39 +20,44 @@ if ! zgen saved; then zgen load zsh-users/zsh-syntax-highlighting # Appearance - # zgen load mafredri/zsh-async - # zgen load sindresorhus/pure - zgen oh-my-zsh themes/eastwood + zgen load mafredri/zsh-async + zgen load sindresorhus/pure + # zgen oh-my-zsh themes/eastwood + + # My plugins + zgen load uvaes/fzf-marks + zgen load uvaes/grm # Other plugins zgen load rupa/z zgen load djui/alias-tips zgen load tarruda/zsh-autosuggestions zgen load Tarrasch/zsh-autoenv - zgen load uvaes/fzf-marks zgen load joel-porquet/zsh-dircolors-solarized # Save all to init script zgen save fi -# Custom key bindings +# Custom key bindings for widgets bindkey -a 'k' history-beginning-search-backward bindkey -a 'j' history-beginning-search-forward bindkey '^P' history-beginning-search-backward bindkey '^N' history-beginning-search-forward +bindkey '^y' autosuggest-execute-suggestion + +# Environment variables for plugins +AUTOSUGGESTION_HIGHLIGHT_COLOR='fg=6' +REPOFILE=/home/urbain/dotfiles/repos.zsh -# Plugins configuration # Autosuggestion -AUTOSUGGESTION_HIGHLIGHT_COLOR='fg=6' -bindkey '^y' autosuggest-execute-suggestion zle-line-init() { zle autosuggest-start } zle -N zle-line-init -# Fzf-marks +# Repofile # User configuration export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games" -- cgit v1.2.3