aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/password57
-rw-r--r--etc/bash/rc5
2 files changed, 57 insertions, 5 deletions
diff --git a/bin/password b/bin/password
new file mode 100755
index 0000000..718ba1c
--- /dev/null
+++ b/bin/password
@@ -0,0 +1,57 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ cat <<-'EOF'
+ Usage:
+ password [LENGTH]
+ password -h
+ EOF
+}
+
+help() {
+ cat <<-'EOF'
+
+ Options:
+ -h, --help show this message
+
+ LENGTH the size of the password (default: 99)
+ EOF
+}
+
+for flag in "$@"; do
+ case "$flag" in
+ --)
+ break
+ ;;
+ --help)
+ usage
+ help
+ exit
+ ;;
+ *)
+ ;;
+ esac
+done
+
+while getopts 'h' flag; do
+ case "$flag" in
+ h)
+ usage
+ help
+ exit
+ ;;
+ *)
+ usage >&2
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+
+LENGTH="${1-99}"
+tr -cd '[:alnum:]' < /dev/random |
+ fold -w "$LENGTH" |
+ head -n1 |
+ tr -d '\n'
diff --git a/etc/bash/rc b/etc/bash/rc
index 96c9312..8588089 100644
--- a/etc/bash/rc
+++ b/etc/bash/rc
@@ -213,11 +213,6 @@ cm() {
-genpassword() {
- length="${1-99}"
- tr -cd '[:alnum:]' < /dev/urandom | fold -w "$length" | head -n1
-}
-
deps() {
cd ~/dev/libre/package-repository/ || return 1
rm -f public/dependencies.svg