summaryrefslogtreecommitdiffstats
path: root/docs/configuration/custom_commands/joshuto_git_conflicts
blob: 7721e885de438666c9f3f790ae383d1eea795f72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash

CURRENT_PATH="$PWD"
GIT_PATH="$(git rev-parse --show-toplevel)"

cd $GIT_PATH
GIT_PATH="$PWD"

IFS=$'\n' FILES=($(git diff --name-only --diff-filter=U --relative))

cnt=${#FILES[@]}
for ((i=0;i<cnt;i++)); do
   FILES[i]=$(realpath --relative-to "$CURRENT_PATH" "${GIT_PATH}/${FILES[i]}")
done

cd $CURRENT_PATH

echo "${FILES[*]}" \
   | fzf --ansi --preview 'bat -n $(echo {})' \
   | cut -d ":" -f1