diff options
author | Mike Burns <mike@mike-burns.com> | 2013-08-01 16:06:30 -0400 |
---|---|---|
committer | Mike Burns <mike@mike-burns.com> | 2013-08-02 17:51:02 -0400 |
commit | 9e16a4aea0dad1909abc78b3f9bc1291917486db (patch) | |
tree | e8dfdebb79370c0b46aab71d805621f6fe5ee34c /bin | |
parent | fe3244ca9c8c9a38ea700851e36667b1015d11e6 (diff) |
Add `mkrc -o` to install host-specific files
To make it easier to manage host-specific rc files, `mkrc` now supports
a `-o` option. This causes the specified file to be added to the host
section named for the current machine.
This option is in conflict with the `-t` option.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/mkrc | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -4,10 +4,17 @@ . $RCM_LIB/rcm.sh destination() { - if [ $# -eq 2 ]; then - echo $1 + local dotfiles_dir=$1 + local dotless=$2 + local in_host=$3 + local tag=$4 + + if [ "x$tag" != "x" ]; then + echo $dotfiles_dir/tag-$tag + elif [ $in_host = 1 ]; then + echo $dotfiles_dir/host-`hostname` else - echo $1/tag-$3 + echo $dotfiles_dir fi } @@ -16,7 +23,7 @@ if [ -e $HOME/.rcrc ]; then fi if [ $# -eq 0 ]; then - echo "Usage: mkrc [-d dir] [-t tag] [-v] [-q] filename ..." + echo "Usage: mkrc [-d dir] [-t tag] [-o] [-v] [-q] filename ..." exit 1 fi @@ -26,13 +33,15 @@ done tag= verbosity=0 +in_host=0 version=0 -while getopts Vvqt:d: opt; do +while getopts Vvqot:d: opt; do case "$opt" in t) tag=$OPTARG;; v) verbosity=$(($verbosity + 1));; q) verbosity=$(($verbosity - 1));; + o) in_host=1;; d) DOTFILES_DIR=$OPTARG;; V) version=1 esac @@ -41,11 +50,15 @@ shift $(($OPTIND-1)) handle_common_flags mkrc $version $verbosity +if [ $in_host -eq 1 -a "x$tag" != "x" ]; then + $ERROR 1 "Cannot specify both -o and -t" +fi + files=$@ for file in $files; do dotless=`echo $file | sed -e "s|$DEST_DIR/||" | sed -e 's/^\.//'` - dest=`destination $DOTFILES_DIR $dotless $tag` + dest=`destination $DOTFILES_DIR $dotless $in_host $tag` mkdir -p $dest/`dirname $dotless` $MV $file $dest/$dotless $INSTALL -d $DOTFILES_DIR -t ${tag:--} $dotless |