fix: fix copy without newline (#141)

Don't known why `tr -d '\n'` inner fzf options doesn't work.
Use `tr -d '[:space:]'` instead. It's OK for this scenario.
This commit is contained in:
Wenxuan Zhang 2021-03-10 09:56:31 +08:00
parent 304a5aa268
commit 15383e6b4d
No known key found for this signature in database
GPG key ID: CCAF35548C65530F
2 changed files with 4 additions and 4 deletions

View file

@ -42,7 +42,7 @@ function forgit::log -d "git commit viewer"
$FORGIT_FZF_DEFAULT_OPTS $FORGIT_FZF_DEFAULT_OPTS
+s +m --tiebreak=index +s +m --tiebreak=index
--bind=\"enter:execute($cmd |env LESS='-r' less)\" --bind=\"enter:execute($cmd |env LESS='-r' less)\"
--bind=\"ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '\n' | $copy_cmd)\" --bind=\"ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '[:space:]' |$copy_cmd)\"
$FORGIT_LOG_FZF_OPTS $FORGIT_LOG_FZF_OPTS
" "
@ -259,7 +259,7 @@ function forgit::rebase -d "git rebase "
set opts " set opts "
$FORGIT_FZF_DEFAULT_OPTS $FORGIT_FZF_DEFAULT_OPTS
+s +m --tiebreak=index +s +m --tiebreak=index
--bind=\"ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '\n' |$copy_cmd)\" --bind=\"ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '[:space:]' |$copy_cmd)\"
$FORGIT_REBASE_FZF_OPTS $FORGIT_REBASE_FZF_OPTS
" "
eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview" | eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview" |

View file

@ -22,7 +22,7 @@ forgit::log() {
$FORGIT_FZF_DEFAULT_OPTS $FORGIT_FZF_DEFAULT_OPTS
+s +m --tiebreak=index +s +m --tiebreak=index
--bind=\"enter:execute($cmd | LESS='-r' less)\" --bind=\"enter:execute($cmd | LESS='-r' less)\"
--bind=\"ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '\n' |${FORGIT_COPY_CMD:-pbcopy})\" --bind=\"ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '[:space:]' |${FORGIT_COPY_CMD:-pbcopy})\"
$FORGIT_LOG_FZF_OPTS $FORGIT_LOG_FZF_OPTS
" "
graph=--graph graph=--graph
@ -174,7 +174,7 @@ forgit::rebase() {
opts=" opts="
$FORGIT_FZF_DEFAULT_OPTS $FORGIT_FZF_DEFAULT_OPTS
+s +m --tiebreak=index +s +m --tiebreak=index
--bind=\"ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '\n' |${FORGIT_COPY_CMD:-pbcopy})\" --bind=\"ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '[:space:]' |${FORGIT_COPY_CMD:-pbcopy})\"
$FORGIT_REBASE_FZF_OPTS $FORGIT_REBASE_FZF_OPTS
" "
commit=$(eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview" | commit=$(eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview" |