diff options
Diffstat (limited to 'docs/configuration/custom_commands/git_untracked')
-rwxr-xr-x | docs/configuration/custom_commands/git_untracked | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/configuration/custom_commands/git_untracked b/docs/configuration/custom_commands/git_untracked new file mode 100755 index 0000000..fedae42 --- /dev/null +++ b/docs/configuration/custom_commands/git_untracked @@ -0,0 +1,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 |