diff --git a/google/.hgrc b/google/.hgrc index 86ed48d..56808e9 100644 --- a/google/.hgrc +++ b/google/.hgrc @@ -8,8 +8,13 @@ username = Christian Nieves # 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 diff --git a/scripts/scripts/hg-multi-diff b/scripts/scripts/hg-multi-diff new file mode 100755 index 0000000..1eb4519 --- /dev/null +++ b/scripts/scripts/hg-multi-diff @@ -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 diff --git a/scripts/scripts/vimdiff-multi b/scripts/scripts/vimdiff-multi new file mode 100755 index 0000000..d852ea4 --- /dev/null +++ b/scripts/scripts/vimdiff-multi @@ -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' \ + "$@" diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf index 5044acc..f16933f 100644 --- a/tmux/.tmux.conf +++ b/tmux/.tmux.conf @@ -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" diff --git a/tmux/.tmuxinator/dev.yml b/tmux/.tmuxinator/dev.yml index f4d6db8..f57fbdf 100644 --- a/tmux/.tmuxinator/dev.yml +++ b/tmux/.tmuxinator/dev.yml @@ -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 diff --git a/vim/.vim/lua/config/oscyank.lua b/vim/.vim/lua/config/oscyank.lua index 8609108..1fe185d 100644 --- a/vim/.vim/lua/config/oscyank.lua +++ b/vim/.vim/lua/config/oscyank.lua @@ -1,3 +1,2 @@ vim.keymap.set('n', 'y', require('osc52').copy_operator, {expr = true}) -vim.keymap.set('n', 'yy', 'c_', {remap = true}) vim.keymap.set('v', 'y', require('osc52').copy_visual) diff --git a/vim/.vim/lua/plugins.lua b/vim/.vim/lua/plugins.lua index 9c89445..54acff9 100644 --- a/vim/.vim/lua/plugins.lua +++ b/vim/.vim/lua/plugins.lua @@ -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', diff --git a/vim/.vim/prefs/google.vim b/vim/.vim/prefs/google.vim index f959b90..497437a 100644 --- a/vim/.vim/prefs/google.vim +++ b/vim/.vim/prefs/google.vim @@ -174,7 +174,7 @@ nnoremap po :PiperOpenPath nmap rbs ss rb -nmap yb :let @" = join(blaze#GetTargets(), ' ') +nmap yb :let @+ = join(blaze#GetTargets(), ' ') Glug corpweb nnoremap csw :CorpWebCsFile diff --git a/vim/.vim/prefs/leader.vim b/vim/.vim/prefs/leader.vim index ca10733..07e0084 100644 --- a/vim/.vim/prefs/leader.vim +++ b/vim/.vim/prefs/leader.vim @@ -102,7 +102,7 @@ vnoremap c :call nerdcommenter#Comment(0,"toggle") nnoremap c$ :call nerdcommenter#Comment(0,"ToEOL") vnoremap c$ :call nerdcommenter#Comment(0,"ToEOL") -nmap yf :let @" = expand("%") +nmap yf :let @+ = expand("%") nmap ut :UndotreeToggle nmap e :e %% diff --git a/vim/.vimrc b/vim/.vimrc index 0776087..83bef9a 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -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") + diff --git a/zsh/.bash_profile.google b/zsh/.bash_profile.google index 004e725..d84a3e4 100644 --- a/zsh/.bash_profile.google +++ b/zsh/.bash_profile.google @@ -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() { diff --git a/zsh/g3path.zsh b/zsh/g3path.zsh index 522db03..d790357 100644 --- a/zsh/g3path.zsh +++ b/zsh/g3path.zsh @@ -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