summaryrefslogtreecommitdiffstats
path: root/docs/configuration/custom_commands/git_untracked
blob: fedae426854f26831c15788f8375aa808c442458 (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 ls-files . --exclude-standard --others))

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