From 5963249c0acf290005ffb13fa90423eabf0f075f Mon Sep 17 00:00:00 2001 From: Sam Morrison Date: Mon, 19 Jan 2015 12:15:26 +0900 Subject: [PATCH 1/4] Rename function pass to passgen. Define alias pass if pass command (password store) is not installed or BASH_IT_LEGACY_PASS is true. --- plugins/available/base.plugin.bash | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index f47b9c7b..c54fdd4b 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -39,7 +39,7 @@ function pickfrom () head -n $n $file | tail -1 } -function pass () +function passgen () { about 'generates random password from dictionary words' param 'optional integer length' @@ -53,6 +53,13 @@ function pass () echo "Without (use this as the pass): $(echo $pass | tr -d ' ')" } +# Create alias pass to passgen when pass isn't installed or +# BASH_IT_LEGACY_PASS is true. +if ! command -v pass &>/dev/null || [ "$BASH_IT_LEGACY_PASS" == 1 ] +then + alias pass=passgen +fi + function pmdown () { about 'preview markdown file in a browser' From f1f250f7b8e02f00db9543eee0b6fe4cc1617f67 Mon Sep 17 00:00:00 2001 From: Sam Morrison Date: Mon, 19 Jan 2015 12:28:35 +0900 Subject: [PATCH 2/4] corrected passgen example text and default --- plugins/available/base.plugin.bash | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index c54fdd4b..f0aa155d 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -44,13 +44,13 @@ function passgen () about 'generates random password from dictionary words' param 'optional integer length' param 'if unset, defaults to 4' - example '$ pass' - example '$ pass 6' + example '$ passgen' + example '$ passgen 6' group 'base' - local i pass length=${1:-4} + local i passgen length=${1:-4} pass=$(echo $(for i in $(eval echo "{1..$length}"); do pickfrom /usr/share/dict/words; done)) echo "With spaces (easier to memorize): $pass" - echo "Without (use this as the pass): $(echo $pass | tr -d ' ')" + echo "Without (use this as the password): $(echo $pass | tr -d ' ')" } # Create alias pass to passgen when pass isn't installed or From bfe25807a7acb47168655f2dbdb3e0e4d79445fb Mon Sep 17 00:00:00 2001 From: Sam Morrison Date: Mon, 19 Jan 2015 13:05:46 +0900 Subject: [PATCH 3/4] using bash-it boolean check convention --- plugins/available/base.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index f0aa155d..850cdb46 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -55,7 +55,7 @@ function passgen () # Create alias pass to passgen when pass isn't installed or # BASH_IT_LEGACY_PASS is true. -if ! command -v pass &>/dev/null || [ "$BASH_IT_LEGACY_PASS" == 1 ] +if ! command -v pass &>/dev/null || [ "$BASH_IT_LEGACY_PASS" = true ] then alias pass=passgen fi From 4ce1f6f77153f640896e60c48a1b39bc56ce54a3 Mon Sep 17 00:00:00 2001 From: Sam Morrison Date: Tue, 20 Jan 2015 18:46:44 +0900 Subject: [PATCH 4/4] rename local variable passgen back to pass --- plugins/available/base.plugin.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index 850cdb46..10f5a2bf 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -47,7 +47,7 @@ function passgen () example '$ passgen' example '$ passgen 6' group 'base' - local i passgen length=${1:-4} + local i pass length=${1:-4} pass=$(echo $(for i in $(eval echo "{1..$length}"); do pickfrom /usr/share/dict/words; done)) echo "With spaces (easier to memorize): $pass" echo "Without (use this as the password): $(echo $pass | tr -d ' ')"