dot

packages and services management
Log | Files | Refs | README

commit 97b919048f7e9da5d27520b6cc5462fe49f81f65
parent bafbc9b39552e2f3fb0c2df0117ada5c3d88c95a
Author: josuah <mail@josuah.net>
Date:   Fri, 18 Nov 2016 13:26:51 +0100

Simplify all this config thing.  May switch to plain makefile!

Diffstat:
M.profile | 5++---
Mbin/config | 102+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
Dbin/config-git | 16----------------
Dbin/config-link | 27---------------------------
Dbin/config-mail | 10----------
Dbin/config-vim | 17-----------------
Rbin/config-sync -> bin/lsync | 0
7 files changed, 86 insertions(+), 91 deletions(-)

diff --git a/.profile b/.profile @@ -31,8 +31,7 @@ export PS1='$( # status line printf %s "$PWD" > $HOME/.cache/status/pwd - printf "\n\033[s\033[0;0H%$(stty size | cut -d " " -f 2)s" "$(status)" - printf "\033[u\033[A" + printf "\n%$(stty size | cut -d " " -f 2)s" "$(status)" # terminal name printf "\033]0;shell\007" @@ -41,7 +40,7 @@ export PS1='$( printf "\033[?6c" # prompt character - printf "\n \033[3%s;1m───\033[0m " "$color" + printf "\033[3%s;1m\n ───\033[0m " "$color" )' export PS2=' > ' export PS3=' > ' diff --git a/bin/config b/bin/config @@ -1,21 +1,89 @@ -# Hub script that acts as a menu for subcommands. +CONFIG="${0%/*}" + usage() { - printf '%s\n' " + printf %s " Usage: ${0##*/} COMMAND -COMMAND" +COMMAND + l link the dotfiles to $HOME + g clone git repos listed in ~/.config/git/projects + m setup mail credentials + v installs vim plugins listed in ~/.vim/plugin +" + + exit 0 +} + + +link() +{ + # Link all dotfiles + find "$CONFIG" -type f -path "$CONFIG/.*" ! -path "*/.git*" | + while IFS='' read -r file + do + destination="$HOME/${file#$CONFIG/}" + + printf '%s\n' "$destination" + mkdir -p "${destination%/*}" + ln -sf "$file" "$destination" + done - for script in "${0%/*}"/config-* + # Delete dead links + find -L "$HOME" -type l -exec rm {} \; +} + + +git-repos() +{ + local projects="$HOME/Projects" + + mkdir -p "$projects" + cd "$projects" + + while read url dir do - subcommand="${script#$0-}" + [ "${dir}" ] && mkdir -p "${dir%/*}" + printf 'cloning %s\n' "${url##*/}" + nohup git clone -q "$url" $dir 2> /dev/null & + done < ~/.config/git/projects - printf '\t%-10s' "$subcommand" - sed '1 s/^# //; q' "$script" - done + printf 'still running in the background' +} - exit 0 + +netrc() +{ + read -p 'address: ' + read -p 'host: ' + read -p 'password: ' password + + printf 'machine %s\nlogin %s\npassword "%s"' \ + "$MAIL_HOST" "$MAIL_ADDR" "$password" > ~/.netrc + chmod 400 "$HOME/.netrc" + + printf '\033[A\r\033[K' +} + + +vim-plugins() +{ + local bundle=~/.vim/bundle + + [ -d "$bundle" ] && rm -r "$bundle" ~/.vim/autoload/pathogen.vim + mkdir -p "$bundle" ~/.vim/autoload + wget -qO ~/.vim/autoload/pathogen.vim http://tpo.pe/pathogen.vim & + + # download the plugins and extract them + while IFS='' read -r plugin + do + printf 'downloading %s\n' "$plugin" + wget -qO- "http://github.com/$plugin/archive/master.tar.gz" | + tar -xvz -f- -c "$bundle" 1> /dev/null & + done < ~/.vim/plugins + + printf 'downloading in background...\n' } @@ -23,15 +91,13 @@ main() { [ $# -eq 0 ] && usage - if [ -f "$0-$1"* ] - then - subcommand="$1" - shift - CONFIG="${0%/*/*}" "$0-$subcommand"* $* - exit $? - else - usage - fi + case "$1" in + l ) link ;; + g ) git-repos ;; + m ) netrc ;; + v ) vim-plugins ;; + * ) usage ;; + esac } diff --git a/bin/config-git b/bin/config-git @@ -1,16 +0,0 @@ -# Clone git repos from "$CONFIG/git/projects" list - -PROJECTS="$HOME/Projects" - -mkdir -p "$PROJECTS" -cd "$PROJECTS" - -sed 's/^[[:space:]]*#.*//; /^[[:space:]]*$/ d' "$CONFIG/git/projects" | - while read url dir - do - [ "${dir}" ] && mkdir -p "${dir%/*}" - printf 'cloning %s\n' "${url##*/}" - nohup git clone -q "$url" $dir 2> /dev/null & - done - -printf 'still running in the background' diff --git a/bin/config-link b/bin/config-link @@ -1,27 +0,0 @@ -CONFIG="${CONFIG:-$HOME/Config}" -LOCAL="${LOCAL:-$LOCAL}" - -# -# Link dotfiles and other resources to $HOME. -# -link() -{ - local destination - - # Link all dotfiles - find "$CONFIG" -type f -path "$CONFIG/.*" ! -path "*/.git*" | - while IFS='' read -r file - do - destination="$HOME/${file#$CONFIG/}" - - printf '%s\n' "$destination" - mkdir -p "${destination%/*}" - ln -sf "$file" "$destination" - done - - # Delete dead links - find -L "$HOME" -type l -exec rm {} \; -} - - -link $@ diff --git a/bin/config-mail b/bin/config-mail @@ -1,10 +0,0 @@ -# Prompt and stores the mail password - -mail='mail@josuah.net' -host='mail.gandi.net' - -mkdir -p "$HOME/Mail" "$HOME/.cache/mail" -read -p 'password: ' p -printf 'machine %s\nlogin %s\npassword "%s"' "$host" "$mail" "$p" > ~/.netrc -chmod 400 "$HOME/.netrc" -printf '\033[A\r\033[K' diff --git a/bin/config-vim b/bin/config-vim @@ -1,17 +0,0 @@ -# Installs vim plugins listed in ~/.vim/plugin - -BUNDLE=~/.vim/bundle - -[ -d "$BUNDLE" ] && rm -r "$BUNDLE" ~/.vim/autoload/pathogen.vim -mkdir -p "$BUNDLE" ~/.vim/autoload -wget -qO ~/.vim/autoload/pathogen.vim http://tpo.pe/pathogen.vim & - -# download the plugins and extract them -while IFS='' read -r plugin -do - printf 'Downloading %s\n' "$plugin" - wget -qO- "http://github.com/$plugin/archive/master.tar.gz" | - tar -xvz -f- -C "$BUNDLE" 1> /dev/null & -done < ~/.vim/plugins - -printf 'Downloading in background...\n' diff --git a/bin/config-sync b/bin/lsync