From 0ad505b78023c8a27d861ec1c154be02d05bf8da Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Wed, 25 Sep 2013 16:38:16 -0700 Subject: [PATCH] Tweaks from simlay. --- .functions | 36 ++++++++++++++++++++++++++++++++---- bootstrap.sh | 21 +++++++++++++++------ 2 files changed, 47 insertions(+), 10 deletions(-) diff --git a/.functions b/.functions index 0015cc19..12404b5d 100644 --- a/.functions +++ b/.functions @@ -1,8 +1,36 @@ -get_col () { - for item in `awk "{print \\$$@}"`; do - printf $item - printf '\n' +get_cols () { + # Usage: get_cols [file_name] [column_num] + column_list="" + for column_num in $@; do + [ -r $column_num ] && continue + + [ $column_num -lt '0' ] && column_num="(NF + 1 $column_num )" #Negative indices like python's array[-1] + + [ -z $column_list ] && column_num="\$$column_num" || column_num=",\$$column_num" # Place commas appropriately. + + column_list="$column_list$column_num" done + unset column_num + + # Is the first parameter a file? + if [ -r $1 ]; then + awk "{print $column_list}" $1 + else + awk "{print $column_list}" + fi + unset column_list +} + +note() { + if [ $# -eq 0 ]; then + (ym && exec $EDITOR $HOME/notes/$(git rev-parse --abbrev-ref HEAD)) ; + else + $EDITOR $HOME/notes/"$*" ; + fi +} + +list_notes() { + ls -c $HOME/notes/ | grep "$*" } function get_shas_that_touched() { diff --git a/bootstrap.sh b/bootstrap.sh index 299d4f3e..710017f6 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,11 +1,20 @@ #!/bin/bash -cd "$(dirname "${BASH_SOURCE}")" +CURRENT_DIRECTORY="$(dirname "${BASH_SOURCE}" | xargs readlink -f)" +cd $CURRENT_DIRECTORY + +echo "Linking From $CURRENT_DIRECTORY" + function doIt() { - rsync --exclude "setup.sh" --exclude "Monaco-Powerline.otf" --exclude "web_start.sh" \ - --exclude "oh-my-zsh" --exclude "tmux-powerline" --exclude ".git/" \ - --exclude ".DS_Store" --exclude "bootstrap.sh" --exclude "README.md" \ - --exclude "requirements.txt" --exclude "more_python.txt" \ - -av . ~ + [[ -a ~/.dotfiles-backups ]] || mkdir ~/.dotfiles-backups + exclude_list="setup.sh Monaco-Powerline.otf web_start.sh oh-my-zsh tmux-powerline .git .gitmodules .DS_store bootstrap.sh README.md more_python.txt . .. requirements.txt" + + for i in .*; do + if ! [ -z ${i/*.swp/} ] && ! [[ $exclude_list =~ $i ]] + then + [[ -a ~/$i ]] && mv ~/$i ~/.dotfiles-backups/$i + ln -si $CURRENT_DIRECTORY/$i ~/$i + fi + done } if [ "$1" == "--force" -o "$1" == "-f" ]; then