From bc693d13753547ba354a6421d1fd962f05b380ee Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Sat, 18 Apr 2015 05:21:23 +0200 Subject: [PATCH] fzf: fix fzf-file-widget, improve template fzf-file-widget had several mistakes: 1) It was missing zsh -c for the tmux command to run 2) the fsel function wasn't accessible from the shell we spawned in the new tmux pane We solved the second issue by converting the function to an executable fzf-fsel. We also patched the bash key bindings to make use of that executable. While we were at it, we improved the template by setting wrksrc correctly and cd'ing in pre_build. --- srcpkgs/fzf/files/fzf-file-widget | 36 ++++++++++--------------------- srcpkgs/fzf/files/fzf-fsel | 8 +++++++ srcpkgs/fzf/patches/fsel.patch | 18 ++++++++++++++++ srcpkgs/fzf/template | 12 ++++++++--- 4 files changed, 46 insertions(+), 28 deletions(-) create mode 100644 srcpkgs/fzf/files/fzf-fsel create mode 100644 srcpkgs/fzf/patches/fsel.patch diff --git a/srcpkgs/fzf/files/fzf-file-widget b/srcpkgs/fzf/files/fzf-file-widget index 48f3c85189..d218cda953 100644 --- a/srcpkgs/fzf/files/fzf-file-widget +++ b/srcpkgs/fzf/files/fzf-file-widget @@ -1,27 +1,13 @@ -fzf-file-widget_fsel() { - command find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \ - -o -type f -print \ - -o -type d -print \ - -o -type l -print 2> /dev/null | sed 1d | cut -b3- | fzf -m | while read item; do - printf '%q ' "$item" - done - echo -} - -fzf-file-widget() { - if [ -n "$TMUX_PANE" -a ${FZF_TMUX:-1} -ne 0 -a ${LINES:-40} -gt 15 ]; then - local height - height=${FZF_TMUX_HEIGHT:-40%} - if [[ $height =~ %$ ]]; then - height="-p ${height%\%}" - else - height="-l $height" - fi - tmux split-window $height "cd $(printf %q "$PWD"); tmux send-keys -t $TMUX_PANE \"\$(fzf-file-widget_fsel)\"'" +if [ -n "$TMUX_PANE" -a ${FZF_TMUX:-1} -ne 0 -a ${LINES:-40} -gt 15 ]; then + local height + height=${FZF_TMUX_HEIGHT:-40%} + if [[ $height =~ %$ ]]; then + height="-p ${height%\%}" else - LBUFFER="${LBUFFER}$(fzf-file-widget_fsel)" - zle redisplay + height="-l $height" fi -} - -fzf-file-widget "$@" + tmux split-window $height "cd $(printf %q "$PWD"); zsh -c 'tmux send-keys -t $TMUX_PANE \"\$(fzf-fsel)\"'" +else + LBUFFER="${LBUFFER}$(fzf-fsel)" + zle redisplay +fi diff --git a/srcpkgs/fzf/files/fzf-fsel b/srcpkgs/fzf/files/fzf-fsel new file mode 100644 index 0000000000..371f1d655d --- /dev/null +++ b/srcpkgs/fzf/files/fzf-fsel @@ -0,0 +1,8 @@ +#!/bin/sh +command find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \ + -o -type f -print \ + -o -type d -print \ + -o -type l -print 2> /dev/null | sed 1d | cut -b3- | fzf -m | while read item; do + printf '%q ' "$item" + done +echo diff --git a/srcpkgs/fzf/patches/fsel.patch b/srcpkgs/fzf/patches/fsel.patch new file mode 100644 index 0000000000..d555b26ec6 --- /dev/null +++ b/srcpkgs/fzf/patches/fsel.patch @@ -0,0 +1,18 @@ +--- shell/key-bindings.bash.orig 2015-04-18 05:12:24.372078942 +0200 ++++ shell/key-bindings.bash 2015-04-18 05:12:49.244078057 +0200 +@@ -1,15 +1,5 @@ + # Key bindings + # ------------ +-__fsel() { +- command find -L . \( -path '*/\.*' -o -fstype 'dev' -o -fstype 'proc' \) -prune \ +- -o -type f -print \ +- -o -type d -print \ +- -o -type l -print 2> /dev/null | sed 1d | cut -b3- | fzf -m | while read item; do +- printf '%q ' "$item" +- done +- echo +-} +- + if [[ $- =~ i ]]; then + + __fsel_tmux() { diff --git a/srcpkgs/fzf/template b/srcpkgs/fzf/template index f42ea04d9e..6731efa113 100644 --- a/srcpkgs/fzf/template +++ b/srcpkgs/fzf/template @@ -2,8 +2,8 @@ pkgname=fzf version=0.9.7.1 _version=0.9.7-1 -wrksrc=${pkgname}-${_version}/src -revision=1 +wrksrc=${pkgname}-${_version} +revision=2 build_style=go go_import_path="github.com/junegunn/fzf/src" go_package="github.com/junegunn/fzf/src/fzf" @@ -19,12 +19,18 @@ checksum=38fa16c41e861af6ad87e7ff655188559775a2979254d76198c435d198e15fb4 # Needs cgo to build, which doesn't work when cross-compiling. nocross=yes +pre_build() { + cd src +} + post_install() { - cd ${wrksrc}/.. + cd ${wrksrc} vbin bin/fzf-tmux + vbin ${FILESDIR}/fzf-fsel vman man/man1/fzf.1 sed -i -e 's#source ~/\.fzf\.bash; ##' shell/key-bindings.bash + sed -i -e 's/(__fsel)/(fzf-fsel)/' shell/key-bindings.bash vinstall plugin/fzf.vim 644 usr/share/vim/vimfiles/plugin vinstall shell/completion.bash 644 usr/share/bash-completion/completions fzf vinstall ${FILESDIR}/fzf-file-widget 644 usr/share/zsh/site-functions