diff --git a/base/arch-desktop/bin/urxvt-app-launcher b/base/arch-desktop/bin/urxvt-app-launcher index 586ce5ef..20004f6c 100755 --- a/base/arch-desktop/bin/urxvt-app-launcher +++ b/base/arch-desktop/bin/urxvt-app-launcher @@ -1,4 +1,4 @@ #!/usr/bin/env bash xdotool search --onlyvisible --classname urxvt-fuzzy windowkill xdotool search --classname urxvt-fuzzy windowmap \ - || urxvt -name urxvt-fuzzy -geometry 80x18 -e $SHELL -c fzf-apps + || urxvt -name urxvt-fuzzy -geometry 80x18 -e $SHELL -c sk-apps diff --git a/base/arch-desktop/bin/urxvt-pass-manager b/base/arch-desktop/bin/urxvt-pass-manager index 7bbb0360..ae1b061e 100755 --- a/base/arch-desktop/bin/urxvt-pass-manager +++ b/base/arch-desktop/bin/urxvt-pass-manager @@ -1,7 +1,7 @@ #!/usr/bin/env zsh # -# Opens fzf-pass in a transient popup window and temporary tmux session, +# Opens sk-pass in a transient popup window and temporary tmux session, # recreating this window if necessary. # @@ -24,6 +24,6 @@ bspc monitor -f primary urxvt -name urxvt-fuzzy \ -geometry 100x16 \ -e $SHELL \ - -c "fzf-pass $@ $url" + -c "sk-pass $@ $url" [[ -n $win ]] && xdotool windowactivate $win diff --git a/bin/shekel b/bin/shekel index 496d1ca6..108438b5 100755 --- a/bin/shekel +++ b/bin/shekel @@ -5,8 +5,7 @@ A shell script that converts one currency to another. Usage: shekel [-rh] AMOUNT FROM TO [TO ...] -FROM and TO are either currency codes or a fuzzy substring (requires iterfzf and -fzf). +FROM and TO are currency codes. Examples: shekel 200 USD CAD diff --git a/bin/spell b/bin/spell index ae2ebb56..28946bcc 100755 --- a/bin/spell +++ b/bin/spell @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# Find the correct spelling of a word. Uses (and requires) fzf to select the +# Find the correct spelling of a word. Uses (and requires) skim to select the # correct word. This output can be piped to something like dict to find # definitions/synonyms. # -# Requires: aspell, fzf +# Requires: aspell, skim # Usage: spell mispeling # Example: dict $(spell mispeling) @@ -13,8 +13,8 @@ if [[ "$result" == '*' ]]; then echo "$@" else words=$(echo "$result" | sed $'s/[:,] /\\\n/g' | tail -n +2) - if (( $(wc -l <<< "$words") > 1 )) && command -v 'fzf' >/dev/null; then - fzf <<< "$words" + if (( $(wc -l <<< "$words") > 1 )) && command -v sk >/dev/null; then + sk <<< "$words" else echo "$words" fi diff --git a/bin/sup b/bin/sup index bce09803..6aa077d8 100755 --- a/bin/sup +++ b/bin/sup @@ -1,7 +1,7 @@ #!/usr/bin/env zsh # Performs an online search. Uses the last used provider, otherwise prompts for -# one with fzf. +# one with skim. provider="$1"; shift query="$*" @@ -19,7 +19,7 @@ providers+=('Youtube' 'https://youtube.com/results?aq=f&oq=&search_query=%s') providers+=('Wolfram alpha' 'https://wolframalpha.com/input/?i=%s') providers+=('Wikipedia' 'https://wikipedia.org/search-redirect.php?language=en&go=Go&search=%s') -pick=$(printf "%s\n" "${(@k)providers}" | fzf --query="$provider" --prompt='provider > ' -1 -0) +pick=$(printf "%s\n" "${(@k)providers}" | sk --query="$provider" --prompt='provider > ' -1 -0) if [[ -z $pick ]]; then >&2 echo 'No provider selected. Aborting.' exit 1 diff --git a/shell/fzf/aliases.zsh b/shell/fzf/aliases.zsh deleted file mode 100644 index d3a006fb..00000000 --- a/shell/fzf/aliases.zsh +++ /dev/null @@ -1,5 +0,0 @@ -alias fgcf='noglob git commit -S --fixup `fzf-git-sha`' -alias fgl=fzf-git-log - -alias bm=fzf-browser-bookmarks -alias hist=fzf-browser-history diff --git a/shell/fzf/bin/fzf-mpc b/shell/fzf/bin/fzf-mpc deleted file mode 100755 index adbc5d24..00000000 --- a/shell/fzf/bin/fzf-mpc +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -# -# Select and play a song from the current playlist (using fzf) -# - -set -e - -song=$(mpc -f "%position%) %artist% - %title%" playlist) -song_index=$(fzf --query="$1" --select-1 --exit-0 --prompt='play > ' <<<"$song" | sed -n 's/^\([0-9]\+\)).*/\1/p') -[[ -n $song_index ]] && mpc -q play "$song_index" diff --git a/shell/fzf/env.zsh b/shell/fzf/env.zsh deleted file mode 100644 index 6541bd26..00000000 --- a/shell/fzf/env.zsh +++ /dev/null @@ -1 +0,0 @@ -export FZF_DEFAULT_OPTS='--reverse --color=16,fg+:2,bg+:0,hl:4,hl+:4,prompt:4,pointer:8' \ No newline at end of file diff --git a/shell/fzf/_init b/shell/sk/_init similarity index 50% rename from shell/fzf/_init rename to shell/sk/_init index 79d82df5..4048e84d 100755 --- a/shell/fzf/_init +++ b/shell/sk/_init @@ -3,9 +3,9 @@ source ${0:A:h}/../../deploy install() { case $(_os) in - macos) brew install fzf ;; - arch) sudo pacman --needed --noconfirm -S fzf ;; - debian) sudo apt-get install -y fzf ;; + macos) brew install sbdchd/skim/skim ;; + arch) pacaur --needed --noconfirm -S skim ;; + debian) sudo apt-get install -y skim ;; esac } diff --git a/shell/sk/aliases.zsh b/shell/sk/aliases.zsh new file mode 100644 index 00000000..9a49f064 --- /dev/null +++ b/shell/sk/aliases.zsh @@ -0,0 +1,5 @@ +alias skgcf='noglob git commit -S --fixup `skim-git-sha`' +alias skgl=skim-git-log + +alias bm=skim-browser-bookmarks +alias hist=skim-browser-history diff --git a/shell/fzf/bin/fzf-apps b/shell/sk/bin/sk-apps similarity index 81% rename from shell/fzf/bin/fzf-apps rename to shell/sk/bin/sk-apps index 1740f791..bf619e41 100755 --- a/shell/fzf/bin/fzf-apps +++ b/shell/sk/bin/sk-apps @@ -1,20 +1,21 @@ #!/usr/bin/env bash -# Uses fzf as an application launcher. +# Uses skim as an application launcher. # -# Requires: fzf, lnch +# Requires: skim, lnch + +_do_sk() { sk --prompt='open > '; } -FZF_DEFAULT_OPTS="--prompt='open > ' $FZF_DEFAULT_OPTS" case $OSTYPE in darwin*) - cmd=$(find -L {,~}/Applications -iname '*.app' -maxdepth 2 -type d 2>/dev/null | sort -u | fzf) + cmd=$(find -L {,~}/Applications -iname '*.app' -maxdepth 2 -type d 2>/dev/null | sort -u | _do_sk) [[ -n $cmd ]] && open "$cmd" ;; linux*) - cmd=$(echo -n "$PATH" | xargs -d: -I{} -r -- find -L {} -maxdepth 1 -mindepth 1 -type f -executable -printf '%P\n' 2>/dev/null | sort -u | fzf) + cmd=$(echo -n "$PATH" | xargs -d: -I{} -r -- find -L {} -maxdepth 1 -mindepth 1 -type f -executable -printf '%P\n' 2>/dev/null | sort -u | _do_sk) if [[ -z $cmd ]]; then exit - elif [[ $cmd == fzf-* ]]; then + elif [[ $cmd == sk-* ]]; then $cmd elif ! command -v lnch >/dev/null; then >&2 echo "lnch not installed, run 'go get github.com/oem/lnch'" diff --git a/shell/fzf/bin/fzf-browser-bookmarks b/shell/sk/bin/sk-browser-bookmarks similarity index 79% rename from shell/fzf/bin/fzf-browser-bookmarks rename to shell/sk/bin/sk-browser-bookmarks index 69746c72..b4872342 100755 --- a/shell/fzf/bin/fzf-browser-bookmarks +++ b/shell/sk/bin/sk-browser-bookmarks @@ -1,14 +1,14 @@ #!/usr/bin/env bash -# Interactively select (in fzf) bookmarks to open from Firefox or +# Interactively select (in skim) bookmarks to open from Firefox or # Chrome/Chromium (depends on $BROWSER). Should work on Linux and MacOS. # # requires: sqlite3, jq (if you use chrome/chromium) [[ $OSTYPE == linux* ]] && open='xdg-open' || open='open' -_do_fzf() { - for url in $(awk -F "$1" '{printf "%s, %s\n", $1, $2}' | fzf --prompt='bookmarks > ' --multi | sed 's#.*\(https*://\)#\1#'); do +_do_sk() { + for url in $(awk -F "$1" '{printf "%s, %s\n", $1, $2}' | skim --prompt='bookmarks > ' --multi | sed 's#.*\(https*://\)#\1#'); do $open "$url" & done } @@ -22,7 +22,7 @@ case ${BROWSER:-firefox} in "SELECT DISTINCT mb.title, mp.url FROM moz_bookmarks mb \ INNER JOIN moz_places mp ON mp.id = mb.fk \ WHERE mb.type = 1 AND mb.title IS NOT NULL \ - ORDER BY mp.frecency DESC" | _do_fzf "$sep" + ORDER BY mp.frecency DESC" | _do_sk "$sep" break fi done @@ -33,7 +33,7 @@ case ${BROWSER:-firefox} in if [[ -f "$dir/Bookmarks" ]]; then jq -r '.. | [.name, .url]? | @tsv' "$dir/Bookmarks" | \ sed '/^[ \t]*$/d;/\t$/d;/\tchrome:\/\//d' | \ - _do_fzf "\t" + _do_sk "\t" break fi done diff --git a/shell/fzf/bin/fzf-browser-history b/shell/sk/bin/sk-browser-history similarity index 74% rename from shell/fzf/bin/fzf-browser-history rename to shell/sk/bin/sk-browser-history index 29e5e53e..0f4b4953 100755 --- a/shell/fzf/bin/fzf-browser-history +++ b/shell/sk/bin/sk-browser-history @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Interactively select (in fzf) an url from Firefox/Chrome/Chromium history to +# Interactively select (in skim) an url from Firefox/Chrome/Chromium history to # open in your browser (depends on $BROWSER). Should work on Linux and MacOS. # # requires: sqlite3 @@ -8,8 +8,8 @@ sep='{{::}}' [[ $OSTYPE == linux* ]] && open='xdg-open' || open='open' -_do_fzf() { - for url in $(awk -F "$sep" '{printf "%s, %s\n", $1, $2}' | fzf --prompt='history > ' --multi | sed 's#.*\(https*://\)#\1#'); do +_do_skim() { + for url in $(awk -F "$sep" '{printf "%s, %s\n", $1, $2}' | skim --prompt='history > ' --multi | sed 's#.*\(https*://\)#\1#'); do $open "$url" & done } @@ -21,7 +21,7 @@ case ${BROWSER:-firefox} in sqlite3 -separator $sep "$dir/places.sqlite" \ "SELECT DISTINCT title, url FROM moz_places \ WHERE title IS NOT NULL \ - ORDER BY last_visit_date DESC" | _do_fzf + ORDER BY last_visit_date DESC" | _do_skim break fi done @@ -32,7 +32,7 @@ case ${BROWSER:-firefox} in cp -f "$dir/History" "/tmp/_h" sqlite3 -separator $sep "/tmp/_h" \ "SELECT substr(title, 1, $((COLUMNS / 3))), url \ - FROM urls ORDER BY last_visit_time DESC" | _do_fzf + FROM urls ORDER BY last_visit_time DESC" | _do_skim break fi done diff --git a/shell/fzf/bin/fzf-git-log b/shell/sk/bin/sk-git-log similarity index 65% rename from shell/fzf/bin/fzf-git-log rename to shell/sk/bin/sk-git-log index 32737416..65e05a98 100755 --- a/shell/fzf/bin/fzf-git-log +++ b/shell/sk/bin/sk-git-log @@ -1,9 +1,9 @@ #!/usr/bin/env bash git log --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$@" | \ - fzf --ansi --no-sort --tiebreak=index --bind=ctrl-s:toggle-sort \ - --bind "ctrl-m:execute: + sk --ansi --no-sort --tiebreak=index --bind=ctrl-s:toggle-sort \ + --bind "ctrl-m:execute: (grep -o '[a-f0-9]\{7\}' | head -1 | - xargs -I % sh -c 'git show --color=always % | less -R') << 'FZF-EOF' + xargs -I % sh -c 'git show --color=always % | less -R') << 'SK-EOF' {} -FZF-EOF" +SK-EOF" diff --git a/shell/fzf/bin/fzf-git-sha b/shell/sk/bin/sk-git-sha similarity index 66% rename from shell/fzf/bin/fzf-git-sha rename to shell/sk/bin/sk-git-sha index a9081dca..aa59e3ee 100755 --- a/shell/fzf/bin/fzf-git-sha +++ b/shell/sk/bin/sk-git-sha @@ -3,9 +3,9 @@ # Retrieves a git commit's SHA, useful for a variety of git commands. # # Examples: -# + git checkout `fzf-git-sha` -# + git commit --fixup `fzf-git-sha` +# + git checkout `sk-git-sha` +# + git commit --fixup `sk-git-sha` commits=$(git log --color=always --abbrev-commit --reverse --format="%C(auto)%h%d %s %C(black)%C(bold)%cr") && - commit=$(echo "$commits" | fzf --tac +s +m -e --ansi) && + commit=$(echo "$commits" | sk --tac --no-sort -e --ansi) && echo -n $(echo "$commit" | sed "s/ .*//") diff --git a/shell/fzf/bin/fzf-kill b/shell/sk/bin/sk-kill similarity index 70% rename from shell/fzf/bin/fzf-kill rename to shell/sk/bin/sk-kill index 55489acc..5dc99949 100755 --- a/shell/fzf/bin/fzf-kill +++ b/shell/sk/bin/sk-kill @@ -2,7 +2,7 @@ # Interactively select a process to kill. -pid=$(ps -ef | sed 1d | fzf -m | awk '{print $2}') +pid=$(ps -ef | sed 1d | sk -m | awk '{print $2}') if [[ -n $pid ]]; then xargs kill -${1:-9} <<< "$pid" diff --git a/shell/sk/bin/sk-mpc b/shell/sk/bin/sk-mpc new file mode 100755 index 00000000..8d364a63 --- /dev/null +++ b/shell/sk/bin/sk-mpc @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# +# Select and play a song from the current playlist (using skim) +# + +set -e + +song=$(mpc -f "%position%) %artist% - %title%" playlist) +song_index=$(sk --query="$1" --select-1 --exit-0 --prompt='play > ' <<<"$song" | sed -n 's/^\([0-9]\+\)).*/\1/p') +[[ -n $song_index ]] && mpc -q play "$song_index" diff --git a/shell/fzf/bin/fzf-pass b/shell/sk/bin/sk-pass similarity index 81% rename from shell/fzf/bin/fzf-pass rename to shell/sk/bin/sk-pass index 4c52d263..5e42b17c 100755 --- a/shell/fzf/bin/fzf-pass +++ b/shell/sk/bin/sk-pass @@ -2,9 +2,9 @@ # # Prompts for a pass entry, then for a specific field. Similar to passmenu, but -# uses fzf, and can resume from a previous session. +# uses sk, and can resume from a previous session. # -# Example: fzf-pass [RESUME] +# Example: sk-pass [RESUME] # set -e @@ -18,13 +18,12 @@ url=$@ LAST_ENTRY_FILE=/tmp/_upm if [[ -n $resume && -f $LAST_ENTRY_FILE ]]; then entry="$(<$LAST_ENTRY_FILE)" - last=1 else prefix=${PASSWORD_STORE_DIR-~/.password-store} password_files=( "$prefix"/**/*.gpg ) password_files=( "${password_files[@]#"$prefix"/}" ) password_files=( "${password_files[@]%.gpg}" ) - entry=$(printf "%s\n" "${password_files[@]}" | fzf --query="$url" --prompt='pass > ') + entry=$(printf "%s\n" "${password_files[@]}" | sk --query="$url" --prompt='pass > ') fi if [[ -z $entry ]]; then @@ -36,7 +35,7 @@ echo "$entry" >/tmp/_upm secrets="$(pass show "$entry")" if [[ -n $secrets ]]; then fields=$(awk -F': ' 'NR>1 && !/^otpauth:/ {print $1}' <<<"$secrets") - field=$(printf "password\n%s\notp\n" "${fields[@]}" | fzf --prompt="pass ($entry) > ") + field=$(printf "password\n%s\notp\n" "${fields[@]}" | sk --prompt="pass ($entry) > ") case $field in password) printf "%s" "$(head -n1 <<<"$secrets")" ;; otp) printf "%s" "$(pass otp "$entry")" ;; diff --git a/shell/sk/env.zsh b/shell/sk/env.zsh new file mode 100644 index 00000000..b0d32b28 --- /dev/null +++ b/shell/sk/env.zsh @@ -0,0 +1 @@ +export SKIM_DEFAULT_OPTIONS='--reverse --color=16,fg+:2,bg+:0,hl:4,hl+:4,prompt:4,pointer:8'