summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorGravatar Christopher Koch <ckoch@cs.nmt.edu>2014-07-23 00:03:27 +0200
committerGravatar Mike Burns <mike@mike-burns.com>2014-11-19 15:20:30 -0800
commit8d6bc1fc7b14d26589a4789dc9da291ef404bd61 (patch)
tree9429cd6340cd0436bb678a6ab16ed882aac6fef2 /bin
parent6f011c7fab8d407ec0cd091e9cbeb03c276372ce (diff)
Support rc files without leading dots
This adds the `-U` option to lsrc(1), rcup(1), and rcdn(1) commands; its argument is an exclusion pattern. Any file matching this pattern is symlinked without the leading dot. There is also a `-u` option to undo a `-U`. The `UNDOTTED` setting in rcrc(5) can be used to set it permanently. The mkrc(1) command has `-U` and `-u` flags. They take no argument.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/lsrc.in42
-rwxr-xr-xbin/mkrc.in20
-rwxr-xr-xbin/rcdn.in15
-rwxr-xr-xbin/rcup.in15
4 files changed, 80 insertions, 12 deletions
diff --git a/bin/lsrc.in b/bin/lsrc.in
index ad40b5e..ada436b 100755
--- a/bin/lsrc.in
+++ b/bin/lsrc.in
@@ -214,7 +214,7 @@ is_excluded() {
show_help() {
local exit_code=${1:-0}
- $PRINT "Usage: lsrc [-FhqVv] [-B HOSTNAME] [-d DOT_DIR] [-I EXCL_PAT] [-S EXCL_PAT ] [-s EXCL_PAT] [-t TAG] [-x EXCL_PAT]"
+ $PRINT "Usage: lsrc [-FhqVv] [-B HOSTNAME] [-d DOT_DIR] [-I EXCL_PAT] [-S EXCL_PAT] [-s EXCL_PAT] [-t TAG] [-U EXCL_PAT] [-u EXCL_PAT] [-x EXCL_PAT]"
$PRINT "see lsrc(1) and rcm(7) for more details"
exit $exit_code
@@ -231,8 +231,10 @@ handle_command_line() {
local symlink_dirs=
local never_symlink_dirs=
local hostname=
+ local undotted=
+ local never_undotted=
- while getopts :FVqvhI:x:B:S:s:t:d: opt; do
+ while getopts :FVqvhI:x:B:S:s:U:u:t:d: opt; do
case "$opt" in
F) show_sigils=1;;
h) show_help ;;
@@ -245,6 +247,8 @@ handle_command_line() {
x) excludes="$excludes $OPTARG";;
S) symlink_dirs="$symlink_dirs $OPTARG";;
s) never_symlink_dirs="$never_symlink_dirs $OPTARG";;
+ U) undotted="$undotted $OPTARG";;
+ u) never_undotted="$never_undotted $OPTARG";;
B) hostname="$OPTARG";;
?) show_help 64 ;;
esac
@@ -260,6 +264,8 @@ handle_command_line() {
INCLUDES="${includes:-$INCLUDES}"
SYMLINK_DIRS="${symlink_dirs:-$SYMLINK_DIRS}"
MK_DIRS="${never_symlink_dirs:-$MK_DIRS}"
+ UNDOTTED="${undotted:-$UNDOTTED}"
+ NEVER_UNDOTTED="${never_undotted:-$NEVER_UNDOTTED}"
FILES="$@"
$DEBUG "TAGS: $TAGS"
@@ -282,6 +288,12 @@ $DEBUG "SYMLINK_DIRS: $SYMLINK_DIRS"
: ${MK_DIRS:=""}
$DEBUG "MK_DIRS: $MK_DIRS"
+: ${UNDOTTED:=""}
+$DEBUG "UNDOTTED: $UNDOTTED"
+
+: ${NEVER_UNDOTTED:=""}
+$DEBUG "NEVER_UNDOTTED: $NEVER_UNDOTTED"
+
relative_root_dir="$PWD"
for DOTFILES_DIR in $DOTFILES_DIRS; do
@@ -301,18 +313,27 @@ for DOTFILES_DIR in $DOTFILES_DIRS; do
include_file_globs="$(dotfiles_dir_excludes "$DOTFILES_DIR" "$INCLUDES")"
symlink_dirs_file_globs="$(dotfiles_dir_excludes "$DOTFILES_DIR" "$SYMLINK_DIRS")"
$DEBUG "symlink_dirs_file_globs: $symlink_dirs_file_globs"
- mk_dirs_file_globs=$(dotfiles_dir_excludes "$DOTFILES_DIR" "$MK_DIRS")
+ mk_dirs_file_globs="$(dotfiles_dir_excludes "$DOTFILES_DIR" "$MK_DIRS")"
$DEBUG "mk_dirs_file_globs: $mk_dirs_file_globs"
+ undotted_file_globs="$(dotfiles_dir_excludes "$DOTFILES_DIR" "$UNDOTTED")"
+ $DEBUG "undotted_file_globs: $undotted_file_globs"
+ never_undotted_file_globs="$(dotfiles_dir_excludes "$DOTFILES_DIR" "$NEVER_UNDOTTED")"
+ $DEBUG "never_undotted_file_globs: $never_undotted_file_globs"
cd "$DOTFILES_DIR"
DIR_STACK=":$DOTFILES_DIR"
for file in ${FILES:-*}; do
+ dotted=0
if is_metafile "$file"; then
continue
fi
- handle_file "$file" "$DEST_DIR" "$DOTFILES_DIR" . 0 "$exclude_file_globs" "$include_file_globs" "$symlink_dirs_file_globs" "$mk_dirs_file_globs"
+ if is_excluded "$file" "$undotted_file_globs" "$never_undotted_file_globs"; then
+ dotted=1
+ fi
+
+ handle_file "$file" "$DEST_DIR" "$DOTFILES_DIR" . "$dotted" "$exclude_file_globs" "$include_file_globs" "$symlink_dirs_file_globs" "$mk_dirs_file_globs"
done
cd "$DOTFILES_DIR"
@@ -321,7 +342,12 @@ for DOTFILES_DIR in $DOTFILES_DIRS; do
if [ -d "$host_files" ]; then
pushdir "$(basename "$host_files")"
for file in ${FILES:-*}; do
- handle_file "$file" "$DEST_DIR" "$host_files" . 0 "$exclude_file_globs" "$include_file_globs" "$symlink_dirs_file_globs" "$mk_dirs_file_globs"
+ dotted=0
+ if is_excluded "$file" "$undotted_file_globs" "$never_undotted_file_globs"; then
+ dotted=1
+ fi
+
+ handle_file "$file" "$DEST_DIR" "$host_files" . "$dotted" "$exclude_file_globs" "$include_file_globs" "$symlink_dirs_file_globs" "$mk_dirs_file_globs"
done
popdir
fi
@@ -333,7 +359,11 @@ for DOTFILES_DIR in $DOTFILES_DIRS; do
pushdir "$(basename "tag-$tag")"
for file in ${FILES:-*}; do
$DEBUG "TAG: $tag, exclude_file_globs: $exclude_file_globs"
- handle_file "$file" "$DEST_DIR" "$DOTFILES_DIR/tag-$tag" . 0 "$exclude_file_globs" "$include_file_globs" "$symlink_dirs_file_globs" "$mk_dirs_file_globs"
+ dotted=0
+ if is_excluded "$file" "$undotted_file_globs" "$never_undotted_file_globs"; then
+ dotted=1
+ fi
+ handle_file "$file" "$DEST_DIR" "$DOTFILES_DIR/tag-$tag" . "$dotted" "$exclude_file_globs" "$include_file_globs" "$symlink_dirs_file_globs" "$mk_dirs_file_globs"
done
popdir
fi
diff --git a/bin/mkrc.in b/bin/mkrc.in
index 8932926..da22a63 100755
--- a/bin/mkrc.in
+++ b/bin/mkrc.in
@@ -23,7 +23,7 @@ destination() {
show_help() {
local exit_code=${1:-0}
- $PRINT "Usage: mkrc [-ChSsVvqo] [-t TAG] [-d DIR] [-B HOSTNAME] FILES ..."
+ $PRINT "Usage: mkrc [-ChSsUuVvqo] [-t TAG] [-d DIR] [-B HOSTNAME] FILES ..."
$PRINT "see mkrc(1) and rcm(7) for more details"
exit $exit_code
@@ -44,9 +44,10 @@ in_host=0
version=0
always_copy=0
force_symlink=50
+undotted=50
install_args=
-while getopts :ChSsVvqot:d:B: opt; do
+while getopts :ChSsUuVvqot:d:B: opt; do
case "$opt" in
C) always_copy=1 ;;
h) show_help ;;
@@ -58,6 +59,8 @@ while getopts :ChSsVvqot:d:B: opt; do
V) version=1 ;;
S) force_symlink=1 ;;
s) force_symlink=0 ;;
+ U) undotted=1 ;;
+ u) undotted=0 ;;
B)
in_host=1
hostname="$OPTARG"
@@ -93,11 +96,24 @@ elif [ $force_symlink -eq 0 ]; then
done
fi
+if [ $undotted -eq 1 ]; then
+ for file in $files; do
+ dedotted="$(de_dot "$file")"
+ INSTALL="$INSTALL -U $dedotted"
+ done
+elif [ $undotted -eq 0 ]; then
+ for file in $files; do
+ dedotted="$(de_dot "$file")"
+ INSTALL="$INSTALL -u $dedotted"
+ done
+fi
+
for file in $files; do
case "$file" in
/*) : ;;
*) [ -e "$PWD/$file" ] && file="$PWD/$file" ;;
esac
+
dotless="$(de_dot "$file")"
dest="$(destination "$DOTFILES_DIR" "$dotless" $in_host "$tag")"
mkdir -p "$dest/$(dirname "$dotless")"
diff --git a/bin/rcdn.in b/bin/rcdn.in
index 91223fa..90cfcd6 100755
--- a/bin/rcdn.in
+++ b/bin/rcdn.in
@@ -21,7 +21,7 @@ remove_link() {
show_help() {
local exit_code=${1:-0}
- $PRINT "Usage: rcdn [-hKkqVv] [-B HOSTNAME] [-d DOT_DIR] [-I EXCL_PAT] [-S EXCL_PAT] [-s EXCL_PAT] [-t TAG] [-x EXCL_PAT]"
+ $PRINT "Usage: rcdn [-hqVv] [-B HOSTNAME] [-d DOT_DIR] [-I EXCL_PAT] [-S EXCL_PAT] [-s EXCL_PAT] [-t TAG] [-U EXCL_PAT] [-u EXCL_PAT] [-x EXCL_PAT]"
$PRINT "see rcdn(1) and rcm(7) for more details"
exit $exit_code
@@ -38,9 +38,11 @@ handle_command_line() {
local includes=
local symlink_dirs=
local never_symlink_dirs=
+ local undotted=
+ local never_undotted=
local hostname=
- while getopts :VqvhKkI:x:S:s:t:d:B: opt; do
+ while getopts :VqvhIKk:x:S:s:U:u:t:d:B: opt; do
case "$opt" in
h) show_help ;;
B) hostname="$OPTARG" ;;
@@ -50,6 +52,8 @@ handle_command_line() {
t) arg_tags="$arg_tags $OPTARG" ;;
S) symlink_dirs="$symlink_dirs $OPTARG";;
s) never_symlink_dirs="$never_symlink_dirs $OPTARG";;
+ U) undotted="$undotted $OPTARG";;
+ u) never_undotted="$never_undotted $OPTARG";;
v) verbosity=$(($verbosity + 1));;
q) verbosity=$(($verbosity - 1));;
d) dotfiles_dirs="$dotfiles_dirs $OPTARG" ;;
@@ -86,6 +90,13 @@ handle_command_line() {
for never_symlink_dir in $symlink_dirs; do
LS_ARGS="$LS_ARGS -s $never_symlink_dir"
done
+ for undot in $undotted; do
+ LS_ARGS="$LS_ARGS -U $undot"
+ done
+ for never_undot in $never_undotted; do
+ LS_ARGS="$LS_ARGS -u $never_undot"
+ done
+
LS_ARGS="$LS_ARGS -B $hostname $files"
$DEBUG "LS_ARGS: $LS_ARGS"
diff --git a/bin/rcup.in b/bin/rcup.in
index c990ac7..e5c5cdb 100755
--- a/bin/rcup.in
+++ b/bin/rcup.in
@@ -171,7 +171,7 @@ handle_file() {
show_help() {
local exit_code=${1:-0}
- $PRINT "Usage: rcup [-CfghiKkqVv] [-B HOSTNAME] [-d DOT_DIR] [-I EXCL_PAT] [-S EXCL_PAT] [-s EXCL_PAT] [-t TAG] [-x EXCL_PAT]"
+ $PRINT "Usage: rcup [-CfhiKkqVv] [-B HOSTNAME] [-d DOT_DIR] [-I EXCL_PAT] [-S EXCL_PAT] [-s EXCL_PAT] [-t TAG] [-U EXCL_PAT] [-u EXCL_PAT] [-x EXCL_PAT]"
$PRINT "see rcup(1) and rcm(7) for more details"
exit $exit_code
@@ -192,10 +192,12 @@ handle_command_line() {
local hostname=
local generate=0
local args=$*
+ local undotted=
+ local never_undotted=
REPLACE_ALL=0
GENERATE=
- while getopts :CVqvfghikKI:x:S:s:t:d:B: opt; do
+ while getopts :CVqvfghikKI:x:S:s:U:u:t:d:B: opt; do
case "$opt" in
B) hostname="$OPTARG" ;;
C) always_copy=1 ;;
@@ -211,6 +213,8 @@ handle_command_line() {
t) arg_tags="$arg_tags $OPTARG" ;;
S) symlink_dirs="$symlink_dirs $OPTARG";;
s) never_symlink_dirs="$never_symlink_dirs $OPTARG";;
+ U) undotted="$undotted $OPTARG";;
+ u) never_undotted="$never_undotted $OPTARG";;
v) verbosity=$(($verbosity + 1)) ;;
V) version=1 ;;
x) excludes="$excludes $OPTARG" ;;
@@ -259,6 +263,13 @@ handle_command_line() {
for never_symlink_dir in $never_symlink_dirs; do
LS_ARGS="$LS_ARGS -s $never_symlink_dir"
done
+ for undot in $undotted; do
+ LS_ARGS="$LS_ARGS -U $undot"
+ done
+ for never_undot in $never_undotted; do
+ LS_ARGS="$LS_ARGS -u $never_undot"
+ done
+
LS_ARGS="$LS_ARGS -B $hostname $files"
$DEBUG "LS_ARGS: $LS_ARGS"