summaryrefslogtreecommitdiff
path: root/Biz/Ide/ns.sh
blob: a56ed89754edc7622991bfa7c296fd42ca6ca920 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
set -euo pipefail
nss="fd --color=always --exclude=_ -t f . \"${CODEROOT:?}\" | sed \"s,${CODEROOT:?}/*,,g\""
keybindings=$(cat <<EOF
repl {}:enter
repl --bash {}:alt+enter
edit {} with $EDITOR:tab
lint -f {}:alt+c
bild {}:alt+space
bild --test {}:alt+t
exec {}:alt+e
ship {}:ctrl+space
create new namespace:alt+n
change preview window:alt+0-6
resize preview window:ctrl+/
EOF
)
fzf_flags=(
  --ansi
  --bind "focus:transform-preview-label:echo {}"
  --bind "?:change-preview(column -o ' -> ' -s':' -t <<< \"$keybindings\")"
  --bind "alt-n:execute(touch {q})+reload($nss)"
  --bind "alt-space:execute(bild {} ; read -p [fin])"
  --bind "tab:execute($EDITOR {})"
  --bind "alt-c:execute(lint -f {} ; read -p [fin])"
  --bind "enter:execute(repl.sh {})"
  --bind "alt-enter:execute(repl.sh --bash {})"
  --bind "ctrl-space:execute(ship.sh {} ; read -p [fin])"
  --bind "alt-t:execute(bild {} ; run.sh {} test ; read -p [fin])"
  --bind "ctrl-/:change-preview-window(right,88|right,70%|hidden|)"
  --bind "alt-0:change-preview(bat -p --color=always {})"
  --bind "alt-1:change-preview(git log --color=always --date=relative --abbrev-commit --pretty=format:'%Cred%h%Creset %s / %an %Creset%C(yellow)%d%Creset%Cgreen(%cr)%Creset' -- {})"
  --bind "alt-2:change-preview(git log --color=always {})"
  --bind "alt-3:change-preview(git log --color=always -p {})"
  --bind "alt-4:change-preview(git blame -c --date=short {})"
  --bind "alt-5:change-preview(git log --pretty=short {} | git shortlog -nse)"
  --bind "alt-6:change-preview(git log --pretty=short {} | git shortlog)"
  --bind "backward-eof:abort"
  --bind "pgup:preview-page-up"
  --bind "pgdn:preview-page-down"
  --header-first
  --header="? for keybindings"
  --border=top
  --border-label="$(lolcat -f <<< "hack a namespace")"
  --color=label:italic
  --preview-window="bottom,80%"
  --preview "bat -p --color=always {}"
)
sh -c "$nss" | fzf "${fzf_flags[@]}"