Skip to content

Commit

Permalink
fix(bash-function): Fix fzf selection on git commands
Browse files Browse the repository at this point in the history
Close #1
  • Loading branch information
musq committed Feb 23, 2020
1 parent e91ae99 commit 995391f
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/shell/bash_functions
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fzf_find_edit() {
)

if [[ -n $files ]]; then
${EDITOR:-vim} "$files"
${EDITOR:-vim} $files
fi

}
Expand All @@ -92,7 +92,7 @@ fzf_git_add() {
)

if [[ -n $files ]]; then
git add --verbose "$files"
git add --verbose $files
fi

}
Expand All @@ -119,7 +119,7 @@ fzf_git_log() {

if [[ -n $commits ]]; then
local hashes=$(printf "%s" "$commits" | cut -d' ' -f2 | tr '\n' ' ')
git sh "$hashes"
git sh $hashes
fi

}
Expand Down Expand Up @@ -148,7 +148,7 @@ fzf_git_log_pickaxe() {

if [[ -n $commits ]]; then
local hashes=$(printf "%s" "$commits" | cut -d' ' -f1 | tr '\n' ' ')
git sh "$hashes"
git sh $hashes
fi

}
Expand All @@ -161,8 +161,8 @@ fzf_git_reflog() {

local hash=$(
if [ "$FZF_PREVIEW" -eq 1 ]; then
git reflog --color=always "$@" |
fzf --no-multi --ansi --no-sort --height 100% \
git rf --color=always "$@" |
fzf --ansi --no-sort --height 100% \
--preview "git sh --color=always {1}"
else
git reflog --color=always "$@" |
Expand All @@ -188,7 +188,7 @@ fzf_git_reset() {
)

if [[ -n $files ]]; then
git reset "$files"
git reset $files
fi

}
Expand Down Expand Up @@ -232,10 +232,16 @@ fzf_grep_edit(){
)
fi

local files=$(echo "$matches" | cut -d':' -f1)
# https://stackoverflow.com/a/28101809

files=$(echo "$matches" \
| cut -d':' -f1,2 \
| sed 's/:/|:/' \
| sed 's/^/:e /' \
|sed 's/$/|/')

if [[ -n $files ]]; then
${EDITOR:-vim} "$files" +"$(echo "$matches" | cut -d':' -f2)"
${EDITOR:-vim} -c "$files" +/"$1"
fi

}
Expand Down

0 comments on commit 995391f

Please sign in to comment.