From 47287f3b218e7f30e2ce5b1bdd7f6b0f3fac41ee Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Thu, 16 Dec 2021 07:57:39 -0500 Subject: Add hoog.sh, improve ide scripts --- Biz/Ide/ftags.sh | 30 ++++++++++++++---------- Biz/Ide/hoog.sh | 14 +++++++++++ Biz/Ide/init_tags.sh | 21 ++++++++--------- Biz/Ide/ns | 65 ++++++++++++++++++++++++++-------------------------- 4 files changed, 75 insertions(+), 55 deletions(-) create mode 100755 Biz/Ide/hoog.sh (limited to 'Biz/Ide') diff --git a/Biz/Ide/ftags.sh b/Biz/Ide/ftags.sh index 2687e9a..4b8396b 100755 --- a/Biz/Ide/ftags.sh +++ b/Biz/Ide/ftags.sh @@ -1,13 +1,19 @@ #!/usr/bin/env bash -# ftags - search ctags -set -euo pipefail -tags=$BIZ_ROOT/tags -tag_search=$( - awk 'BEGIN { FS="\t" } !/^!/ {print toupper($4)"\t"$1"\t"$2"\t"$3}' $tags \ - | cut -c1-80 \ - | fzf --nth=1,2 -) -${EDITOR:-vim} \ - $(cut -f3 <<< "$tag_search") \ - -c "set nocst" \ - -c "silent tag $(cut -f2 <<< "$tag_search")" +# +# search tags with fzf +# + set -euo pipefail + tags=$BIZ_ROOT/tags + tag_search=$( + awk 'BEGIN { FS="\t" } !/^!/ {print toupper($4)"\t"$1"\t"$2"\t"$3}' $tags \ + | cut -c1-80 \ + | fzf \ + --nth=1,2 \ + --preview-window=down \ + --preview "rg --ignore-case --pretty --context 2 --word-regexp {+2}" + ) + ${EDITOR:-vim} \ + $(cut -f3 <<< "$tag_search") \ + -c "set nocst" \ + -c "silent tag $(cut -f2 <<< "$tag_search")" +## diff --git a/Biz/Ide/hoog.sh b/Biz/Ide/hoog.sh new file mode 100755 index 0000000..5379e54 --- /dev/null +++ b/Biz/Ide/hoog.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# +# search hoogle with fzf +# + set -euo pipefail + HOOG="hoogle search --count=200" + export FZF_DEFAULT_COMMAND="$HOOG $@" + fzf \ + --preview-window=down \ + --preview "hoogle search --link --info {+2}" \ + --bind "change:reload:$HOOG {q} || true" \ + --print-query \ + --ansi +## diff --git a/Biz/Ide/init_tags.sh b/Biz/Ide/init_tags.sh index 10e9c85..0efc0ed 100755 --- a/Biz/Ide/init_tags.sh +++ b/Biz/Ide/init_tags.sh @@ -1,13 +1,12 @@ #!/usr/bin/env bash +# # fast-tags wrapper to generate tags automatically if there are none. - -flags=( - --fully-qualified -) -fns=$@ -if [[ ! -r tags ]]; then - echo Generating tags from scratch... - exec fast-tags $flags -R . -else - exec fast-tags $flags $fns -fi +# + fns=$@ + if [[ ! -r tags ]]; then + echo Generating tags from scratch... + exec fast-tags $flags -R . + else + exec fast-tags $fns + fi +## diff --git a/Biz/Ide/ns b/Biz/Ide/ns index 6d27d46..aa4beac 100755 --- a/Biz/Ide/ns +++ b/Biz/Ide/ns @@ -1,33 +1,34 @@ #!/usr/bin/env bash - -if [[ $NOUN == "" ]] -then - export NOUN=$(fd --exclude=_ -t f . $BIZ_ROOT | fzf) -fi - -if [[ $VERB == "" ]] -then - export VERB=$(fzf <<< $(sed 's/ /\n/g' <<< "edit bild push ship lint")) -fi - -$VERB $NOUN - -printf "\nn:\tchange ns\nv:\tchange verb\nb:\tchange both\n^C:\texit\nelse:\tcontinue\n" -read -p " ns> " -n 1 input - -if [[ $input == "v" ]] -then - unset VERB - $0 -elif [[ $input == "n" ]] -then - unset NOUN - $0 -elif [[ $input == "b" ]] -then - unset NOUN - unset VERB - $0 -else - $0 -fi +## + if [[ $NOUN == "" ]] + then + export NOUN=$(fd --exclude=_ -t f . $BIZ_ROOT | fzf) + fi +## + if [[ $VERB == "" ]] + then + export VERB=$(fzf <<< $(sed 's/ /\n/g' <<< "edit bild push ship lint")) + fi +## + $VERB $NOUN +## + printf "\nn:\tchange ns\nv:\tchange verb\nb:\tchange both\n^C:\texit\nelse:\tcontinue\n" + read -p " ns> " -n 1 input +## + if [[ $input == "v" ]] + then + unset VERB + $0 + elif [[ $input == "n" ]] + then + unset NOUN + $0 + elif [[ $input == "b" ]] + then + unset NOUN + unset VERB + $0 + else + $0 + fi +## -- cgit v1.2.3