diff --git a/README.md b/README.md index 363fb3c..3297414 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ # multiple_scripts Multiple scripts that are useful but don't deserve their own repository. -## mansearch.sh +This is often a repository when I work on small ideas until they're big enough +to deserve thier own repo and README. This readme may very well be outdated +or inaccurate! -Uses fzf and such to search both manpages and tldr and cheatsheets with preview. Run -mansearch -p to update database preemptively. +## sr.sh + +A transparent wrapper for surfraw that utilizes fzf ## ytube.sh @@ -26,7 +29,7 @@ Create a sidebar (e.g. for reading manpages) and kill when done. ## tmux_topbar.sh -Create a vertical split (it's actually a bottombar) and kill when done. +Create a vertical split and kill when done. ## briefing.sh diff --git a/sr.sh b/sr.sh new file mode 100755 index 0000000..ca9b3a8 --- /dev/null +++ b/sr.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +############################################################################## +# +# sr.sh +# Wrapper for surfraw using fzf but able to be dropped inline +# (c) Steven Saus 2020 +# Licensed under the MIT license +# +############################################################################## + + +AllVars="${@}" +FirstVar="${1}" +SecondVar="${2}" +Binary=$(which surfraw) + +# Check if -g was passed to it for graphical browser + +if [[ "${FirstVar}" == "-g" ]];then + FirstVar="${SecondVar}" +fi + +# read in array of elvi +readarray -t sr_elvi < <(sr -elvi | awk '{print $1}') + +# Was the elvi specified on the command line? +if [[ " ${sr_elvi[@]} " =~ " ${FirstVar} " ]]; then + CommandString=$(echo "${Binary} ${AllVars}") + eval "${CommandString}" + +fi + +# use fzf to determine which elvi to use +if [[ ! " ${sr_elvi[@]} " =~ " ${FirstVar} " ]]; then + Elvi=$(sr -elvi | fzf --multi | awk '{print $1}') + + # If nothing selected, assume it's the default and pass it all to sr + if [ -z "${Elvi}" ];then + CommandString=$(echo "${Binary} ${AllVars}") + eval "${CommandString}" + else + for e in $Elvi;do + echo "Searching ${e%}..." + CommandString=$(echo "${Binary} ${e} ${AllVars}") + eval "${CommandString}" + done + fi +fi diff --git a/tmux_devour.sh b/tmux_devour.sh index a3ff27f..7c77eb6 100755 --- a/tmux_devour.sh +++ b/tmux_devour.sh @@ -1,12 +1,14 @@ #!/bin/bash +############################################################################## +# +# tmux-devour +# (c) Steven Saus 2020 +# Licensed under the MIT license +# +############################################################################## + -#maybe use this as a setup for those programs and have a permanent sidebar? -#tmux send-keys -t "%74" "chafa " "/home/steven/downloads/images/big_keys_for_logo.jpg" "C-m" -# See the space!!! -#replaces man command - makes help a fallback -# use pick to deal with the output better -#TOD c_tmux=$(env | grep -c TMUX) if [ $c_tmux -gt 0 ];then @@ -20,15 +22,7 @@ command2=$(echo "eval \"${command}\" ; tmux kill-pane -t ${c_pane}") tmux resize-pane -Z -t "$c_pane" tmux send-keys -t "$c_pane" "$command2" C-m + else + eval "$@" fi - -# if [ $c_tmux -gt 0 ];then -# tmux kill-pane -t "$c_pane" -# fi - - - -# Is it tmux? -# Does the sidebar already exist in this window? -# if not, create sidebar and export variable diff --git a/tmux_sidebar.sh b/tmux_sidebar.sh index 39e5eda..b0f09a6 100755 --- a/tmux_sidebar.sh +++ b/tmux_sidebar.sh @@ -1,12 +1,14 @@ #!/bin/bash +############################################################################## +# +# tmux-sidebar +# (c) Steven Saus 2020 +# Licensed under the MIT license +# +############################################################################## + -#maybe use this as a setup for those programs and have a permanent sidebar? -#tmux send-keys -t "%74" "chafa " "/home/steven/downloads/images/big_keys_for_logo.jpg" "C-m" -# See the space!!! -#replaces man command - makes help a fallback -# use pick to deal with the output better -#TOD c_tmux=$(env | grep -c TMUX) if [ $c_tmux -gt 0 ];then @@ -21,16 +23,7 @@ command2=$(echo "eval \"${command}\" ; tmux kill-pane -t ${c_pane}") tmux send-keys -t "$c_pane" "$command2" C-m tmux last-pane - #tmux send-keys -t "$o_pane" C-o C-m + else + eval "$@" fi - -# if [ $c_tmux -gt 0 ];then -# tmux kill-pane -t "$c_pane" -# fi - - - -# Is it tmux? -# Does the sidebar already exist in this window? -# if not, create sidebar and export variable diff --git a/tmux_topbar.sh b/tmux_topbar.sh index 5c20d9c..04643e2 100755 --- a/tmux_topbar.sh +++ b/tmux_topbar.sh @@ -1,12 +1,13 @@ #!/bin/bash +############################################################################## +# +# tmux-topbar +# (c) Steven Saus 2020 +# Licensed under the MIT license +# +############################################################################## -#maybe use this as a setup for those programs and have a permanent sidebar? -#tmux send-keys -t "%74" "chafa " "/home/steven/downloads/images/big_keys_for_logo.jpg" "C-m" -# See the space!!! -#replaces man command - makes help a fallback -# use pick to deal with the output better -#TOD c_tmux=$(env | grep -c TMUX) if [ $c_tmux -gt 0 ];then @@ -22,16 +23,6 @@ command2=$(echo "eval \"${command}\" ; tmux kill-pane -t ${c_pane}") tmux send-keys -t "$c_pane" "$command2" C-m tmux last-pane - #tmux send-keys -t "$o_pane" C-o C-m + else + eval "$@" fi - - -# if [ $c_tmux -gt 0 ];then -# tmux kill-pane -t "$c_pane" -# fi - - - -# Is it tmux? -# Does the sidebar already exist in this window? -# if not, create sidebar and export variable