Replace fzf with skim

This commit is contained in:
Henrik Lissner 2018-03-23 15:29:50 -04:00
parent d887634ff7
commit 1f94f3ba95
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
19 changed files with 59 additions and 60 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -1 +0,0 @@
export FZF_DEFAULT_OPTS='--reverse --color=16,fg+:2,bg+:0,hl:4,hl+:4,prompt:4,pointer:8'

View file

@ -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
}

5
shell/sk/aliases.zsh Normal file
View file

@ -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

View file

@ -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'"

View file

@ -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

View file

@ -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

View file

@ -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 \
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"

View file

@ -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/ .*//")

View file

@ -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"

11
shell/sk/bin/sk-mpc Executable file
View file

@ -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"

View file

@ -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")" ;;

1
shell/sk/env.zsh Normal file
View file

@ -0,0 +1 @@
export SKIM_DEFAULT_OPTIONS='--reverse --color=16,fg+:2,bg+:0,hl:4,hl+:4,prompt:4,pointer:8'