From 50cae027bcaf1aa4c4676de054bdb0a778518318 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Thu, 23 Sep 2021 17:14:29 +0800 Subject: [PATCH 1/2] feat: split loadenv from readenv to load any file --- cli/fish/config.fish | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/cli/fish/config.fish b/cli/fish/config.fish index 51192dd..fdb6ac5 100644 --- a/cli/fish/config.fish +++ b/cli/fish/config.fish @@ -70,19 +70,23 @@ if status is-interactive # === auto cd into last activated directory test "$PWD" = "$HOME" && cd $last_pwd + function loadenv + while read -l line + set -l line (string trim $line) + if [ -z "$line" ] + continue + end + if string match -q '#*' $line + continue + end + set -l kv (string split -m 1 = -- $line) + set -gx $kv + end < $argv[1] + end + function readenv --on-variable PWD if test -r .env - while read -l line - set -l line (string trim $line) - if [ -z "$line" ] - continue - end - if string match -q '#*' $line - continue - end - set -l kv (string split -m 1 = -- $line) - set -gx $kv - end < .env + loadenv .env end end end From 48477b99c7cbee2b6f47c82fa0749d70eb99984f Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Thu, 23 Sep 2021 17:15:05 +0800 Subject: [PATCH 2/2] feat: support copy in termux --- cli/vim/init.vim | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cli/vim/init.vim b/cli/vim/init.vim index d41b68c..e40ca9c 100644 --- a/cli/vim/init.vim +++ b/cli/vim/init.vim @@ -66,9 +66,20 @@ nnoremap h h nnoremap j j nnoremap k k nnoremap l l -nnoremap o o +nnoremap oo o nnoremap q q + +function! GetXCopyCmd() + let l:status = system("command -v termux-clipboard-set") + if len(l:status) > 0 + return "termux-clipboard-set" + endif + return "xsel -b" +endfunction + +let g:xcopy = GetXCopyCmd() + function! XCopy() " Why is this not a built-in Vim script function?! let [line_start, column_start] = getpos("'<")[1:2] @@ -79,7 +90,7 @@ function! XCopy() endif let lines[-1] = lines[-1][: column_end - (&selection == 'inclusive' ? 1 : 2)] let lines[0] = lines[0][column_start - 1:] - call system('xsel -b', join(lines, "\n")) + call system(g:xcopy, join(lines, "\n")) endfunction function! YankFileLineNo()