Suepr vim diff viewer!
This commit is contained in:
parent
0851642315
commit
88284235da
7 changed files with 43 additions and 42 deletions
|
@ -4,11 +4,11 @@ NUM_DESKTOPS="$(xrq bspwm.num_desktops)"
|
|||
REVERSE_DESKTOP_ORDERING="$(xrq bspwm.reverse_desktop_ordering)"
|
||||
REVERSE_MONITOR_DESKTOPS="$(xrq bspwm.reverse_monitor_desktops)"
|
||||
BSPWM_MONITORS=$(bspc query -M)
|
||||
MONITOR_COUNT=$(<<< "$BSPWM_MONITORS" wc -w | awk '{ printf $1 }')
|
||||
MONITOR_COUNT=$(echo "$BSPWM_MONITORS" | wc -w | awk '{ printf $1 }')
|
||||
PER_MONITOR=$((NUM_DESKTOPS / MONITOR_COUNT))
|
||||
DESKTOPS=$(seq "$NUM_DESKTOPS")
|
||||
|
||||
[ "$REVERSE_MONITOR_DESKTOPS" -eq 1 ] && BSPWM_MONITORS=$(<<< "$BSPWM_MONITORS" tac)
|
||||
[ "$REVERSE_MONITOR_DESKTOPS" -eq 1 ] && BSPWM_MONITORS=$(echo "$BSPWM_MONITORS" | tac)
|
||||
|
||||
bspc config normal_border_color "$(xrq bspwm.normal_border_color)"
|
||||
bspc config focused_border_color "$(xrq bspwm.focused_border_color)"
|
||||
|
@ -28,7 +28,7 @@ bspc rule -a "*" split_dir=right
|
|||
i=1
|
||||
for mon in $BSPWM_MONITORS; do
|
||||
max=$((i + PER_MONITOR - 1))
|
||||
screens=
|
||||
screens=""
|
||||
for j in $(seq $i $max); do
|
||||
screens="${screens}${j} "
|
||||
done
|
||||
|
|
|
@ -19,14 +19,11 @@
|
|||
followRedirects = true
|
||||
|
||||
[diff]
|
||||
tool = cat
|
||||
tool = nvimdiff
|
||||
|
||||
[difftool]
|
||||
prompt = false
|
||||
|
||||
[multidiff]
|
||||
tool = nvimdiff -f
|
||||
|
||||
[alias]
|
||||
d = difftool
|
||||
s = status
|
||||
|
@ -52,20 +49,10 @@
|
|||
[mergetool "nvimdiff"]
|
||||
cmd = nvimdiff $BASE $LOCAL $REMOTE $MERGED -c '$wincmd w' -c '$wincmd J'
|
||||
|
||||
[mergetool "cat"]
|
||||
cmd = cat $BASE $LOCAL $REMOTE $MERGED
|
||||
|
||||
[mergetool "echo"]
|
||||
cmd = echo $BASE $LOCAL $REMOTE $MERGED
|
||||
|
||||
[mergetool "vimmultidiff"]
|
||||
cmd = vim-multi-diff-builder $BASE $LOCAL $REMOTE $MERGED
|
||||
|
||||
[pager]
|
||||
branch = false
|
||||
# remove ansi codes, pad each file's diff with newlines, show as diff, remove top padding
|
||||
# diff = vimpager -c 'silent %sm/\\e[^mK]*[mK]//g' -c 'silent %s/^diff/\\r\\rdiff/' -c 'silent set ft=diff' -c 'silent execute \"normal gg2dd\"'
|
||||
diff = less
|
||||
diff = vimpager -c 'silent %sm/\\e[^mK]*[mK]//g' -c 'silent %s/^diff/\\r\\rdiff/' -c 'silent set ft=diff' -c 'silent execute \"normal gg2dd\"'
|
||||
|
||||
[url "git@github.com:postmates"]
|
||||
insteadOf = https://github.com/postmates
|
||||
|
|
|
@ -43,7 +43,7 @@ let g:polyglot_disabled = ['cue', 'cuesheet']
|
|||
" let g:fzf_layout = { 'window': 'enew' }
|
||||
|
||||
" check if we're using vim as the manpage viewer before loading session plugins
|
||||
if exists('asmanviewer')
|
||||
if exists('asmanviewer') || exists('nosession')
|
||||
let g:prosession_dir = '/dev/null'
|
||||
else
|
||||
Plug 'tpope/vim-obsession' " session ease-of-use
|
||||
|
|
|
@ -110,7 +110,7 @@ function g
|
|||
end
|
||||
end
|
||||
alias gs "git status"
|
||||
alias gd "git d"
|
||||
alias gd "git diff"
|
||||
alias gds "gd --staged"
|
||||
# alias gdv "git dv" # TODO: what is this?
|
||||
alias gpl "git pull"
|
||||
|
@ -156,6 +156,7 @@ alias wifi "sudo nmtui"
|
|||
alias year 'cal (date +%Y)'
|
||||
alias y year
|
||||
alias pa pulsemixer
|
||||
alias vd vdiff
|
||||
|
||||
# games aliases
|
||||
# this sometimes fixes steam dynamic library issues?
|
||||
|
|
34
bin/vdiff
Executable file
34
bin/vdiff
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
repo_root="$(git rev-parse --show-toplevel)"
|
||||
pushd "$repo_root" &> /dev/null || ( echo "Repo doesn't exist!"; exit 2 )
|
||||
td="$(mktemp -p "$pdir" -d "vdiff.XXXXXXXX")"
|
||||
trap "rm -rf \"$td\"" EXIT
|
||||
files="$(git diff --name-only "$@")"
|
||||
|
||||
args=()
|
||||
vcmd=""
|
||||
for f in $files; do
|
||||
d="$(dirname "$td/$f")"
|
||||
rfn="$(basename "$f")"
|
||||
fn="$rfn._@HEAD"
|
||||
cfn="$rfn"
|
||||
|
||||
mkdir -p "$d"
|
||||
git --no-pager show HEAD:"$f" > "$d/$fn" 2>/dev/null || \
|
||||
echo "<FILE CREATED>" > "$d/$fn"
|
||||
cp "$f" "$d/$cfn" 2>/dev/null || echo "<FILE DELETED>" > "$d/$cfn"
|
||||
|
||||
if [ -z "$args" ]; then
|
||||
args+=($d/$fn -c)
|
||||
vcmd="vert diffsplit $d/$cfn"
|
||||
else
|
||||
vcmd="$vcmd | tabnew | e $d/$fn | vert diffsplit $d/$cfn"
|
||||
fi
|
||||
done
|
||||
|
||||
remaps="nnoremap <leader>k :tabnext<CR> | nnoremap <leader>j :tabprev<CR>"
|
||||
nvim "${args[@]}" "$vcmd | tabnext | $remaps"
|
||||
|
||||
rm -rf "$td"
|
||||
popd &> /dev/null || ( echo "Could not return to original directory" && exit 4 )
|
|
@ -1,22 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
td="$(mktemp -p "$pdir" -d "tmp_vim_git_multi_diff.XXXXXXXX")"
|
||||
trap "rm -rf \"$td\"" EXIT
|
||||
|
||||
files="$(git diff --name-only "$@")"
|
||||
|
||||
for f in $files; do
|
||||
d="$(dirname "$td/$f")"
|
||||
rfn="$(basename "$f")"
|
||||
fn="$rfn._@HEAD"
|
||||
cfn="$rfn._@DISK"
|
||||
mkdir -p "$d"
|
||||
git --no-pager show HEAD:"$f" > "$d/$fn" 2>/dev/null || \
|
||||
echo "<NO FILE>" > "$d/$fn"
|
||||
cp "$f" "$d/$cfn"
|
||||
nvim -d "$d/$fn" "$d/$cfn"
|
||||
exit 3
|
||||
done
|
||||
|
||||
ls -R "$td"
|
||||
rm -rf "$td"
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
nvim \
|
||||
-c 'let nosession=1' \
|
||||
-c 'silent setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile' \
|
||||
"$@" \
|
||||
-
|
||||
|
|
Reference in a new issue