From 27d3a43452443b60809212198abc95e076d434dd Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Tue, 2 Mar 2021 10:52:31 +0800 Subject: [PATCH 1/4] [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 From 3582bb47377a6776f35d4f88f87572a7174858de Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Tue, 2 Mar 2021 17:49:01 +0800 Subject: [PATCH 2/4] [feature] add icons --- cli/fish/functions/f.fish | 162 ++++++++++++++++++++++++++++++++++++++ cli/lf/lfrc | 1 + 2 files changed, 163 insertions(+) diff --git a/cli/fish/functions/f.fish b/cli/fish/functions/f.fish index 700966c..71fbf91 100644 --- a/cli/fish/functions/f.fish +++ b/cli/fish/functions/f.fish @@ -1,4 +1,166 @@ function f --description='sync lf pwd to shell when exit' + set -x LF_ICONS "\ +tw= :\ +st= :\ +ow= :\ +dt= :\ +di= :\ +fi= :\ +ln= :\ +or= :\ +ex= :\ +*.c= :\ +*.cc= :\ +*.clj= :\ +*.coffee= :\ +*.cpp= :\ +*.css= :\ +*.d= :\ +*.dart= :\ +*.erl= :\ +*.exs= :\ +*.fs= :\ +*.go= :\ +*.h= :\ +*.hh= :\ +*.hpp= :\ +*.hs= :\ +*.html= :\ +*.java= :\ +*.jl= :\ +*.js= :\ +*.json= :\ +*.lua= :\ +*.md= :\ +*.php= :\ +*.pl= :\ +*.pro= :\ +*.py= :\ +*.rb= :\ +*.rs= :\ +*.scala= :\ +*.ts= :\ +*.vim= :\ +*.cmd= :\ +*.ps1= :\ +*.sh= :\ +*.bash= :\ +*.zsh= :\ +*.fish= :\ +*.tar= :\ +*.tgz= :\ +*.arc= :\ +*.arj= :\ +*.taz= :\ +*.lha= :\ +*.lz4= :\ +*.lzh= :\ +*.lzma= :\ +*.tlz= :\ +*.txz= :\ +*.tzo= :\ +*.t7z= :\ +*.zip= :\ +*.z= :\ +*.dz= :\ +*.gz= :\ +*.lrz= :\ +*.lz= :\ +*.lzo= :\ +*.xz= :\ +*.zst= :\ +*.tzst= :\ +*.bz2= :\ +*.bz= :\ +*.tbz= :\ +*.tbz2= :\ +*.tz= :\ +*.deb= :\ +*.rpm= :\ +*.jar= :\ +*.war= :\ +*.ear= :\ +*.sar= :\ +*.rar= :\ +*.alz= :\ +*.ace= :\ +*.zoo= :\ +*.cpio= :\ +*.7z= :\ +*.rz= :\ +*.cab= :\ +*.wim= :\ +*.swm= :\ +*.dwm= :\ +*.esd= :\ +*.jpg= :\ +*.jpeg= :\ +*.mjpg= :\ +*.mjpeg= :\ +*.gif= :\ +*.bmp= :\ +*.pbm= :\ +*.pgm= :\ +*.ppm= :\ +*.tga= :\ +*.xbm= :\ +*.xpm= :\ +*.tif= :\ +*.tiff= :\ +*.png= :\ +*.svg= :\ +*.svgz= :\ +*.mng= :\ +*.pcx= :\ +*.mov= :\ +*.mpg= :\ +*.mpeg= :\ +*.m2v= :\ +*.mkv= :\ +*.webm= :\ +*.ogm= :\ +*.mp4= :\ +*.m4v= :\ +*.mp4v= :\ +*.vob= :\ +*.qt= :\ +*.nuv= :\ +*.wmv= :\ +*.asf= :\ +*.rm= :\ +*.rmvb= :\ +*.flc= :\ +*.avi= :\ +*.fli= :\ +*.flv= :\ +*.gl= :\ +*.dl= :\ +*.xcf= :\ +*.xwd= :\ +*.yuv= :\ +*.cgm= :\ +*.emf= :\ +*.ogv= :\ +*.ogx= :\ +*.aac= :\ +*.au= :\ +*.flac= :\ +*.m4a= :\ +*.mid= :\ +*.midi= :\ +*.mka= :\ +*.mp3= :\ +*.mpc= :\ +*.ogg= :\ +*.ra= :\ +*.wav= :\ +*.oga= :\ +*.opus= :\ +*.spx= :\ +*.xspf= :\ +*.pdf= :\ +*.nix= :\ +" set tempfile (mktemp -t tmp.XXXXXX) command lf -last-dir-path $tempfile $argv if test -s $tempfile diff --git a/cli/lf/lfrc b/cli/lf/lfrc index 59d08ed..0f68500 100644 --- a/cli/lf/lfrc +++ b/cli/lf/lfrc @@ -1,4 +1,5 @@ set drawbox +set icons cmd mkdir %mkdir "$@" cmd copyfilepath %echo "$f" | xsel -b From a863c733473a5ae47a4481cdd402da323f2d0da4 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Fri, 5 Mar 2021 11:56:56 +0800 Subject: [PATCH 3/4] [feature] capital P for paste-overwrite --- cli/lf/lfrc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cli/lf/lfrc b/cli/lf/lfrc index 0f68500..cd43a86 100644 --- a/cli/lf/lfrc +++ b/cli/lf/lfrc @@ -3,7 +3,21 @@ set icons cmd mkdir %mkdir "$@" cmd copyfilepath %echo "$f" | xsel -b -cmd copyfilename %basename "$f" | xsel -b - map Yp copyfilepath + +cmd copyfilename %basename "$f" | xsel -b map Yn copyfilename + +cmd pasteoverwrite %{{ + load=$(lf -remote 'load') + mode=$(echo "$load" | sed -n '1p') + list=$(echo "$load" | sed '1d') + if [ $mode = 'copy' ]; then + cp -R $list . + elif [ $mode = 'move' ]; then + mv $list . + fi + lf -remote 'send load' + lf -remote 'send clear' +}} +map P pasteoverwrite From 1c91dde68b6226bff035986ee7d8685b87cdf020 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Sat, 6 Mar 2021 21:06:27 +0800 Subject: [PATCH 4/4] [misc] add ~/go/bin to PATH --- cli/fish/config.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/fish/config.fish b/cli/fish/config.fish index cfb971b..5d3cd59 100644 --- a/cli/fish/config.fish +++ b/cli/fish/config.fish @@ -53,7 +53,7 @@ if status is-interactive alias dt='date "+%Y%m%d-%H%M%S"' # === PATH and file sourcing - append_paths ~/bin ~/.local/bin ~/.yarn/bin ~/dotfiles/bin ~/dotfiles/devops/bin + append_paths ~/go/bin ~/bin ~/.local/bin ~/.yarn/bin ~/dotfiles/bin ~/dotfiles/devops/bin source_files /usr/share/autojump/autojump.fish /usr/local/share/autojump/autojump.fish \ ~/.jabba/jabba.fish \ ~/.profile.fish