From 88fd9c416be0f5fe1e5fd48ba7c27d4d1e25261c Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 24 Feb 2020 03:39:44 -0800 Subject: Moved bbstartup into a script, renamed helper/ -> scripts/, and added bbshutdown script. Also tweaked some of the precedence. --- helpers/bbask | 31 ------------------------------- helpers/bbcmd | 11 ----------- helpers/bbconfirm | 9 --------- helpers/bbpause | 4 ---- helpers/bbpick | 39 --------------------------------------- helpers/bbtargets | 25 ------------------------- helpers/bbunscroll | 5 ----- 7 files changed, 124 deletions(-) delete mode 100755 helpers/bbask delete mode 100755 helpers/bbcmd delete mode 100755 helpers/bbconfirm delete mode 100755 helpers/bbpause delete mode 100755 helpers/bbpick delete mode 100755 helpers/bbtargets delete mode 100755 helpers/bbunscroll (limited to 'helpers') diff --git a/helpers/bbask b/helpers/bbask deleted file mode 100755 index ad446ec..0000000 --- a/helpers/bbask +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# A simple user-input asker. Result is output to stdout. -# Usage: ask [-1] [prompt [initial query]] -if [ "$1" = '-1' ]; then - # Get one character of input - tput civis >/dev/tty; - printf '\033[1m%s\033[0m' "$2" >/dev/tty; - stty -icanon -echo >/dev/tty 2>/dev/tty; - if [ "$(uname)" = "Darwin" ]; then - read -n 1 REPLY /dev/tty; - echo $REPLY - else - dd bs=1 count=1 2>/dev/null /dev/tty 2>/dev/tty - tput cvvis >/dev/tty -else - # Get a line of input - if command -v ask >/dev/null; then - ask --history=bb.hist --prompt="$(printf '%s\033[?25h' "$1")" --query="$2" - else - printf "\033[1m%s\033[0m" "$1" >/dev/tty - tput cvvis >/dev/tty - if [ "$(uname)" = "Darwin" ]; then - read -e REPLY /dev/tty - else - read REPLY /dev/tty - fi - echo $REPLY - fi -fi diff --git a/helpers/bbcmd b/helpers/bbcmd deleted file mode 100755 index fdc4e78..0000000 --- a/helpers/bbcmd +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -if [ $# -eq 0 ]; then cat >> $BBCMD; exit; fi -for arg; do - shift - if expr "$arg" : '^[^:]*:$' >/dev/null; then - if [ $# -gt 0 ]; then printf "$arg%s\\0" "$@" >> $BBCMD - else sed "s/\([^\\x00]\+\)/$arg\1/g" >> $BBCMD; fi - exit - fi - printf "%s\\0" "$arg" >> $BBCMD -done diff --git a/helpers/bbconfirm b/helpers/bbconfirm deleted file mode 100755 index cae1153..0000000 --- a/helpers/bbconfirm +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -# Ask for user confirmation -set -e -if command -v ask >/dev/null; then - ask -n "$(printf "$1Is that okay?\033[?25h")" -else - reply="$(bbask -1 "$(printf "$1\033[0;1mIs that okay? [y/N] ")")" - [ "$reply" != 'y' ] -fi diff --git a/helpers/bbpause b/helpers/bbpause deleted file mode 100755 index 6604fbd..0000000 --- a/helpers/bbpause +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# Pause before continuing -printf '\033[0;2m Press any key to continue...\033[0m' >/dev/tty -bbask -1 >/dev/null diff --git a/helpers/bbpick b/helpers/bbpick deleted file mode 100755 index 3316484..0000000 --- a/helpers/bbpick +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# Pick from the provided input -if [ -z "$PICKER" ]; then - if command -v fzf >/dev/null; then - PICKER=fzf - elif command -v fzy >/dev/null; then - PICKER=fzy - elif command -v ask >/dev/null; then - PICKER=ask - elif command -v dmenu >/dev/null; then - PICKER=dmenu - elif command -v pick >/dev/null; then - PICKER=pick - fi -fi - -case "$PICKER" in - fzf) - printf '\033[3A\033[?25h' >/dev/tty - fzf --read0 --height=4 --prompt="$(printf "$1")" - ;; - fzy) - printf '\033[3A\033[?25h' >/dev/tty - tr '\0' '\n' | fzy --lines=3 --prompt="$(printf "\033[1m$1\033[0m")" - ;; - ask) - ask --read0 --prompt="$(printf "$1\033[?25h")" - ;; - dmenu) - tr '\0' '\n' | dmenu -i -l 10 -p "$(printf "$1")" - ;; - pick) - printf '\033[?25h' >/dev/tty - tr '\0' '\n' | pick - ;; - *) - query="$(bbask "$1")" && grep -i -m1 "$(echo "$query" | sed 's;.;[^/&]*[&];g')" - ;; -esac diff --git a/helpers/bbtargets b/helpers/bbtargets deleted file mode 100755 index 1862ca0..0000000 --- a/helpers/bbtargets +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# If the user is doing something ambiguous, like selecting a bunch of files, -# moving the cursor off of those files, then doing an action, this will ask -# what they mean to target, then output either 'cursor' or 'selected'. -# Usage: targets "$BBCURSOR" "$@" -cursor="$1" -shift -if [ $# -gt 0 ]; then - for f in "$@"; do - if [ "$f" = "$cursor" ]; then - intended='Selected files' - break - fi - done -else - intended='Cursor file' -fi - -[ -z "$intended" ] && intended="$(printf '%s\0' 'Cursor file' 'Selected files' 'Both' | bbpick 'Which do you want to delete? ')" - -case "$intended" in - Cursor*) echo cursor ;; - Selected*) echo selected ;; - Both) echo both ;; -esac diff --git a/helpers/bbunscroll b/helpers/bbunscroll deleted file mode 100755 index 15102c4..0000000 --- a/helpers/bbunscroll +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -# Display text from the current line upward (instead of downward) -input="$(cat)" -printf "\\033[$(echo "$input" | wc -l)A\\033[J" >/dev/tty -echo "$input" -- cgit v1.2.3