summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-11-01 09:55:22 +0800
committerYour Name <you@example.com>2026-11-01 09:55:22 +0800
commit708e0c38fdcfd84a0028c4b261d77c4b2f5083df (patch)
tree9569b0dd0e9886ef1cea423b733c797461f1878e
parent30b598c7d885b79e792232eff7146b524e31493b (diff)
core: one vimrc and tmux.conf for Mac and Linux
-rw-r--r--core/tmux.conf40
-rwxr-xr-xcore/vim.sh67
-rw-r--r--core/vimrc (renamed from mac/vimrc)11
-rw-r--r--mac/tmux.conf38
4 files changed, 44 insertions, 112 deletions
diff --git a/core/tmux.conf b/core/tmux.conf
index 465641c..97084f1 100644
--- a/core/tmux.conf
+++ b/core/tmux.conf
@@ -1,15 +1,41 @@
1# True-color support regardless of what TERM the outer terminal/distro sets 1# Ctrl-b f: prompt for text, list windows whose name, pane title or pane contents match; Enter jumps
2set -g default-terminal "tmux-256color" 2# Ctrl-b w: tree of every window in every session; press f inside it to filter by name, Enter jumps
3set -ga terminal-overrides ",*256col*:Tc" 3# Ctrl-b s: tree of sessions (same tree, session view)
4 4# Ctrl-b p: go to the previous window (lower index, wraps); Ctrl-b n goes to the next one
5#
5# Vi mode for copy 6# Vi mode for copy
6setw -g mode-keys vi 7setw -g mode-keys vi
7 8
8# Mouse selection 9# Mouse selection
9set -g mouse on 10set -g mouse on
10 11
12# Persistent pane index labels (top-left of each pane's border)
13set -g pane-border-status top
14set -g pane-border-format "#P"
15
16# Explicitly swap current pane with a pane index you type in
17bind-key P command-prompt -p "swap with pane #:" "swap-pane -d -t '%%'"
18# Manual: :swap-pane -s <src> -t <dst>
19
20# Vim-style pane resizing (prefix + H/J/K/L), magnitude 1
21bind -r H resize-pane -L 1
22bind -r J resize-pane -D 1
23bind -r K resize-pane -U 1
24bind -r L resize-pane -R 1
25
11# v to start selection, y to yank (like vim) 26# v to start selection, y to yank (like vim)
12bind-key -T copy-mode-vi v send-keys -X begin-selection 27bind-key -T copy-mode-vi v send-keys -X begin-selection
13bind-key -T copy-mode-vi y send-keys -X copy-pipe-no-clear "openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1" 28# macOS: pbcopy. Linux: wl-copy/xclip when usable, else just drain (tmux's own
14bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-no-clear "openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1" 29# buffer + set-clipboard/OSC 52 still apply). Netcat send is the same on both.
15bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear "openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1" 30if-shell 'uname | grep -q Darwin' {
31 bind-key -T copy-mode-vi y send-keys -X copy-pipe-no-clear "bash -c 'tee >(pbcopy) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'"
32 bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-no-clear "bash -c 'tee >(pbcopy) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'"
33 bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear "bash -c 'tee >(pbcopy) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'"
34} {
35 # Linux only: true-color regardless of what TERM the outer terminal/distro sets
36 set -g default-terminal "tmux-256color"
37 set -ga terminal-overrides ",*256col*:Tc"
38 bind-key -T copy-mode-vi y send-keys -X copy-pipe-no-clear "bash -c 'tee >(wl-copy 2>/dev/null || xclip -selection clipboard 2>/dev/null || cat >/dev/null) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'"
39 bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-no-clear "bash -c 'tee >(wl-copy 2>/dev/null || xclip -selection clipboard 2>/dev/null || cat >/dev/null) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'"
40 bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear "bash -c 'tee >(wl-copy 2>/dev/null || xclip -selection clipboard 2>/dev/null || cat >/dev/null) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'"
41}
diff --git a/core/vim.sh b/core/vim.sh
index 8041e0e..241673e 100755
--- a/core/vim.sh
+++ b/core/vim.sh
@@ -2,71 +2,8 @@
2 2
3cd "$(dirname "${BASH_SOURCE[0]}")" || exit 3cd "$(dirname "${BASH_SOURCE[0]}")" || exit
4 4
5# Same vimrc as the Mac (core/vimrc); OS differences are guarded inside the file.
5VIMRC_PATH="/etc/vimrc" 6VIMRC_PATH="/etc/vimrc"
6[ -d /etc/vim ] && VIMRC_PATH="/etc/vim/vimrc" 7[ -d /etc/vim ] && VIMRC_PATH="/etc/vim/vimrc"
7CLIP_HOST="p.noml.ch"
8CLIP_PORT="5023"
9CLIP_CMD="openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 ${CLIP_HOST} ${CLIP_PORT}"
10 8
11grep -q 'netcat_clipboard' "$VIMRC_PATH" && exit 0 9cp vimrc "$VIMRC_PATH"
12
13cat << EOF >> "$VIMRC_PATH"
14augroup netcat_clipboard
15 au!
16 au TextYankPost * call system("echo " . shellescape(@") . " | ${CLIP_CMD} >/dev/null 2>&1 &")
17augroup END
18
19" Enable line wrapping
20set wrap
21
22" Optional: Make wrapped lines easier to read by indenting them
23set breakindent
24set breakindentopt=shift:1
25
26syntax on
27set mouse=a
28set expandtab
29set shiftwidth=4
30set softtabstop=4
31set tabstop=4
32set noautoindent
33set nosmartindent
34filetype plugin indent on
35
36set laststatus=2 " permanent status bar
37set statusline=%F " shows full file path
38
39if (has("termguicolors"))
40 " tmux's terminfo entries (tmux-256color/screen-256color) don't define
41 " setrgbf/setrgbb, so vim has no termcap to build true-color escapes and
42 " silently emits none. Set them explicitly (standard vim+tmux fix).
43 if !empty($TMUX)
44 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
45 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
46 endif
47 set termguicolors
48endif
49
50"colorscheme murphy
51colorscheme zellner
52
53" Ctrl+A: Move to the beginning of the line in INSERT mode
54inoremap <C-a> <Home>
55
56" Ctrl+E: Move to the end of the line in INSERT mode
57inoremap <C-e> <End>
58
59" Ctrl+A: Move to the beginning of the line in NORMAL mode
60nnoremap <C-a> 0
61
62" Ctrl+E: Move to the end of the line in NORMAL mode
63nnoremap <C-e> $
64
65set number
66setlocal regexpengine=2
67set foldcolumn=12
68
69set noswapfile
70autocmd InsertLeave * silent! update
71
72EOF
diff --git a/mac/vimrc b/core/vimrc
index ba9bd88..b4441a5 100644
--- a/mac/vimrc
+++ b/core/vimrc
@@ -1,4 +1,5 @@
1" /etc/vim/vimrc — self-contained; source of truth: /v1/dev_env/core/vim.sh 1" One vimrc for Mac and Linux. Source of truth: /Users/xs/dev_env/core/vimrc
2" Mac: cp core/vimrc ~/.vimrc Linux: sudo bash core/vim.sh (copies it to /etc/vimrc or /etc/vim/vimrc)
2" gt: go to next tab (right, wraps) 3" gt: go to next tab (right, wraps)
3" gT: go to previous tab (left, wraps) 4" gT: go to previous tab (left, wraps)
4" 2gt: go to tab number 2 (counted from 1 at the left) 5" 2gt: go to tab number 2 (counted from 1 at the left)
@@ -111,7 +112,10 @@ autocmd InsertLeave * silent! update
111function! s:LockIfManaged() abort 112function! s:LockIfManaged() abort
112 if !exists('s:managed') 113 if !exists('s:managed')
113 let l:cargo = empty($CARGO_HOME) ? expand('~/.cargo') : $CARGO_HOME 114 let l:cargo = empty($CARGO_HOME) ? expand('~/.cargo') : $CARGO_HOME
114 let s:managed = [trim(system('rustup show home')), l:cargo . '/registry', l:cargo . '/git'] 115 let s:managed = [l:cargo . '/registry', l:cargo . '/git']
116 if executable('rustup')
117 call add(s:managed, trim(system('rustup show home')))
118 endif
115 endif 119 endif
116 for l:dir in s:managed 120 for l:dir in s:managed
117 if stridx(expand('%:p'), l:dir . '/') == 0 121 if stridx(expand('%:p'), l:dir . '/') == 0
@@ -126,6 +130,8 @@ augroup managed_readonly
126augroup END 130augroup END
127 131
128 132
133" vim-plug is optional: skip the plugin block until plug.vim is installed (see Setup above)
134if filereadable(expand('~/.vim/autoload/plug.vim'))
129call plug#begin('~/.vim/plugged') 135call plug#begin('~/.vim/plugged')
130Plug 'prabirshrestha/async.vim' 136Plug 'prabirshrestha/async.vim'
131Plug 'prabirshrestha/vim-lsp' 137Plug 'prabirshrestha/vim-lsp'
@@ -141,6 +147,7 @@ Plug 'airblade/vim-gitgutter'
141Plug 'preservim/nerdtree' 147Plug 'preservim/nerdtree'
142Plug 'andymass/vim-matchup' 148Plug 'andymass/vim-matchup'
143call plug#end() 149call plug#end()
150endif
144 151
145let g:gitgutter_sign_column_always = 0 152let g:gitgutter_sign_column_always = 0
146 153
diff --git a/mac/tmux.conf b/mac/tmux.conf
deleted file mode 100644
index bd89157..0000000
--- a/mac/tmux.conf
+++ /dev/null
@@ -1,38 +0,0 @@
1# Ctrl-b f: prompt for text, list windows whose name, pane title or pane contents match; Enter jumps
2# Ctrl-b w: tree of every window in every session; press f inside it to filter by name, Enter jumps
3# Ctrl-b s: tree of sessions (same tree, session view)
4# Ctrl-b p: go to the previous window (lower index, wraps); Ctrl-b n goes to the next one
5#
6# Vi mode for copy
7setw -g mode-keys vi
8
9# Mouse selection
10set -g mouse on
11
12# Persistent pane index labels (top-left of each pane's border)
13set -g pane-border-status top
14set -g pane-border-format "#P"
15
16# Explicitly swap current pane with a pane index you type in
17bind-key P command-prompt -p "swap with pane #:" "swap-pane -d -t '%%'"
18# Manual: :swap-pane -s <src> -t <dst>
19
20# Vim-style pane resizing (prefix + H/J/K/L), magnitude 1
21bind -r H resize-pane -L 1
22bind -r J resize-pane -D 1
23bind -r K resize-pane -U 1
24bind -r L resize-pane -R 1
25
26# v to start selection, y to yank (like vim)
27bind-key -T copy-mode-vi v send-keys -X begin-selection
28# macOS: pbcopy. Linux: wl-copy/xclip when usable, else just drain (tmux's own
29# buffer + set-clipboard/OSC 52 still apply). Netcat send is the same on both.
30if-shell 'uname | grep -q Darwin' {
31 bind-key -T copy-mode-vi y send-keys -X copy-pipe-no-clear "bash -c 'tee >(pbcopy) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'"
32 bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-no-clear "bash -c 'tee >(pbcopy) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'"
33 bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear "bash -c 'tee >(pbcopy) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'"
34} {
35 bind-key -T copy-mode-vi y send-keys -X copy-pipe-no-clear "bash -c 'tee >(wl-copy 2>/dev/null || xclip -selection clipboard 2>/dev/null || cat >/dev/null) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'"
36 bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-no-clear "bash -c 'tee >(wl-copy 2>/dev/null || xclip -selection clipboard 2>/dev/null || cat >/dev/null) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'"
37 bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-no-clear "bash -c 'tee >(wl-copy 2>/dev/null || xclip -selection clipboard 2>/dev/null || cat >/dev/null) | openssl enc -aes-256-cbc -pbkdf2 -pass pass:YourPassword | nc -w 1 p.noml.ch 5023 >/dev/null 2>&1'"
38}