diff options
| author | Marc Vertes <mvertes@free.fr> | 2025-01-21 08:31:56 +0100 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2025-01-21 08:31:56 +0100 |
| commit | bac7296bb38bb46b51e4fd70c5fe234f2a58d553 (patch) | |
| tree | 84cf6cb71eb8a483f31483761a5ba2cf54e14296 | |
| parent | 351a23a8b81766d7aba3bfb469f049348d13d2ec (diff) | |
fix for multiple platform
| -rw-r--r-- | .bashrc | 63 | ||||
| -rw-r--r-- | .profile | 29 | ||||
| -rw-r--r-- | .vimrc | 146 |
3 files changed, 167 insertions, 71 deletions
@@ -5,11 +5,15 @@ export PAGER=less export EDITOR=vim -export HISTIGNORE=ls:ps:history +export HISTIGNORE=2fa:ls:ps:history:tc:cursor 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 +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" @@ -18,7 +22,7 @@ shopt -s histappend # append to history, don't overwrite it # 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 @@ -31,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 # gnuplot display in terminal export GNUTERM='sixelgd enhanced truecolor font "arial,9"' @@ -38,16 +43,16 @@ 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 cp='cp --reflink' +#alias cl='cf xft:Mono:size=12' +#alias cp='cp --reflink' alias ls='ls --color=auto -v' alias ll='ls -AlFhv' alias vi='vim' alias view='vim -R' #alias op='xdg-open' -alias git='hub' +#alias git='hub' #alias go='go1.14.1' alias go11='go1.11.13' alias go12='go1.12.10' @@ -59,9 +64,9 @@ alias god='p go doc' alias gtr='go test -v -run' alias gtb='go test -v -cpuprofile cpu.out -memprofile mem.out -benchmem -bench' #alias vi='vim' -alias rvi='sudo vim' -alias rxt='sudo xt' -alias rxvi='sudo xvi' +#alias rvi='sudo vim' +#alias rxt='sudo xt' +#alias rxvi='sudo xvi' alias ww='vi ~/Wiki/HomePage' alias dotfiles='git --git-dir=$HOME/dotfiles --work-tree=$HOME' @@ -86,26 +91,26 @@ alias wai='~/go/src/github.co/traefik/whoami/whoami' # yaegi debug export YAEGI_DOT_CMD='dotty -' -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 -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 meteo() { local request="wttr.in/${1-Toulouse}?F&T" @@ -117,17 +122,17 @@ meteo() { # fzf # 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 +#[ -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 # 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 # export PS1='; ' # load Nix config files (aka auto-completion etc.) -export XDG_DATA_DIRS="$HOME/.nix-profile/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" +#export XDG_DATA_DIRS="$HOME/.nix-profile/share:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" @@ -1,10 +1,25 @@ # ~/.profile -PATH=~/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 - -# Last action: auto start X11 when logged on first console -#case $HOSTNAME in -#([sS]wift|yoda) [ "$(tty)" != /dev/tty1 ] || exec startx ;; -#esac +case $SHELL in +(*/ash) export ENV=~/.shrc ;; +(*/bash) . ~/.bashrc ;; +esac @@ -1,55 +1,62 @@ +" General vim defaults " set background= -set t_te= t_ti= laststatus=2 - +" 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 +"set mouse=a syntax off filetype on 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 -let g:vimki_lower = "a-zàçéèêếëîïñôöùûü" autocmd filetype vimki syntax on autocmd filetype vimki set autowrite -autocmd filetype vimki setlocal spell spelllang=fr +" autocmd filetype vimki setlocal spell spelllang=fr autocmd filetype vimki nmap <leader>z :FZF ~/Wiki<CR> +" autocmd filetype markdown,text,vimki setlocal textwidth=72 -autocmd filetype vimki nnoremap <leader>= YpVr= -autocmd filetype vimki nnoremap <leader>- YpVr- - -" 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 = "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 let g:netrw_browsex_viewer = "open" let g:netrw_gx = "<cWORD>" let g:netrw_banner = 0 -autocmd filetype javascript,html,json,yaml set ts=2 sts=2 sw=2 et +" python and yaml formatting: +" autocmd filetype python,yaml set ts=2 sts=2 sw=2 et -" :set wm=2 linebreak -" :set term=ansi -":set modeline -":set modelines=5 -set autoindent -"set breakindent -" :set ts=2 sw=2 sts=2 et :set wrap :set linebreak :set nolist @@ -59,13 +66,15 @@ set autoindent " 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 " @@ -79,3 +88,70 @@ noremap <leader>n :bn<cr> noremap <leader><leader> :bd<cr> noremap <leader>o :!open <cWORD>&<cr><cr> noremap <C-g> :tag <c-r><c-w><cr> +noremap <C-p> :Files<cr> + +" 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 +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 + +" 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> |
