Skip to content

Commit

Permalink
add a little bit of everyday improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Egor Kovetskiy <[email protected]>
  • Loading branch information
kovetskiy committed Sep 1, 2022
1 parent b7f23e8 commit 420774a
Show file tree
Hide file tree
Showing 19 changed files with 216 additions and 84 deletions.
76 changes: 38 additions & 38 deletions .Xresources.light
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion .config/i3/config.base
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions .vim/snippets/go.snippets
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
52 changes: 23 additions & 29 deletions .zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ docompinit() {

{
if [[ "$BACKGROUND" == "light" ]]; then
#export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=9"
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=9"
fi
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand All @@ -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'

Expand All @@ -1604,15 +1594,18 @@ 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'

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
Expand All @@ -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
Expand All @@ -1642,7 +1640,3 @@ if [[ "$HISTFILE_OVERRIDE" ]]; then
fi

setopt share_history

fuck() {
sudo !!
}
5 changes: 5 additions & 0 deletions bin/autoxrandr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 6 additions & 5 deletions bin/background-switch
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ files = [
commands = [
"xrdb -load ~/.Xresources",
"xrdb -merge ~/.Xresources.theme",
"i3-polybar",
]

background = ARGV[0]
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions bin/docker-ip
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion bin/go-mod-watch
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ fi

go mod tidy

sleep 5
sleep 1
12 changes: 12 additions & 0 deletions bin/k8s-mass-port-forward
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

files=()
while [[ "${1:-}" ]]; do
if [[ "$1" =~ .*=.* ]]; then
eval "export $1"
else
files+=("$1")
fi

shift
done
6 changes: 6 additions & 0 deletions bin/reboot-this
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

current=$(efibootmgr | awk '/BootCurrent: /{print $2}')

sudo efibootmgr -n "${current}"
sudo reboot
20 changes: 20 additions & 0 deletions bin/wait-host
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion bin/xkb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions bin/zfs-info
Original file line number Diff line number Diff line change
@@ -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"
36 changes: 36 additions & 0 deletions bin/zsh-prompt
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions vim.d/01-plugins.vim
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,6 @@ Plug 'mogelbrod/vim-jsonpath'
Plug 'ziglang/zig.vim'
Plug 'mfussenegger/nvim-dap'
Plug 'sonph/onehalf', { 'rtp': 'vim' }

call plug#end()
Loading

0 comments on commit 420774a

Please sign in to comment.