From 83560b5b4ba00df1552d14150ec5d7930e2bdd0a Mon Sep 17 00:00:00 2001 From: Urbain Vaes Date: Sun, 17 Jan 2016 14:54:11 +0000 Subject: Improve install script --- bin/clean | 9 --------- bin/dot | 42 ++++++++++++++++++++---------------------- bin/install | 9 --------- bin/vimin | 4 ++++ 4 files changed, 24 insertions(+), 40 deletions(-) delete mode 100755 bin/clean delete mode 100755 bin/install create mode 100755 bin/vimin (limited to 'bin') diff --git a/bin/clean b/bin/clean deleted file mode 100755 index 19a0455..0000000 --- a/bin/clean +++ /dev/null @@ -1,9 +0,0 @@ -#! /bin/bash -dotdir=/home/urbain/dotfiles && cd $dotdir -for file in `ls -A --ignore="Makefile" --ignore="README.md" --ignore=".git*"`; do - if [[ -f $file/Makefile ]]; then - cd $file && make clean && cd $dotdir - else - rm -f $HOME/$file - fi -done diff --git a/bin/dot b/bin/dot index 905e0c1..2e94da1 100755 --- a/bin/dot +++ b/bin/dot @@ -7,51 +7,49 @@ import yaml # Colors for terminal from termcolor import colored - # Path of dotfiles -dotpath = '/home/urbain/dotfiles' +homepath = '/home/urbain' +dotpath = homepath + '/dotfiles' # Load yaml configuration file with open(dotpath + "/install.yaml", 'r') as stream: config = yaml.load(stream) -# Special symlinks +# Special and default symlinks special_symlinks = set(config['special'].keys()) - -# All files in dir -normal_symlinks = set(os.listdir(dotpath)) - set(config['exclude']) +normal_symlinks = set(config['default']) def perform(action): - # Command to execute - command = config['commands'][action] - for f in special_symlinks | normal_symlinks: # Print filename print('[' + colored(f, 'green') + ']') - if f in config['pre']: - print(config['pre'][f]) - os.system(config['pre'][f]) + if f in config['pre'] and action == 'up': + + # Format command + command = config['pre'][f] + formatted = command.format(file=f, path=dotpath) + + # Print & execute + print(formatted) + os.system(formatted) # Target of symlink if f in special_symlinks: t = config['special'][f] elif f in normal_symlinks: - t = config['default'].format(file=f) - - if t != "": - # Formatted command - formatted = command.format(file=f, path=dotpath, target=t) + t = homepath + '/' + f - # Print & execute command - print(formatted) - os.system(formatted) + # Command to execute + command = config['commands'][action] + formatted = command.format(file=f, path=dotpath, target=t) - else: - print("Nothing to do!") + # Print & execute command + print(formatted) + os.system(formatted) print('\n') diff --git a/bin/install b/bin/install deleted file mode 100755 index bc21136..0000000 --- a/bin/install +++ /dev/null @@ -1,9 +0,0 @@ -#! /bin/bash -dotdir=/home/urbain/dotfiles && cd $dotdir -for file in `ls -A --ignore="Makefile" --ignore="README.md" --ignore=".git*"`; do - if [[ -f $file/Makefile ]]; then - cd $file && make && cd $dotdir - else - rm -f $HOME/$file && ln -s $dotdir/$file $HOME/$file - fi -done diff --git a/bin/vimin b/bin/vimin new file mode 100755 index 0000000..905b30f --- /dev/null +++ b/bin/vimin @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +tempfile=$(mktemp) +urxvt -e vim ${tempfile} +cat ${tempfile} | xclip -i -- cgit v1.2.3