diff --git a/.Xresources.light b/.Xresources.light index 60a683a8..c4264143 100644 --- a/.Xresources.light +++ b/.Xresources.light @@ -1,41 +1,41 @@ -*background: #fdf6e3 -*foreground: #657b83 -*fadeColor: #fdf6e3 -*cursorColor: #586e75 -*pointerColorBackground:#93a1a1 -*pointerColorForeground:#586e75 - -!! black dark/light -*color0: #073642 -*color8: #002b36 - -!! red dark/light -*color1: #dc322f -*color9: #cb4b16 - -!! green dark/light -*color2: #859900 -*color10: #586e75 - -!! yellow dark/light -*color3: #b58900 -*color11: #657b83 - -!! blue dark/light -*color4: #268bd2 -*color12: #839496 - -!! magenta dark/light -*color5: #d33682 -*color13: #6c71c4 - -!! cyan dark/light -*color6: #2aa198 -*color14: #93a1a1 - -!! white dark/light -*color7: #eee8d5 -*color15: #fdf6e3 +*.foreground: #141518 +*.background: #fafafa +*.cursorColor: #bfceff +! +! Black +*.color0: #383a42 +*.color8: #4f525e +! +! Red +*.color1: #e45649 +*.color9: #e06c75 +! +! Green +*.color2: #50a14f +*.color10: #98c379 +! +! Yellow +*.color3: #c18401 +*.color11: #e5c07b +! +! Blue +*.color4: #0184bc +*.color12: #61afef +! +! Magenta +*.color5: #a626a4 +*.color13: #c678dd +! +! Cyan +*.color6: #0997b3 +*.color14: #56b6c2 +! +! White +*.color7: #fafafa +*.color15: #ffffff +! +! Bold, Italic, Underline +*.colorBD: #1d1e22 rofi.color-normal: #eeeeee, #444444, #eeeeee, #af8700, #ffffff rofi.color-active: #eeeeee, #444444, #eeeeee, #af8700, #ffffff diff --git a/.config/i3/config.base b/.config/i3/config.base index 8f80c968..b1de47d4 100644 --- a/.config/i3/config.base +++ b/.config/i3/config.base @@ -108,7 +108,7 @@ for_window [class="obsidian"] floating enable for_window [class="skype"] floating enable for_window [class="Skype"] floating enable for_window [class="Upwork"] floating enable -for_window [class=".*"] border pixel 4 +for_window [class=".*"] border pixel 1 client.focused #D22B2B #D22B2B #D22B2B #D22B2B client.focused_inactive #424242 #424242 #424242 #424242 diff --git a/.vim/snippets/go.snippets b/.vim/snippets/go.snippets index 9a49a2f1..e05e5847 100644 --- a/.vim/snippets/go.snippets +++ b/.vim/snippets/go.snippets @@ -1,6 +1,7 @@ global !p from snippets import * from snippets.go import * +import time def get_indent_levels(snip, base_line): if snip.context is None: @@ -448,3 +449,15 @@ else: snip.rv = "\`"+tag+"\`" ` endsnippet + +snippet ms "" w +`!p +try: + once +except: + now = str(int(time.time())) + once = True +`at`!p snip.rv=now` := time.Now() +${VISUAL} +fmt.Fprintf(os.Stderr, "XXXXXX $1 took: %v\n", time.Since(at`!p snip.rv=now`).Nanoseconds()) +endsnippet diff --git a/.zshrc b/.zshrc index a1a0d240..32c881d3 100644 --- a/.zshrc +++ b/.zshrc @@ -123,7 +123,7 @@ docompinit() { { if [[ "$BACKGROUND" == "light" ]]; then - #export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=9" + export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=9" fi } @@ -189,18 +189,7 @@ docompinit() { return fi - local dir=$PWD - local basename=${dir/*\/} - local relative=$(realpath --relative-to=$HOME $dir/.. \ - | sed -r 's@([^/]{1})[^/]{2,}@\1@g' - ) - if [[ "$relative" =~ ^\\.\\. ]]; then - echo "$dir" - elif [[ "$relative" == "." ]]; then - echo "~/$basename" - else - echo "~/$relative/$basename" - fi + zsh-prompt } zstyle -d "lambda17:00-main" transform @@ -1555,25 +1544,25 @@ alias jxg='sudo journalctl -xe | grep ' alias jxfg='sudo journalctl -xef | grep ' alias wh='() { while :; do eval "${@}"; sleep 0.5; done }' -export TUBEKIT_DEBUG=1 -alias krun='() { :kubectl $1 run -i --tty --image radial/busyboxplus busybox-$RANDOM --restart=Never --rm }' - -alias k='tubectl' :helm-context() { helm --kube-context "${@}" } +alias he=':helm-context' :kail-context() { local context="$1" shift kail --since 5m --context "${context}" "${@}" } - -alias he=':helm-context' alias ka=':kail-context' alias kap=':kail-app' + +# kubectl +export TUBEKIT_DEBUG=1 + +alias k='tubectl' alias kg='tubectl get' alias kgd='kg deployments' alias kgc='kg configmap' @@ -1584,12 +1573,13 @@ alias kgs='kg sts' alias kp='kgp' alias kt='tubectl edit' -alias ktd='tubectl edit deployment' -alias ktc='tubectl edit configmap' -alias kti='tubectl edit ingress' +alias ktd='kt deployment' +alias ktc='kt configmap' +alias kts='kt statefulset' +alias kti='kt ingress' alias kd='tubectl describe' -alias kdp='kd pods' +alias kdp='kd pod' alias kdd='kd deployment' alias kds='kd sts' @@ -1604,6 +1594,7 @@ alias kss='ks statefulset' alias kl='tubectl logs' alias klf='() { kl "${@}" -f --tail 1 }' + alias ke='tubectl exec' alias ki='() { tubectl exec "${@}" -it -- sh -c "bash -i || sh -i" }' alias kv='tubectl get events' @@ -1611,8 +1602,10 @@ alias kv='tubectl get events' alias gob='go build' alias goi='go install' -#alias -g -- '-ya'='-o yaml' -#alias -g -- '-ow'='-o wide' +alias -g -- '\kya'='-o yaml' +alias -g -- '\kow'='-o wide' + +# ssh settings ssh-add ~/.ssh/id_rsa 2>/dev/null stty -ixon @@ -1629,6 +1622,11 @@ source ~/.zgen/fzf.zsh || { source ~/.zgen/fzf.zsh } +source ~/.zgen/kafkactl.zsh || { + kafkactl completion zsh > ~/.zgen/kafkactl.zsh + source ~/.zgen/kafkactl.zsh +} + eval $(dircolors ~/.dircolors.$BACKGROUND) unset -f colors @@ -1642,7 +1640,3 @@ if [[ "$HISTFILE_OVERRIDE" ]]; then fi setopt share_history - -fuck() { - sudo !! -} diff --git a/bin/autoxrandr b/bin/autoxrandr index 25c0c2a8..0ec575e1 100755 --- a/bin/autoxrandr +++ b/bin/autoxrandr @@ -29,6 +29,11 @@ if [[ "$profile" == "desktop" ]]; then cmd+=(--output $TV --mode 1920x1080 --above $CENTER) fi + if [[ "${1:-}" == "-p" ]]; then + echo "xrandr ${cmd[@]}" + exit 0 + fi + xrandr "${cmd[@]}" fi diff --git a/bin/background-switch b/bin/background-switch index 9bd54a6e..db4ba551 100755 --- a/bin/background-switch +++ b/bin/background-switch @@ -7,6 +7,7 @@ files = [ commands = [ "xrdb -load ~/.Xresources", "xrdb -merge ~/.Xresources.theme", + "i3-polybar", ] background = ARGV[0] @@ -16,11 +17,11 @@ if !background exit(0) end -files.each do|file| - link = file + "." + background - cmd = "ln -sf " + link + " " + file + ".theme" - system(cmd) -end +cmd = "ln -sf ~/.Xresources." + background + " ~/.Xresources.theme" +system(cmd) + +cmd = "ln -sf ~/.config/polybar/theme." + background + " ~/.config/polybar/theme.ini" +system(cmd) commands.each do|command| puts command diff --git a/bin/docker-ip b/bin/docker-ip new file mode 100755 index 00000000..032d5445 --- /dev/null +++ b/bin/docker-ip @@ -0,0 +1,9 @@ +#!/bin/bash + +for container in $(docker ps -q); do + json=$(docker inspect "$container") + name=$(jq <<< "$json" -r '.[0] | .Name') + ip=$(jq <<< "$json" -r '.[0] | .NetworkSettings.Networks | .[] | .IPAddress' \ + | sort | uniq | paste -sd' ') + echo "${name}: ${ip}" +done diff --git a/bin/go-mod-watch b/bin/go-mod-watch index 9686c759..2753e952 100755 --- a/bin/go-mod-watch +++ b/bin/go-mod-watch @@ -31,4 +31,4 @@ fi go mod tidy -sleep 5 +sleep 1 diff --git a/bin/k8s-mass-port-forward b/bin/k8s-mass-port-forward new file mode 100755 index 00000000..8da64a2b --- /dev/null +++ b/bin/k8s-mass-port-forward @@ -0,0 +1,12 @@ +#!/bin/bash + +files=() +while [[ "${1:-}" ]]; do + if [[ "$1" =~ .*=.* ]]; then + eval "export $1" + else + files+=("$1") + fi + + shift +done diff --git a/bin/reboot-this b/bin/reboot-this new file mode 100755 index 00000000..0c49f164 --- /dev/null +++ b/bin/reboot-this @@ -0,0 +1,6 @@ +#!/bin/bash + +current=$(efibootmgr | awk '/BootCurrent: /{print $2}') + +sudo efibootmgr -n "${current}" +sudo reboot diff --git a/bin/wait-host b/bin/wait-host new file mode 100755 index 00000000..195eaf20 --- /dev/null +++ b/bin/wait-host @@ -0,0 +1,20 @@ +#!/bin/bash + +hosts=() +while [[ "${1:-}" ]]; do + hosts+=("$1") + shift +done + +while :; do + success=true + for host in "${hosts[@]}"; do + if ! host "${host}"; then + success=false + fi + done + + if $success; then + break + fi +done diff --git a/bin/xkb b/bin/xkb index cb1cd63c..ad9dea5f 100755 --- a/bin/xkb +++ b/bin/xkb @@ -8,7 +8,7 @@ xkbcomp -w 0 -I$HOME/.xkb -R$HOME/.xkb $HOME/.xkbrc${MODE} $DISPLAY xset -b -repeat_delay=110 +repeat_delay=130 repeat_rate=170 # That chinese keyboard somehow has decreased repeat delay with comparison to diff --git a/bin/zfs-info b/bin/zfs-info new file mode 100755 index 00000000..12e113fd --- /dev/null +++ b/bin/zfs-info @@ -0,0 +1,11 @@ +#!/bin/bash + +alloc=$(zpool list -o alloc -H zroot) +size=$(zpool list -o size -H zroot) + +alloc=${alloc//G/} +size=${size//G/} + +free_percent=$(echo "scale=2; 100*${alloc}/${size}" | bc) + +echo " ${free_percent}% ${size}G" diff --git a/bin/zsh-prompt b/bin/zsh-prompt new file mode 100755 index 00000000..5f663d12 --- /dev/null +++ b/bin/zsh-prompt @@ -0,0 +1,36 @@ +#!/bin/env python3 +# vim: ft=python + +import os +import os.path +import sys +from pathlib import Path + +def get_prompt(): + cwd = os.getcwd() + if len(sys.argv) > 1: + cwd = sys.argv[1] + + home = Path.home() + + relative = os.path.relpath(cwd, home) + if '../' in relative: + print(cwd) + return + + chunks = relative.split('/') + for i in range(len(chunks) - 1): + chunk = chunks[i] + if chunk.startswith('.'): + continue + + if len(chunk) > 3: + chunk = chunk[:1] + + chunks[i] = chunk + + print('~/' + '/'.join(chunks)) + return + +if __name__ == "__main__": + get_prompt() diff --git a/vim.d/01-plugins.vim b/vim.d/01-plugins.vim index d58db9b8..abab96e5 100644 --- a/vim.d/01-plugins.vim +++ b/vim.d/01-plugins.vim @@ -137,5 +137,6 @@ Plug 'mogelbrod/vim-jsonpath' Plug 'ziglang/zig.vim' Plug 'mfussenegger/nvim-dap' +Plug 'sonph/onehalf', { 'rtp': 'vim' } call plug#end() diff --git a/vim.d/02-colors.vim b/vim.d/02-colors.vim index 5c0384b9..b075c37a 100644 --- a/vim.d/02-colors.vim +++ b/vim.d/02-colors.vim @@ -1,4 +1,5 @@ set termguicolors +set cursorline if $BACKGROUND == "dark" func! _setup_colorscheme() @@ -22,7 +23,7 @@ endif if $BACKGROUND == "light" func! _setup_colorscheme() - colorscheme solarized8 + colorscheme onehalflight set background=light hi! Normal ctermfg=NONE ctermbg=NONE guibg=NONE guifg=#657b83 @@ -35,5 +36,10 @@ if $BACKGROUND == "light" "hi! PreProc ctermfg=19 hi! LineNr guibg=NONE hi! CursorLineNr guibg=NONE guifg=#cb4b16 + + hi! CocCursorRange guibg=#b16286 guifg=#ebdbb2 ctermbg=5 ctermfg=3 + hi! Pmenu guibg=#ffffff guifg=#141518 + hi! CocErrorHighlight guibg=NONE guifg=#e45649 + hi! CocErrorSign guifg=#e45649 guibg=NONE endfunc! endif diff --git a/vim.d/46-lightline.vim b/vim.d/46-lightline.vim index 0d5abc17..30beb16c 100644 --- a/vim.d/46-lightline.vim +++ b/vim.d/46-lightline.vim @@ -29,7 +29,7 @@ let g:lightline.enable = { \ } if &background == "light" - let g:lightline.colorscheme = 'one' + let g:lightline.colorscheme = 'onehalflight' else let g:lightline.colorscheme = 'dracula' endif diff --git a/vim.d/50-misc-autogroup.vim b/vim.d/50-misc-autogroup.vim index 827ea9e0..b5c4ad76 100644 --- a/vim.d/50-misc-autogroup.vim +++ b/vim.d/50-misc-autogroup.vim @@ -1,14 +1,26 @@ augroup _filetypes au! - au BufRead,BufNewFile *.service set noet ft=systemd - au BufRead,BufNewFile PKGBUILD set et ft=pkgbuild.sh - au BufRead,BufNewFile *.snippets set noet ft=snippets.python - au BufRead,BufNewFile *.skeleton set noet ft=snippets.python - au BufRead,BufNewFile *.chart set noet ft=mermaid - au BufRead,BufNewFile *.go set noet + au BufRead,BufNewFile *.service setlocal noet ft=systemd + au BufRead,BufNewFile PKGBUILD setlocal et ft=pkgbuild.sh + au BufRead,BufNewFile *.snippets setlocal noet ft=snippets.python + au BufRead,BufNewFile *.skeleton setlocal noet ft=snippets.python + au BufRead,BufNewFile *.chart setlocal noet ft=mermaid + au BufRead,BufNewFile *.go setlocal noet + au BufRead,BufNewFile *.config setlocal et ft=json ts=2 sw=2 sts=2 au FileType python setlocal et ts=4 sw=4 sts=4 augroup end +fun! _trim_whitespace() + let l:save = winsaveview() + keeppatterns %s/\s\+$//e + call winrestview(l:save) +endfun + +augroup _whitespaces + au! + au BufWritePre *.yml,*.yaml,*.config call _trim_whitespace() +augroup end + augroup _misc au! diff --git a/vim.d/63-langs-go.vim b/vim.d/63-langs-go.vim index 8b098b03..cfe17edb 100644 --- a/vim.d/63-langs-go.vim +++ b/vim.d/63-langs-go.vim @@ -18,7 +18,13 @@ augroup _code_go \ 'goimports') augroup end +let g:_setup_local_go_finished = 0 func! _setup_local_go() + if g:_setup_local_go_finished == 0 + let g:_job_go_mod_watch = jobstart(['go-mod-watch']) + let g:_setup_local_go_finished = 1 + endif + nnoremap @l :call _search_wrappable()ll:ArgWrap nnoremap @h :call _chain_wrap(1) @@ -37,7 +43,7 @@ func! _setup_local_go() let b:argwrap_tail_comma = 1 let b:ale_fix_on_save = 1 - call ale#Set('go_golines_max_length', '120') + call ale#Set('go_golines_max_length', '200') setlocal cc=80,100 endfunc!