From 4033e43d325e6ff6356eae7c899e593e4e644426 Mon Sep 17 00:00:00 2001 From: Mike Burns Date: Sat, 3 Aug 2013 13:51:27 -0400 Subject: rcup -f and -i Add the `-f` and `-i` options to rcup(1). `-f` will overwrite any file it doesn't recognize; `-i` will prompt each time, and is the default. For example: rm ~/.zshrc touch ~/.zshrc rcup -f # overwrite that .zshrc with the symlink rcup -i # prompt whether to overwrite that .zshrc --- NEWS.md.in | 1 + bin/rcup | 12 +++++++----- man/rcup.1 | 18 +++++++++++++----- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/NEWS.md.in b/NEWS.md.in index f24f2bd..7665527 100644 --- a/NEWS.md.in +++ b/NEWS.md.in @@ -3,6 +3,7 @@ rcm (@PACKAGE_VERSION@) unstable; urgency=low * Improved Debian handling. * Introduce mkrc -o to install host-specific dotfiles. * Add rcdn(1) to remove rc files. + * Add rcup -f and -i to force overwrites/prompt for overwrites. -- Mike Burns Tue, 01 Aug 2013 16:43:33 +0200 diff --git a/bin/rcup b/bin/rcup index 9a0e82b..3aa5fa6 100755 --- a/bin/rcup +++ b/bin/rcup @@ -3,8 +3,6 @@ : ${RCM_LIB:=`dirname $0`/../share/rcm} . $RCM_LIB/rcm.sh -REPLACE_ALL=0 - link_file() { local src=$1 local dest=$2 @@ -78,12 +76,16 @@ handle_command_line() { local version=0 local dotfiles_dirs= local files= + REPLACE_ALL=0 + - while getopts Vqvt:d: opt; do + while getopts Vqvfit:d: opt; do case "$opt" in + f) REPLACE_ALL=1 ;; + i) REPLACE_ALL=0 ;; t) arg_tags="$arg_tags $OPTARG" ;; - v) verbosity=$(($verbosity + 1));; - q) verbosity=$(($verbosity - 1));; + v) verbosity=$(($verbosity + 1)) ;; + q) verbosity=$(($verbosity - 1)) ;; d) dotfiles_dirs="$dotfiles_dirs $OPTARG" ;; V) version=1 esac diff --git a/man/rcup.1 b/man/rcup.1 index e7315ae..a0921b2 100644 --- a/man/rcup.1 +++ b/man/rcup.1 @@ -6,7 +6,7 @@ .Nd update and install dotfiles .Sh SYNOPSIS .Nm rcup -.Op Fl vq +.Op Fl vqfi .Op Fl t Ar tag .Op Fl d Ar dir .Op Ar files ... @@ -23,10 +23,14 @@ for details on the directory layout. .Pp It supports these options: .Bl -tag -.It Fl v -increase verbosity. This can be repeated for extra verbosity. -.It Fl q -decrease verbosity +.It f +If the rc file already exists in your home directory but does not match +the file in your dotfiles directory, remove the rc file then create the +symlink +.It i +If the rc file already exists in your home directory but does not match +the file in your dotfiles directory, prompt for how to handle it. This +is the default .It Fl t Ar TAG install dotfiles according to .Ar TAG @@ -34,6 +38,10 @@ install dotfiles according to install dotfiles from the .Ar DIR \&. This can be specified multiple times. +.It Fl v +increase verbosity. This can be repeated for extra verbosity. +.It Fl q +decrease verbosity .It Ar files only install the specified file(s) .El -- cgit v1.2.3