File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 1196
1196
}
1197
1197
#+end_src
1198
1198
1199
+ Well... after implementing this, I discovered `select`, which allows for these kinds of flows:
1200
+
1201
+ #+begin_src bash
1202
+ mute command -v fzf ||
1203
+ fzf() {
1204
+ local in=$(cat)
1205
+ for p in "${@}"; do
1206
+ [ "$p" = "-0" ] && [ "$(echo "$in" | wc -l)" -eq 1 ] && [ "" = "$in" ] && return 1
1207
+ [ "$p" = "-1" ] && [ "$(echo "$in" | wc -l)" -eq 1 ] && [ "" != "$in" ] && echo "$in" && return
1208
+ done
1209
+ select opt in $(echo "$in"); do
1210
+ [ -n "$opt" ] && break
1211
+ done >/dev/tty </dev/tty
1212
+ echo $opt
1213
+ }
1214
+ #+end_src
1215
+
1199
1216
** change loops for "mapping/reducing" functions
1200
1217
*** find
1201
1218
Many times we want to run the same operation or test to lots of
@@ -1641,6 +1658,9 @@ a kind of rails generators for these helpers
1641
1658
any eq_--help "$@" && usage
1642
1659
#+end_src
1643
1660
1661
+ All these last metaprogramming tricks are not thread safe, and even
1662
+ though it's mostly ok if you use them in isolation, maybe pipes or
1663
+ coprocs would mess up your inline functions.
1644
1664
1645
1665
* Interactive
1646
1666
** Save your small scripts
You can’t perform that action at this time.
0 commit comments