This commit is contained in:
Christian Nieves
2023-04-20 23:31:53 -05:00
parent 0a21fea0e1
commit 096d5435c8
12 changed files with 106 additions and 9 deletions

View File

@ -8,8 +8,13 @@ username = Christian Nieves <cnieves@google.com>
# graphnodetemplate = {label("graphnode.{graphnode}", graphnode)}
[extdiff]
icdiff = icdiff --recursive --line-numbers
cmd.meld = /usr/bin/meld
cmd.pmeld = /usr/bin/meld
cmd.vimdiff = nvim
_real_multidiff = hg-multi-diff
# opts.vimdiff = -d $base $local $output $other +close +close
# opts.vimdiff = -f '+next' '+execute "DirDiff" fnameescape(argv(0)) fnameescape(argv(1))'
[extensions]
unsupported.tree =
@ -29,6 +34,10 @@ vimdiff.executable = nvim
vimdiff.args = -f -d $output -M $local $base $other -c "wincmd J" -c "set modifiable" -c "set write"
vimdiff.premerge = keep
[diff-tools]
vimdiff.executable = nvim
vimdiff.args = -d $base $local $output $other +close +close
[committemplate]
changeset = {desc}\n\n
HG: {extramsg}
@ -40,11 +49,24 @@ changeset = {desc}\n\n
{splitlines(diff()) % 'HG: {line}\n'}
[alias]
dt = icdiff --pager=on
dtex = dt -r exported(.)
dtp4 = dt -r p4base
dtup = dt -r .^
whatsout = status -n --change . --template=hgshort_status
what = status -n --change . --template=hgshort_status
whatsoutall = status --rev p4base --no-status --template=hgshort_status
# unbranch = cp --forget --at-rev . $1
unbranch = !$HG uncommit --keep $1 && $HG forget $1 && $HG add $1 && $HG amend $1
g3docpreview = ! $HG status --rev p4base --no-status -I re:.*\.md$ | xargs -I PATH -n 1 echo "https://g3doc.corp.google.com/PATH?cl=$(citctools info | grep Workspace.ID | cut '-d ' -f 3)"
mdiff = ! HG_ROOT=$(hg root) hg _real_multidiff "$@"
# For some reason, aliases that reuse mdiff don't work, so the
# entire thing has to be copied.
mdiffp4 = ! HG_ROOT=$(hg root) hg _real_multidiff --rev p4base "$@"
mdiffup = ! HG_ROOT=$(hg root) hg _real_multidiff --rev .^ "$@"
[trainingwheels]
warn-head-paths=False
prevent-push-dirty=false

24
scripts/scripts/hg-multi-diff Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
left=$2
right=$1
prefix=
# The directory name format seems to be the $repo[.$hash],
# where the hash is optional if we're comparing to the working directory
if [[ -d "$left" && "$right" != *.* ]]; then
prefix=$(dirname $HG_ROOT)/
fi
if [ -n "$DISPLAY" ]; then
meld_arg="--diff "
fi
# "#" is used as the pattern delimiter because paths might start with "/",
# which would create an invalid pattern.
files=$(find $left $right -type f | sed -e "s#^$left\/##" -e "s#^$right\/##" \
| sort | uniq | xargs -I{} -n 1 echo $left/{} $right/{} \
| awk -v pre=$prefix -v meld_arg="$meld_arg" \
'{ print meld_arg $1 " " pre $2 }')
if [ -z "$DISPLAY" ]; then
exec vimdiff-multi $files
else
# pass $@ so that the left-most tab is a directory tree tab.
meld --diff "$@" $files
fi

9
scripts/scripts/vimdiff-multi Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
#
# Like gvimdiff, but can diff multiple pairs of files.
cmd='nvim'
exec $cmd -R -f \
-c 'silent call TabMultiDiff()' \
-c 'tabdo windo set nofoldenable foldcolumn=0' \
-c 'tabfirst' \
"$@"

View File

@ -9,6 +9,10 @@ set -g mouse off
set -g prefix `
bind-key ` send-prefix
# Hide pane with Prefix-h
bind-key h break-pane -d -n _hidden_pane
bind-key H join-pane -s $.1
# Tick -> Ctrl-A, sets prefix to Ctrl-A
bind-key C-a set-option -g prefix C-a
@ -27,8 +31,10 @@ set-option -g base-index 1
set-window-option -g pane-base-index 1
# enable OSC 52 clipboard
set -s set-clipboard external
set-option -ag terminal-overrides ",xterm-256color:Ms=\\E]52;c;%p2%s\\7"
set -as terminal-overrides ',tmux*:Ms=\\E]52;%p1%s;%p2%s\\007'
set -as terminal-overrides ',screen*:Ms=\\E]52;%p1%s;%p2%s\\007'
set -s set-clipboard on
set -g @thumbs-osc52 '1'
# tmux-256color instead of screen-256color enables italics
set -g default-terminal "tmux-256color"

View File

@ -3,7 +3,7 @@ name: dev
windows:
- gmscore:
layout: main-vertical
layout: main-horizontal
panes:
- main:
- hgd gmscore
@ -12,7 +12,7 @@ windows:
- hgd gmscore
- experimental:
layout: main-vertical
layout: main-horizontal
panes:
- main:
- hgd experimental
@ -26,7 +26,7 @@ windows:
- cd ~/zettelkasten
- vim ~/zettelkasten/Todo.md
- dotfiles:
layout: main-vertical
layout: main-horizontal
panes:
- main:
- cd ~/dotfiles

View File

@ -1,3 +1,2 @@
vim.keymap.set('n', '<leader>y', require('osc52').copy_operator, {expr = true})
vim.keymap.set('n', '<leader>yy', '<leader>c_', {remap = true})
vim.keymap.set('v', '<leader>y', require('osc52').copy_visual)

View File

@ -20,6 +20,7 @@ require('packer').startup(function(use)
use 'wbthomason/packer.nvim'
use 'lewis6991/impatient.nvim'
use 'dstein64/vim-startuptime'
use 'will133/vim-dirdiff'
-- use {
-- 'google/vim-glaive',

View File

@ -174,7 +174,7 @@ nnoremap <leader>po :PiperOpenPath<CR>
nmap <leader>rbs ss <leader>rb
nmap <leader>yb :let @" = join(blaze#GetTargets(), ' ')<cr>
nmap <leader>yb :let @+ = join(blaze#GetTargets(), ' ')<cr>
Glug corpweb
nnoremap <leader>csw :CorpWebCsFile<cr>

View File

@ -102,7 +102,7 @@ vnoremap <leader>c<Space> :call nerdcommenter#Comment(0,"toggle")<CR>
nnoremap <leader>c$ :call nerdcommenter#Comment(0,"ToEOL")<CR>
vnoremap <leader>c$ :call nerdcommenter#Comment(0,"ToEOL")<CR>
nmap <leader>yf :let @" = expand("%")<cr>
nmap <leader>yf :let @+ = expand("%")<cr>
nmap <leader>ut :UndotreeToggle<cr>
nmap <leader>e :e %%

View File

@ -180,4 +180,38 @@ let g:loaded_netrwPlugin = 1
let g:loaded_tutor_mode_plugin = 1
let g:loaded_remote_plugins = 1
" Permanent "very magic" mode
nnoremap / /\v
vnoremap / /\v
cnoremap %s/ %smagic/
cnoremap \>s/ \>smagic/
nnoremap :g/ :g/\v
nnoremap :g// :g//
function! TabMultiDiff()
let s:tab_multi_diff = 0
argdo call s:AddBufferToTab()
tabclose
endfun
" Helper function used by TabMultiDiff(). Adds current buffer to new tab
" or last tab as appropriate, and sets new window's "diff" option.
function! s:AddBufferToTab()
let buf = bufnr("%")
if s:tab_multi_diff
tablast
vsplit
wincmd w
else
tab split
tabmove
endif
let s:tab_multi_diff = ! s:tab_multi_diff
exe 'b ' . buf
diffthis
tabfirst
endfun
lua require("plugins")

View File

@ -9,6 +9,7 @@ export XAUTHORITY=~/.Xauthority
export GOROOT=/usr/lib/google-golang
export PATH=$GOROOT/bin:$PATH
export JAVA_HOME=$(readlink -ne /usr/local/buildtools/java/jdk)
source /google/bin/releases/knock/knock.sh
function gcert() {
if [[ -n $TMUX ]]; then
@ -16,6 +17,7 @@ function gcert() {
fi
command gcert "$@"
source /google/bin/releases/knock/knock.sh
}
function tmux_title() {

View File

@ -13,7 +13,7 @@ autoload -Uz add-zsh-hook
add-zsh-hook chpwd g3path::hook
g3path::zle::accept-line () {
if [[ -n $GOOGLE3_ROOT && ! $BUFFER =~ \\s*(blaze|g4|p4|g4d|add_dep|buildozer|build_cleaner|debug_android_lint|rabbit|hb|gqui|builddoctor|unused_deps|clipper) ]]; then
if [[ -n $GOOGLE3_ROOT && ! $BUFFER =~ \\s*(blaze|g4|p4|g4d|add_dep|buildozer|build_cleaner|debug_android_lint|rabbit|hb|gqui|builddoctor|unused_deps|clipper|blaze_lint_refactoring) ]]; then
BUFFER=${BUFFER// \/\// $GOOGLE3_ROOT\/}
fi
zle .accept-line