From 27d3a43452443b60809212198abc95e076d434dd Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Tue, 2 Mar 2021 10:52:31 +0800 Subject: [PATCH] [feature] add lf --- cli/fish.sh | 1 + cli/fish/functions/f.fish | 12 ++++++++++++ cli/lf.sh | 16 ++++++++++++++++ cli/lf/lfrc | 8 ++++++++ devel/go.sh | 2 +- 5 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 cli/fish/functions/f.fish create mode 100755 cli/lf.sh create mode 100644 cli/lf/lfrc diff --git a/cli/fish.sh b/cli/fish.sh index c4138ea..0c62277 100755 --- a/cli/fish.sh +++ b/cli/fish.sh @@ -58,6 +58,7 @@ lnsf "$DIR/fish/functions/fish_prompt.fish" "$XDG_CONFIG_HOME/fish/functions/fis lnsf "$DIR/fish/functions/fish_right_prompt.fish" "$XDG_CONFIG_HOME/fish/functions/fish_right_prompt.fish" lnsf "$DIR/fish/functions/fisher.fish" "$XDG_CONFIG_HOME/fish/functions/fisher.fish" lnsf "$DIR/fish/functions/r.fish" "$XDG_CONFIG_HOME/fish/functions/r.fish" +lnsf "$DIR/fish/functions/f.fish" "$XDG_CONFIG_HOME/fish/functions/f.fish" lnsf "$DIR/fish/functions/append_paths.fish" "$XDG_CONFIG_HOME/fish/functions/append_paths.fish" lnsf "$DIR/fish/functions/source_files.fish" "$XDG_CONFIG_HOME/fish/functions/source_files.fish" diff --git a/cli/fish/functions/f.fish b/cli/fish/functions/f.fish new file mode 100644 index 0000000..700966c --- /dev/null +++ b/cli/fish/functions/f.fish @@ -0,0 +1,12 @@ +function f --description='sync lf pwd to shell when exit' + set tempfile (mktemp -t tmp.XXXXXX) + command lf -last-dir-path $tempfile $argv + if test -s $tempfile + set dir (cat $tempfile) + if test -n $dir -a -d $dir + builtin cd -- $dir + end + end + + command rm -f -- $tempfile +end diff --git a/cli/lf.sh b/cli/lf.sh new file mode 100755 index 0000000..394591d --- /dev/null +++ b/cli/lf.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e +DIR=$(dirname "$(readlink -f "$0")") +. "$DIR/../env.sh" + +if ! has_cmd go; then + "$PDIR/devel/go.sh" +fi +log 'Setting up lf' + +# install lf +env GOPROXY= CGO_ENABLED=0 GO111MODULE=on go get -u -ldflags="-s -w" github.com/gokcehan/lf + +# linking configuration files +lnsf "$DIR/lf/lfrc" "$XDG_CONFIG_HOME/lf/lfrc" diff --git a/cli/lf/lfrc b/cli/lf/lfrc new file mode 100644 index 0000000..59d08ed --- /dev/null +++ b/cli/lf/lfrc @@ -0,0 +1,8 @@ +set drawbox +cmd mkdir %mkdir "$@" + +cmd copyfilepath %echo "$f" | xsel -b +cmd copyfilename %basename "$f" | xsel -b + +map Yp copyfilepath +map Yn copyfilename diff --git a/devel/go.sh b/devel/go.sh index 010b865..b6ab9c4 100755 --- a/devel/go.sh +++ b/devel/go.sh @@ -18,7 +18,7 @@ esac if in_china; then go env -w GO111MODULE=on - go env -w GOPROXY=https://goproxy.cn,direct + go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/ fi # coc.nvim