dotfiles

$HOME is where the <3 is
git clone git://git.alexkarle.com/dotfiles.git
Log | Files | Refs | README | LICENSE

commit 3443406c575228204bf73a9e578df9458e849f89 (patch)
parent 7a1ef860bf214ece9b14879a6e99474106e79f9e
Author: Alex Karle <alex@alexkarle.com>
Date:   Sun, 27 Feb 2022 12:01:54 -0500

bin: Add `bak` to temporarily rename files

This is helpful when troubleshooting things like module sourcing, etc.
For example, both my last commits needed to test that the nvim and tmux
configs worked both with and without local configs.

This could be done like so:

	$ nvim 	                        # works
	$ bak ~/.config/nvim/local.lua  # shift aside
	$ nvim                          # works
	$ bak ~/.config/nvim/local.lua  # revert

Diffstat:
Abin/bak | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/bin/bak b/bin/bak @@ -0,0 +1,22 @@ +#!/bin/sh +# bak -- move a file to file.bak (or back) +set -e +die() { + echo "$*" 1>&2 + exit 1 +} + +[ -z "$1" ] && die "usage: bak FILE" + +BAK="$1.bak" +if [ -e "$BAK" ] && [ -e "$1" ]; then + die "$1 and $BAK exist, unable to bak or unbak" +elif [ -e "$BAK" ]; then + mv "$BAK" "$1" + echo "$BAK -> $1" +elif [ -e "$1" ]; then + mv "$1" "$BAK" + echo "$1 -> $BAK" +else + die "Neither $1 nor $BAK exist, unable to bak or unbak" +fi