diff --git a/q b/q index 19e98c8..10b59dd 100755 --- a/q +++ b/q @@ -115,7 +115,16 @@ run_command() { COMMAND="$2" FIRST=${COMMAND%%" "*} REST=${COMMAND#*" "} - SCRIPTS="$(get_scripts_for_cmd "$INPUT")" + if [ ! -z "$REST" ]; then + # This branch is taken in most cases when an existing + # item is selected in fzf + SCRIPTS="$(get_scripts_for_cmd "$REST")" + else + # In case when zero items have matched, but a command + # has support for a default action to take (e.g. creating + # a new entry) - use the actual user's input + SCRIPTS="$(get_scripts_for_cmd "$INPUT")" + fi if [ -z "$SCRIPTS" ] || \ [ "$(echo "$SCRIPTS" | wc -w)" -gt "1" ]; then echo "Scripts matched: $SCRIPTS"