diff options
| -rw-r--r-- | .bashrc | 71 | ||||
| -rw-r--r-- | .profile | 33 | ||||
| -rw-r--r-- | .vimrc | 157 |
3 files changed, 156 insertions, 105 deletions
@@ -10,7 +10,10 @@ export HISTCONTROL=ignoreboth:erasedups # no start space and duplicate entries export HISTSIZE=100000 # big big history export HISTFILESIZE=100000 # big big history shopt -s histappend # append to history, don't overwrite it -stty -ixon # disable Ctrl-S +shopt -s globstar +shopt -s dotglob + +stty -ixon # disable Ctrl-S # Save and reload the history after each command finishes #export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" @@ -19,7 +22,7 @@ stty -ixon # disable Ctrl-S # cf 9x15 # cf xft:Monospace:size=12 # cf "xft:Bitstream Vera Sans Mono:size=8:antialias=true -cf() { printf '\e]710;%s\007' "${1:-fixed}"; } +# cf() { printf '\e]710;%s\007' "${1:-fixed}"; } p() { [ -f "$1" -a ! -x "$1" ] && less -XF $1 || "$@" 2>&1 | less -XF ; } export -f p @@ -32,6 +35,7 @@ fixab() { printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 "$1"; } #export LESS_TERMCAP_me=$'\E[0m' # end bold #export LESS_TERMCAP_us=$(tput setaf 5) # underline (magenta) #export LESS_TERMCAP_ue=$'\E[0m' # end underline +export LESS=iXFRx4 export BACKUP=bip:/home/backup/marc@$(hostname -s) export LESS=XFRx4 @@ -42,9 +46,9 @@ export GNUTERM='sixelgd enhanced truecolor font "arial,9"' # Stopwatch alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date' -export TERMINAL=xt +#export TERMINAL=xt -alias cl='cf xft:Mono:size=12' +#alias cl='cf xft:Mono:size=12' #alias cp='cp --reflink' alias ls='ls --color=auto -v' alias ll='ls -AlFhv' @@ -66,26 +70,10 @@ alias god='p go doc' alias gol='GO111MODULE=off go' alias gtr='go test -v -run' alias gtb='go test -v -cpuprofile cpu.out -memprofile mem.out -benchmem -bench' -alias kd='sudo cat /sys/kernel/debug/tracing/trace_pipe' - -alias rvi='sudo vim' -alias rxt='sudo xt' -alias rxvi='sudo xvi' alias ww='vi ~/Wiki/home_page.md' alias s='vi ~/Wiki/scratch.md' alias dotfiles='git --git-dir=$HOME/dotfiles --work-tree=$HOME' -#alias uc='systemctl --user' -#alias wpa='sudo wpa_gui -i wlan0' - -#alias ifre='echo "ip link set wlo1 down; ip link set wlo1 up"|sudo sh' - -# Some admin command -#alias dmesg='sudo dmesg' -#alias mount='sudo mount' -#alias umount='sudo umount' -#alias cryptsetup='sudo cryptsetup' - alias by='go build ./cmd/yaegi' alias cy='cd ~/go/src/github.com/traefik/yaegi' #alias ty='go test -v -short ./interp' @@ -99,28 +87,28 @@ export YAEGI_UNSAFE=1 export YAEGI_UNRESTRICTED=1 export YAEGI_SYSCALL=1 -mosht() { mosh "$@" -- tmux new -A; } -export -f mosht +#mosht() { mosh "$@" -- tmux new -A; } +#export -f mosht -ssht() { ssh -t "$@" -- tmux new -A; } -export -f ssht +#ssht() { ssh -t "$@" -- tmux new -A; } +#export -f ssht sshs() { ssh -t "$@" -- screen -d -R; } -mpvx() { mpv --vo=sixel --profile=sw-fast --really-quiet "$@"; } -export -f mpvx +#mpvx() { mpv --vo=sixel --profile=sw-fast --really-quiet "$@"; } +#export -f mpvx -tfk() { ~/go/src/github.com/traefik/traefik/traefik "$@"; } -export -f tfk +#tfk() { ~/go/src/github.com/traefik/traefik/traefik "$@"; } +#export -f tfk -ty() { go test -v -short ./interp; } -export -f ty +#ty() { go test -v -short ./interp; } +#export -f ty -ws() (cd ~/Wiki && git status --short) -export -f ws +#ws() (cd ~/Wiki && git status --short) +#export -f ws -wsd() (cd ~/Wiki && git add . && git diff --cached) -export -f wsd +#wsd() (cd ~/Wiki && git add . && git diff --cached) +#export -f wsd man() { local width='' @@ -137,16 +125,23 @@ meteo() { #PS1='[\u@\h \W]\$ ' # fzf -[ -f "/usr/share/fzf/completion.bash" ] && . "/usr/share/fzf/completion.bash" -[ -f "/usr/share/fzf/key-bindings.bash" ] && . "/usr/share/fzf/key-bindings.bash" +# Accomodate different base prefix on termux +#[ -d "$HOME/../usr" ] && base=.. +#[ -f "$base/usr/share/fzf/completion.bash" ] && . "$base/usr/share/fzf/completion.bash" +#[ -f "$base/usr/share/fzf/key-bindings.bash" ] && . "$base/usr/share/fzf/key-bindings.bash" +#unset base +#[ -f "/usr/share/fzf/completion.bash" ] && . "/usr/share/fzf/completion.bash" +#[ -f "/usr/share/fzf/key-bindings.bash" ] && . "/usr/share/fzf/key-bindings.bash" # Arch: display package to install for missing commands -[ -f '/usr/share/doc/pkgfile/command-not-found.bash' ] && . /usr/share/doc/pkgfile/command-not-found.bash +#[ -f '/usr/share/doc/pkgfile/command-not-found.bash' ] && . /usr/share/doc/pkgfile/command-not-found.bash # Display git status in prompt . ~/.bash-powerline.sh -eval "$(direnv hook bash)" +# load Nix config files (aka auto-completion etc.) +#export XDG_DATA_DIRS="$HOME/.nix-profile/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" +# eval "$(direnv hook bash)" #export GITHUB_TOKEN=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 #set -o vi @@ -1,14 +1,27 @@ # ~/.profile -PATH=~/bin:~/mu/bin:$PATH:~/go/bin +case $(uname -s) in +(Darwin) + PATH=~/bin:~/mu/bin:/opt/homebrew/bin:/opt/homebrew/opt/ruby/bin:/opt/homebrew/opt/tcl-tk/bin:$PATH:~/go/bin:~/.cargo/bin:~/.pyenv/versions/2.7.18/bin:~/.local/bin + export REPLYTO='mvertes@free.fr' + export LANG=en_US.UTF-8 + if [ -z "$SSH_AUTH_SOCK" ] ; then + eval `ssh-agent -s` + ssh-add + fi + . "/opt/homebrew/etc/profile.d/bash_completion.sh" + tabs -4 + export HOMEBREW_NO_ANALYTICS=1 + ;; +(Linux) + PATH=~/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:~/go/bin + export XDG_RUNTIME_DIR=/run/user/$(id -u) + ;; +esac -[ "${SHELL##*/}" = bash ] && . ~/.bashrc +case $SHELL in +(*/ash) export ENV=~/.shrc ;; +(*/bash) . ~/.bashrc ;; +esac -# Last action: auto start X11 when logged on first console -# case $HOSTNAME in -# ([sS]wift|yoda) [ "$(tty)" != /dev/tty1 ] || exec startxfce4 ;; -# esac - -tabs -4 - -[ "$(tty)" != /dev/tty1 ] || exec dbus-run-session sway +#[ "$(tty)" != /dev/tty1 ] || exec dbus-run-session sway @@ -1,8 +1,10 @@ " General vim defaults " set background= -"set t_te= t_ti= +" set t_te= t_ti= set ls=1 ruler set ai ts=4 sw=4 noet +" Not a good idea to activate mouse, as it disables cut & paste in MacOS +>>>>>>> 6d506e0b30569c547f41f6d6334a1b5133774da4 "set mouse=a syntax off filetype on @@ -10,37 +12,44 @@ filetype plugin on filetype plugin indent on let mapleader = "," +" Save all files at the same place +set backupdir=~/.vim/backup// +set directory=~/.vim/backup// +set undodir=~/.vim/backup// +set undofile +set backup + +" set autochdir + +" ignore case when searching, except mixing upper and lower +set ignorecase +set smartcase + +" No bell +set belloff=all + +" For MacVim +set guifont=6x13:h13 + +" fzf plugin "set rtp+=/opt/homebrew/opt/fzf let g:fzf_preview = 'cat {}' +" set grepprg=rg\ --vimgrep\ --smart-case\ --hidden\ --follow + +" nnoremap \ :Rg<CR> +" nnoremap <C-T> :Files<cr> +nnoremap <Leader>b :Buffers<cr> +nnoremap <Leader>s :Blines<cr> + " vimki plugin autocmd filetype vimki syntax on autocmd filetype vimki set autowrite " autocmd filetype vimki setlocal spell spelllang=fr autocmd filetype vimki nmap <leader>z :FZF ~/Wiki<CR> +" autocmd filetype markdown,text,vimki setlocal textwidth=72 -" vim-go plugin -"let g:go_def_mode = "gopls" -"let g:go_info_mode = "gopls" -"let g:go_list_type = "quickfix" -"let g:go_fmt_command = "gopls" -"let g:go_gopls_gofumpt = 1 - -let g:go_gopls_enabled = 0 -let g:go_def_mode = "godef" -let g:go_fmt_command = "goimports" -let g:go_metalinter_command = "golangci-lint" -"autocmd FileType go syntax on -autocmd FileType go nmap <leader>b <Plug>(go-build) -autocmd FileType go nmap <leader>i <Plug>(go-info) -autocmd FileType go nmap <leader>r <Plug>(go-run) -autocmd FileType go nmap <leader>t <Plug>(go-test) -autocmd FileType go nmap <leader>f <Plug>(go-test-func) -autocmd FileType go nmap <leader>v <Plug>(go-referrers) -autocmd FileType go nmap <leader>n :cnext<CR> -autocmd FileType go nmap <leader>p :cprevious<CR> -autocmd FileType go nmap <leader>a :cclose<CR> -" autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 +autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 let g:netrw_browsex_viewer = "xdg-open" let g:netrw_gx = "<cWORD>" @@ -58,13 +67,15 @@ autocmd filetype python,yaml set ts=2 sts=2 sw=2 et " noremap <M-f> :!cscope -7 <cfile>
" Paragraph format / unformat -noremap <leader>f !}fmt
-noremap <leader>F !}fmt -c -w 2048
+" An alternate way is to use "gqip" to format. +" noremap <leader>f !}fmt -72 -s -p
+" noremap <leader>F !}fmt -c -w 2048
+noremap <leader>f gqip " noremap <buffer> K :s,^,//,
" noremap <buffer> <C-K> :s,^//,,
-noremap <buffer> # :s,^,#,
-noremap <buffer> @ :s,^#,,
+" noremap <buffer> # :s,^,#,
+" noremap <buffer> @ :s,^#,,
"hi MatchParen term=reverse ctermbg=magenta ctermfg=none " hi MatchParen cterm=reverse term=reverse ctermfg=white " @@ -80,36 +91,68 @@ noremap <leader>o :!xdg-open <cWORD>&<cr><cr> noremap <C-g> :tag <c-r><c-w><cr> noremap <C-p> :Files<cr> -""""""""""""" My cscope/vim key mappings - " - " The following maps all invoke one of the following cscope search types: - " - " 's' symbol: find all references to the token under cursor - " 'g' global: find global definition(s) of the token under cursor - " 'c' calls: find all calls to the function name under cursor - " 't' text: find all instances of the text under cursor - " 'e' egrep: egrep search for the word under cursor - " 'f' file: open the filename under cursor - " 'i' includes: find files that include the filename under cursor - " 'd' called: find functions that function under cursor calls - -if has("cscope") - set csto=0 - set cst - set nocsverb - if filereadable("cscope.out") - cs add cscope.out - elseif $CSCOPE_DB - cs add $CSCOPE_DB +" MacOS: Open QuickLook on current file (for markdown preview mainly) +noremap <leader>w :!ql %<CR><CR> + +function! CloseOnLast() +let cnt = 0 +for i in range(0, bufnr("$")) +if buflisted(i) + let cnt += 1 endif - set csverb +endfor + if cnt <= 1 + q +else + bd endif +endfunction + +noremap <leader><leader> :call CloseOnLast()<cr> + +" vim-lsp settings +let g:lsp_diagnostics_enabled = 0 +let g:lsp_document_code_action_signs_enabled = 0 +let g:lsp_document_highlight_enabled = 0 + +if executable('gopls') + au User lsp_setup call lsp#register_server({ + \ 'name': 'gopls', + \ 'cmd': {server_info->['gopls', '-remote=auto']}, + \ 'allowlist': ['go', 'gomod', 'gohtmltmpl', 'gotexttmpl'], + \ }) + autocmd BufWritePre *.go + \ call execute('LspDocumentFormatSync') | + \ call execute('LspCodeActionSync source.organizeImports') +endif + +if executable('clangd') + au User lsp_setup call lsp#register_server({ + \ 'name': 'clangd', + \ 'cmd': {server_info->['clangd', '-background-index']}, + \ 'whitelist': ['c', 'cpp', 'objc', 'objcpp'], + \ }) +endif + +function! s:on_lsp_buffer_enabled() abort + setlocal omnifunc=lsp#complete + if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif + nmap <buffer> gd <plug>(lsp-definition) + nmap <buffer> gs <plug>(lsp-document-symbol-search) + nmap <buffer> gS <plug>(lsp-workspace-symbol-search) + nmap <buffer> gr <plug>(lsp-references) + nmap <buffer> gi <plug>(lsp-implementation) + nmap <buffer> gt <plug>(lsp-type-definition) + nmap <buffer> <leader>rn <plug>(lsp-rename) + nmap <buffer> [g <plug>(lsp-previous-diagnostic) + nmap <buffer> ]g <plug>(lsp-next-diagnostic) + nmap <buffer> K <plug>(lsp-hover) +endfunction + +augroup lsp_install + au! + autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() +augroup END -nmap <leader>cs :cs find s <C-R>=expand("<cword>")<CR><CR> -nmap <leader>cg :cs find g <C-R>=expand("<cword>")<CR><CR> -nmap <leader>cc :cs find c <C-R>=expand("<cword>")<CR><CR> -nmap <leader>ct :cs find t <C-R>=expand("<cword>")<CR><CR> -nmap <leader>ce :cs find e <C-R>=expand("<cword>")<CR><CR> -nmap <leader>ci :cs find i <C-R>=expand("<cfile>")<CR><CR> -nmap <leader>cf :cs find f <C-R>=expand("<cfile>")<CR><CR> -nmap <leader>cd :cs find d <C-R>=expand("<cword>")<CR><CR> +" Git blame +command! Blame normal!:let @a=expand('%')<CR>:let @b=line('.')<CR>:new<CR>:set bt=nofile<CR>:%!git blame -wM --date=short <C-R>a<CR>:<C-R>b<CR> |
