commit d4e59716ddf010660e70de285e1b5e7750441f6f
parent 9df41c1e4fce93702d98fd0c39fa055421cf4ded
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Wed, 2 Oct 2019 20:17:18 +0200
Prefer fzy over fzf, reduce code
Diffstat:
M | .config/sh/commands | | | 78 | +++++++++++++++++++++--------------------------------------------------------- |
1 file changed, 21 insertions(+), 57 deletions(-)
diff --git a/.config/sh/commands b/.config/sh/commands
@@ -3,7 +3,7 @@
alias e='$EDITOR'
f() {
- $EDITOR $(fzf)
+ $EDITOR $(find "${1:-.}" -type f | fzy -l 25)
}
if type doas >/dev/null 2>&1; then
@@ -17,54 +17,43 @@ alias sx="sxiv -ft *"
alias xq="xbps-query"
alias xr="sudo xbps-remove"
-alias cg='c "$(git rev-parse --show-toplevel)"' # cd under git repo
-#alias ch='cd "$(dirs | sort -u | fzf --preview='ls {1}')"' # cd from history
c() {
- dir=$(find "${1:-.}" -type d | grep -v '/\.' | fzf --preview='ls {1}')
+ dir=$(find "${1:-.}" -type d | grep -v '/\.' | fzy -l 25)
[ -d "$dir" ] && cd "$dir" || return
}
-
-alias ls=ls; unalias ls
-alias ls='ls -hF'
-alias l='ls'
-alias la='l -a'
-alias ll='l -l'
-alias lo='l -alo'
+alias cg='c "$(git rev-parse --show-toplevel)"' # cd under git repo
alias r='fc -s'
h() {
- eval $(cat "$HISTFILE" | fzf --preview-window=hidden)
+ eval $(cat "$HISTFILE" | fzy -l 25)
}
o() {
[ "$(uname)" = 'Darwin' ] && open="open" || open="xdg-open"
if [ "$#" -gt 0 ] && [ -f "$1" ]; then
- nohup $open "$1" >/dev/null 2>&1 &
- disown
+ $open "$1"
else
- IFS= out=$(fzf --exit-0 \
- --expect=ctrl-o,ctrl-e,ctrl-y \
- --preview-window=hidden)
- key=$(echo "$out" | sed 1q)
- file=$(echo "$out" | sed 2q | tail -1)
- if [ -n "$file" ]; then
- if [ "$key" = ctrl-e ]; then
- $EDITOR "$file"
- elif [ "$key" = ctrl-y ]; then
- printf "%s" "$PWD/$file" | xclip
- elif [ "$key" = ctrl-o ]; then
- cd "$(dirname "$file")" || return
- else
- nohup $open "$file" >/dev/null 2>&1 &
- disown
- fi
+ target="$(find . | fzy -l 25)"
+ if [ -f "$target" ]; then
+ $open "$target"
+ elif [ -d "$target" ]; then
+ cd "$target"
+ else
+ (>&2 echo "unknown target type")
fi
fi
}
-alias dotfiles="git --git-dir=\$HOME/.dotfiles/ --work-tree=\$HOME"
-alias dotfiles-commit="dotfiles commit -a -S -v; dotfiles push"
+alias ls=ls; unalias ls
+alias ls='ls -hF'
+alias l='ls'
+alias la='l -a'
+alias ll='l -l'
+alias lo='l -alo'
+
+alias dot="git --git-dir=\$HOME/.dotfiles/ --work-tree=\$HOME"
+alias dotcap="dot commit -a -S -v; dot push"
alias m="make"
alias mc="make clean"
@@ -132,31 +121,6 @@ t_stop_idle() {
done
}
-m_all_sl() {
- for d in ~/.local/lib/dwm ~/.local/lib/st ~/.local/lib/surf \
- ~/.local/lib/tabbed ~/.local/lib/nnn; do
- echo
- echo "## Building $d"
- cd "$d" && make clean; make && sudo make install
- done
- cd - || return
-}
-
-gcagp_all_sl() {
- msg="Update color scheme"
- read -r "input?commit message [$msg]: "
- msg="${input:-$msg}"
- dotfiles add .Xresources
- dotfiles commit -m "$msg" --verbose --gpg-sign && git push;
- for d in ~/.local/lib/dwm ~/.local/lib/st ~/.local/lib/surf \
- ~/.local/lib/tabbed; do
- cd "$d" && \
- git branch && \
- git commit --all -m "$msg" --verbose --gpg-sign && git push;
- cd - || return
- done
-}
-
man9() {
if [ -d /usr/lib/plan9 ]; then
plan9mans="/usr/lib/plan9/man/man1"