dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 1c2b4bf48b38f21928033de98842cf47604c5a3c
parent aef32197cd1ae38a62df83d097b6f0043beb830d
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Thu, 14 Mar 2019 15:18:36 +0100

Fix find for shell scripts, improve help text

Diffstat:
Mlinks/bin/fffs | 29+++++++++++++++++++----------
1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/links/bin/fffs b/links/bin/fffs @@ -11,22 +11,21 @@ plugindir="$confdir/lib" pluginfile="$confdir/plugins" function show_help { + echo "usage: ${0##*/} [OPTION] SHELL COMMAND" echo "${0##*/} is a fast and simple manager for shell plugins" - echo "usage: ${0##*/} [OPTIONS] SHELL OPERATION" echo "where SHELL can be 'bash' or 'zsh'." - echo "Valid COMMANDS are:" + echo "Valid COMMANDs are:" echo " init clone repositories specified in pluginfile" echo " update update all local plugin content" echo " clean remove all local plugin content" - echo "OPTIONS are one or more of the following:" + echo "Valid OPTIONs are:" echo " -h, --help show this message" echo " -v, --version show version and license information" echo echo "Set the plugin sources as git repository URLs in " echo "$pluginfile-zsh or $pluginfile-bash" - echo "${0##*/} will source all files from the repository root directories" - echo - echo "Add the generated sources file in the shell-rc file. For ~/.zshrc:" + echo "before running 'init'. Afterwards, add the generated sources file in " + echo "the shell-rc file. For ~/.zshrc:" echo " if [ -f \"\$HOME/.config/fffs/lib/zsh/sources\" ]; then" echo " . \"\$HOME/.config/fffs/lib/zsh/sources\"" echo " else" @@ -88,8 +87,18 @@ function check_if_source_in_shellrc { function init_sources { echo "Generating source file $plugindir/$shell/sources" echo "#!/usr/bin/env $shell" > "$plugindir/$shell/sources" - find "$plugindir/$shell/" -maxdepth 2 -type f -iname '*.zsh' \ - | sed 's/^/. /' >> "$plugindir/$shell/sources" + + if [[ "$shell" == "zsh" ]]; then + find "$plugindir/$shell/" -maxdepth 2 -type f \ + -iname '*.zsh' \ + | sed 's/^/. /' >> "$plugindir/$shell/sources" + elif [[ "$shell" == "bash" ]]; then + find "$plugindir/$shell/" -maxdepth 2 -type f \ + -iname '*.sh' -iname '*.bash' \ + | sed 's/^/. /' >> "$plugindir/$shell/sources" + else + die "Unknown shell $shell" + fi check_if_source_in_shellrc } @@ -107,7 +116,7 @@ function clean { ## Parse command-line arguments -[[ $# -lt 1 ]] && (show_help && exit 1) +[[ $# -lt 2 ]] && (show_help && exit 1) shell="" while :; do @@ -142,7 +151,7 @@ while :; do -v|--version) (show_version && exit 0) ;; - -?*) + ?*) die 'Error: Unknown option specified' ;; *) # No more options