~dricottone/my-utils

0fbc09c9d5b669b20fa0484715f1a1a2693eed9b — Dominic Ricottone 2 years ago 1aabb6e
Added core README; dropped one not-so-useful script
3 files changed, 31 insertions(+), 42 deletions(-)

M core/Makefile
A core/README.md
D core/git-set-remotes
M core/Makefile => core/Makefile +0 -2
@@ 8,7 8,6 @@ install:
	install -m755 ctdir $(BIN_DIR)/ctdir
	install -m755 debom $(BIN_DIR)/debom
	install -m755 enumerate $(BIN_DIR)/enumerate
	install -m755 git-set-remotes $(BIN_DIR)/git-set-remotes
	install -m755 mkbak $(BIN_DIR)/mkbak
	install -m755 rand $(BIN_DIR)/rand
	install -m755 rebom $(BIN_DIR)/rebom


@@ 34,7 33,6 @@ uninstall:
	rm $(BIN_DIR)/ctdir
	rm $(BIN_DIR)/debom
	rm $(BIN_DIR)/enumerate
	rm $(BIN_DIR)/git-set-remotes
	rm $(BIN_DIR)/mkbak
	rm $(BIN_DIR)/rand
	rm $(BIN_DIR)/rebom

A core/README.md => core/README.md +31 -0
@@ 0,0 1,31 @@
# core utilities

Tools for everyday living.


## Specification

Executable      |Description                                                   |Extra Dependencies
:---------------|:-------------------------------------------------------------|:-----------------
ctdir           |Count entries in a target directory(ies)
debom           |Remove BOM from a target file                                 |`bash`
enumerate       |Rename files in current directory into sequential numbers     |`bash`
mkbak           |Create a backup of a target file                              |`bash`
rand            |Get a random number within an inclusive range                 |`bash`, `shuf`
rebom           |Add BOM to a target file
rmold           |Delete old files
start-at        |After a pattern is matched, re-print                          |GNU or New (AT&T) `awk`
stop-at         |Re-print until a pattern is matched                           |GNU or New (AT&T) `awk`
unittest        |Wrapper around Python's `unittest` module                     |`python3`, GNU or New (AT&T) `awk`
vimsplit        |Open two files in split windows                               |`nvim`
whichcat        |Print all lines from a program
whiched         |Open a program with your editor
whichhead       |Print the first 10 lines from a program                       |`bash`
whichvi         |Open a program with your visual editor
wttr            |Wrapper around `wttr` to fix double-wide runes for some fonts |`wego`

*All* scripts support `-h` and `--help` for printing built-in documentation.


## To-Do


D core/git-set-remotes => core/git-set-remotes +0 -40
@@ 1,40 0,0 @@
#!/bin/sh

name="git-set-remotes"
version="1.0"
help_message=$(/usr/bin/cat <<-EOF
	Set all git remotes for my public repositories
	Usage: git-set-remotes
	Options:
	 -h, --help     print this message and exit
	 -q, --quiet    suppress error messages
	 -v, --version  print version number and exit
EOF
)

. /usr/local/lib/myminiparse.sh

error_msg() {
  if [ "$quiet" -eq 0 ]; then
    (>&2 /usr/bin/printf "%s: %s\n" "$name" "$1")
  fi
}

git_add_or_set() {
  if ! git remote add "$1" "$2" >/dev/null 2>&1; then
    error_msg "remote '${1}' already exists; resetting the URL"
    git remote set-url "$1" "$2" >/dev/null 2>&1
  fi
}

if [ ! -d .git ]; then
  error_msg "not a git repository"
  exit 1
fi

NAME="$(basename "$(pwd)")"

git_add_or_set "origin" "git:${NAME}.git"
git_add_or_set "github" "git@github.com:dricottone/${NAME}.git"
git_add_or_set "gitweb" "deploy-aws2:/var/git/${NAME}.git"