diff --git a/.config/coc/extensions/package.json b/.config/coc/extensions/package.json index 578e1f14..6586cdcd 100755 --- a/.config/coc/extensions/package.json +++ b/.config/coc/extensions/package.json @@ -15,10 +15,11 @@ "coc-xml": ">=1.14.1", "coc-yaml": ">=1.8.0", "coc-zig": ">=0.6.1", - "coc-clangd": ">=0.28.0", - "coc-prettier": ">=9.3.1" + "coc-clangd": ">=0.29.3", + "coc-prettier": ">=9.3.1", + "coc-rust-analyzer": ">=0.75.0" }, "disabled": [], "locked": [], - "lastUpdate": 1683017894840 + "lastUpdate": 1709112918684 } \ No newline at end of file diff --git a/.config/i3/config.base b/.config/i3/config.base index 88e6e06a..27631b32 100644 --- a/.config/i3/config.base +++ b/.config/i3/config.base @@ -82,14 +82,10 @@ mode "resize" { bindsym Escape mode "default" } -# dell poweroff button -bindcode 124 exec poweroff - bindcode 171 exec playerctl next bindcode 172 exec playerctl play-pause bindcode 173 exec playerctl previous - for_window [title="tudu"] floating enable for_window [class="zoom"] floating enable for_window [class="kuake"] floating enable diff --git a/.config/i3/config.laptop b/.config/i3/config.laptop new file mode 100644 index 00000000..cec64717 --- /dev/null +++ b/.config/i3/config.laptop @@ -0,0 +1,17 @@ +set $left DVI-I-4-4 +set $center eDP1 +set $right DVI-I-1-1 + +workspace 1 output $center +workspace 2 output $center +workspace 3 output $center +workspace 4 output $center +workspace s output $center + +workspace a output $left +workspace z output $left +workspace d output $left + +workspace q output $right +workspace w output $right +workspace e output $right diff --git a/.tmux.conf b/.tmux.conf index ebac9b5a..06276050 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -9,15 +9,18 @@ set -g status-left '' set -g status-left-length 100 set -g status-right '' set -g status-position top -set -g window-status-current-format "window-status-current-format" -set -g window-status-format "window-status-format" +set -g window-status-current-format "#I:#W#F" +set -g window-status-format "#I:#W#F" #set -g force-height 1 set -g escape-time 0 set -g history-limit 2000 set -g set-titles on -set-option -g automatic-rename on -set-option -g automatic-rename-format 'asd' +## Update pane title when command changes +#set -g pane-border-format '#[fg=green]#{pane_current_path}#[default]' +#set -g pane-border-status top +#set -g set-titles on +#set -g automatic-rename on bind-key -Tcopy-mode-vi Escape send-keys -X cancel bind-key -Tcopy-mode-vi Enter send-keys -X copy-pipe-and-cancel clipboard-copy @@ -48,8 +51,21 @@ set -g mode-keys vi bind-key -n M-/ copy-mode \; send-key ? bind p paste-buffer -set -g default-terminal screen-256color +set -g default-terminal alacritty bind-key -Tcopy-mode-vi q send-keys -X begin-selection set -g destroy-unattached off + + +# List of plugins +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-sensible' + +set -g @treemux-tree-width 50 + +set -g @treemux-tree-nvim-init-file '~/.tmux/plugins/treemux/configs/treemux_init.lua' +set -g @plugin 'kiyoon/treemux' + +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +run '~/.tmux/plugins/tpm/tpm' diff --git a/.vim/coc-settings.json b/.vim/coc-settings.json index 8edbb34b..ebd6e88f 100755 --- a/.vim/coc-settings.json +++ b/.vim/coc-settings.json @@ -1,4 +1,5 @@ { + "workspace.ignoredFolders": ["$HOME", "$HOME/.cargo/**", "$HOME/.rustup/**"], "suggest.noselect": true, "suggest.enablePreselect": false, "diagnostic.errorSign": "\\ E", @@ -28,6 +29,13 @@ "tsserver.log": "verbose", "tsserver.trace.server": "verbose", "languageserver": { + "terraform": { + "command": "terraform-ls", + "args": ["serve"], + "filetypes": ["terraform", "tf"], + "initializationOptions": {}, + "settings": {} + }, "golangci-lint-languageserver": { "command": "golangci-lint-langserver", "filetypes": ["go"], @@ -71,6 +79,8 @@ "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces": true, "go.trace.server": "verbose", "go.goplsOptions": { + "allowModfileModifications": true, + "allowImplicitNetworkAccess":true, "gofumpt": false, "codelenses": { "generate": true, @@ -86,7 +96,6 @@ "hoverKind": "FullDocumentation", "verboseOutput": true }, - "go.goplsPath": "/home/operator/go/bin/gopls", "java.jdt.ls.vmargs": "-noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication -javaagent:\"/home/operator/.config/coc/extensions/node_modules/coc-java-lombok/jar/lombok.jar\"", "java.format.settings.url": "/home/operator/sources/github.com/neoclide/redhat.java/eclipse-formatter.xml", "typescript.validate.enable": true, diff --git a/.zshrc b/.zshrc index 91dbb328..dae591a6 100644 --- a/.zshrc +++ b/.zshrc @@ -1,6 +1,6 @@ . ~/bin/environment-variables -export TERM=screen-256color +export TERM=alacritty export KEYTIMEOUT=100 export WORDCHARS=- @@ -117,7 +117,6 @@ docompinit() { compdef github-browse=ls compdef man-directive=man compdef vim-which=which - compdef smash=ssh compdef guess=which compdef _git gdd=git-checkout } @@ -245,10 +244,35 @@ docompinit() { setopt hist_ignore_space setopt hist_verify setopt inc_append_history - setopt inc_append_history_time setopt share_history setopt hist_save_by_copy + + # If the internal history needs to be trimmed to add the current command line, + # setting this option will cause the oldest history event that has a duplicate + # to be lost before losing a unique event from the list. You should be sure to + # set the value of HISTSIZE to a larger number than SAVEHIST in order to give + # you some room for the duplicated events, otherwise this option will behave + # just like HIST_IGNORE_ALL_DUPS once the history fills up with unique events. + # + # ^disabled + unsetopt histexpiredupsfirst + + # If a new command line being added to the history list duplicates an older + # one, the older command is removed from the list (even if it is not the + # previous event). + # + # ^disabled + unsetopt histignorealldups + + # Do not enter command lines into the history list if they are duplicates of the + # previous event. + # + # ^ enabled + setopt hist_ignore_dups + + unsetopt hist_save_no_dups + zstyle ':zle:smart-kill-word' precise always zstyle ':zle:smart-kill-word' keep-slash true } @@ -335,15 +359,15 @@ docompinit() { for file in "${files[@]}"; do if $diff; then after=$(mktemp -u) - sed -r "s/$from/$to/g" $file > $after - git diff --color $file $after | diff-so-fancy + sed -r "s/$from/$to/" $file > $after + git diff $file $after else - sed -ri "s/$from/$to/g" $file + sed -ri "s/$from/$to/" $file fi done else - sed -r "s/$from/$to/g" + sed -r "s/$from/$to/" fi } @@ -445,80 +469,6 @@ docompinit() { git remote add origin "$new_url" } - go-get-enhanced() { - if [ $# -eq 0 ]; then - go get - return - fi - - local url="" - local dir="" - local flags=("-v") - local update=false - if [ "$1" = "u" -o "$1" = "-u" -o "$1" = "-" ]; then - flags+=("-u") - update=true - shift - fi - - if [ $# -eq 0 ]; then - go get ${flags[@]} - return - fi - - import=$(sed 's/.*:\/\///' <<< "$1") - shift - - flags+=("$@") - local slashes=$(grep -o '/' <<< "$import" | wc -l) - if [ $slashes = 1 ]; then - user=$(cut -d/ -f1 <<< "$import") - repo=$(cut -d/ -f2 <<< "$import") - case "$user" in - s) - import="seletskiy/$repo" - ;; - - r) - import="reconquest/$repo" - ;; - - d) - import="deadcrew/$repo" - ;; - esac - - import="github.com/$import" - fi - - if $update && [ $slashes = 0 ]; then - dependency_import=$( - go list -f \ - '{{ range $dep := .Deps }}{{ $dep }}{{ "\n" }}{{ end }}' . \ - | awk "/\/$import\$/ { print }" - ) - if [ "$dependency_import" ]; then - import=$dependency_import - fi - fi - - if [ ! "$dependency_import" ] && [ $slashes = 0 ]; then - import="github.com/kovetskiy/$import" - fi - - go get ${flags[@]} $import - - dir=$GOPATH/src/$import - if [[ "$dir" == *.git ]]; then - dir=$(sed 's/\.git//' <<< "$dir") - fi - - if [ -d $dir ]; then - cd $dir - git submodule update --init - fi - } - create-and-change-directory() { mkdir -p "$@" cd "$@" @@ -737,13 +687,6 @@ docompinit() { git clean -ffdx } - ssh-enhanced() { - local hostname="$1" - tmux set status on - tmux set status-left "# $hostname" - smash -z "$@" - tmux set status off - } makepkg-clean() { local branch="$1" rm -rf *.xz @@ -1446,7 +1389,6 @@ alias f=':find' alias si='ssh-copy-id' alias cdp='cd-pkgbuild' -alias gog='go-get-enhanced' alias gme='go-makepkg-enhanced' alias gmev='FLAGS="-p version" go-makepkg-enhanced' alias gmevs='FLAGS="-p version -s" go-makepkg-enhanced' @@ -1674,9 +1616,8 @@ alias ask='ai-ask' alias -g -- '\kya'='-o yaml' alias -g -- '\kow'='-o wide' -# ssh settings +alias gmf='sed -i "/replace/d" go.mod; go mod tidy' -ssh-add ~/.ssh/id_rsa 2>/dev/null stty -ixon FZF_TMUX_HEIGHT=0 @@ -1700,16 +1641,16 @@ eval $(dircolors ~/.dircolors.$BACKGROUND) unset -f colors -export HISTSIZE=100000 -export SAVEHIST=1000000000000 +export HISTSIZE=100000000 +export SAVEHIST=100000000 +# HIST_IGNORE_DUPS +#HIST_SAVE_BY_COPY +#HIST_IGNORE_ALL_DUPS export HISTFILE=~/history/zsh_history if [[ "$HISTFILE_OVERRIDE" ]]; then export HISTFILE=$HISTFILE_OVERRIDE fi -setopt share_history - source ~/.guts/zsh/*.zsh - #source /usr/share/nvm/init-nvm.sh diff --git a/bin/battery-info b/bin/battery-info new file mode 100755 index 00000000..97f2d577 --- /dev/null +++ b/bin/battery-info @@ -0,0 +1,22 @@ +#!/bin/bash + +:get-section-battery() { + battery=$(acpi -b 2>/dev/null \ + | grep -v 'rate information unavailable' \ + | sed -r \ + -e 's/Battery [0-9]:\s*//' \ + -e 's/ until charged//' \ + -e 's/ remaining//' \ + -e 's/Discharging,/↓/' \ + -e 's/Full,/✓/' \ + -e 's/Not charging/✓/' \ + -e 's/discharging at zero rate - will never fully discharge./∞/' \ + -e 's/,//') + if [[ "$battery" =~ "rate information unavailable" ]]; then + return + fi + + echo "$battery" +} + +:get-section-battery "$@" diff --git a/bin/browser b/bin/browser index 799b6624..0aee99af 100755 --- a/bin/browser +++ b/bin/browser @@ -1,28 +1,60 @@ -#!/bin/bash - -[ -n "$_LOCK" ] || _LOCK=x exec flock -n $0 $0 "$@" - -url=$(sed -r 's#^(git+ssh|ssh|git)://(\w+@)?##' <<< "$1") -params="${@:2}" - -scheme=$(grep -Po '^\w+://' <<< "$url") -if [[ "$scheme" != "http://" - && "$scheme" != "https://" - && "$scheme" != "ftp://" - && "$scheme" != "file://" - && "$scheme" != "" ]]; then - notify "Unexpected scheme: '$scheme'" - exit 1 -fi - -if [[ -e "${url}" ]]; then - url="$(readlink -f "${url}")" -fi - -browser="chromium" - -if [[ "$url" ]]; then - i3-msg "exec \"$browser \\\"$url\\\"" -else - i3-msg "exec $browser" -fi +#!/bin/env python3 +# vim: ft=python + +import sys +import os +import os.path +import subprocess +from urllib.parse import urlparse, urlunparse + +url = sys.argv[1] if len(sys.argv) > 1 else '' +parsed_url = urlparse(url) + +if parsed_url.scheme in ['tc']: + subprocess.run(['i3-msg', 'exec mtw ' + url]) + exit(0) + +if parsed_url.scheme in ['git+ssh', 'ssh', 'git']: + scheme = 'https' + netloc = parsed_url.netloc.replace('git@', '') + path = parsed_url.path + if path.endswith('.git'): + path = path[:-4] + url = urlunparse((scheme, netloc, path, '', '', '')) + +if parsed_url.scheme == '' and url.startswith('git@'): + scheme = 'https' + if ':' in parsed_url.path.split('/')[0]: + chunks = parsed_url.path.split(':', 2) + netloc = chunks[0].replace('git@', '') + path = chunks[1] + else: + netloc = parsed_url.netloc + path = parsed_url.path + + if path.endswith('.git'): + path = path[:-4] + + url = urlunparse((scheme, netloc, path, '', '', '')) + +if parsed_url.scheme == '' and url != '': + file_path = parsed_url.path + if os.path.exists(file_path): + scheme = 'file' + url = urlunparse((scheme, '', file_path, '', '', '')) + else: + raise Exception(f'File {file_path} does not exist') + +browser = 'chromium' + +cmd = [browser] +if url: + cmd.append(url) + if len(sys.argv) > 2: + cmd.extend(sys.argv[2:]) + i3_cmd = f"exec {' '.join(map(subprocess.list2cmdline, [cmd]))}" +else: + i3_cmd = f"exec {browser}" + +print(i3_cmd) +subprocess.run(['i3-msg', i3_cmd]) diff --git a/bin/go-mod-watch b/bin/go-mod-watch index 694ae9f7..a168bc54 100755 --- a/bin/go-mod-watch +++ b/bin/go-mod-watch @@ -35,4 +35,9 @@ fi :blue ":: go mod tidy" go mod tidy +if [[ -d "vendor" ]]; then + :blue ":: go mod vendor" + go mod vendor +fi + sleep 1 diff --git a/bin/i3-config b/bin/i3-config index ee9cdcf7..ec3875d6 100755 --- a/bin/i3-config +++ b/bin/i3-config @@ -8,6 +8,8 @@ config="$(cat ~/.config/i3/config.base)" if [[ -f ~/.config/i3/config.${profile} ]]; then echo ":: loading ~/.config/i3/config.${profile}" >&2 config="${config}"$'\n'"$(cat ~/.config/i3/config.${profile})" +else + echo ":: ~/.config/i3/config.${profile} not found" >&2 fi nagbar="# MANAGED BY i3-config DO NOT EDIT MANUALLY" diff --git a/bin/modal-tabs b/bin/modal-tabs index dd4f5e25..0160ba35 100755 --- a/bin/modal-tabs +++ b/bin/modal-tabs @@ -1,6 +1,6 @@ #!/bin/bash -tabs=$(curl -s "http://localhost:3451/rpc?command=list_tabs") +tabs=$(curl -m 1 -s "http://localhost:3451/rpc?command=list_tabs") pick=$( echo "$tabs" \ diff --git a/bin/screen-lock b/bin/screen-lock index 169cea17..8d9c4625 100755 --- a/bin/screen-lock +++ b/bin/screen-lock @@ -1,24 +1,28 @@ #!/bin/bash -export XSECURELOCK_DISCARD_FIRST_KEYPRESS=0 -export XSECURELOCK_SHOW_DATETIME=1 -export XSECURELOCK_PASSWORD_PROMPT=kaomoji +import -window root /tmp/s.png +convert /tmp/s.png /tmp/s_blurred.png +exec i3lock -i /tmp/s_blurred.png -volume=$(volumectl get) +#export XSECURELOCK_DISCARD_FIRST_KEYPRESS=0 +#export XSECURELOCK_SHOW_DATETIME=1 +#export XSECURELOCK_PASSWORD_PROMPT=kaomoji -volumectl down $volume +#volume=$(volumectl get) -song=$(spotify_status -q) -if [[ "$song" ]]; then - playerctl play-pause -fi +#volumectl down $volume -xsecurelock +#song=$(spotify_status -q) +#if [[ "$song" ]]; then +# playerctl play-pause +#fi -if [[ "$song" ]]; then - playerctl play-pause -fi +#xsecurelock -volumectl up $volume +#if [[ "$song" ]]; then +# playerctl play-pause +#fi -(sleep 5 && pidof polybar && i3-polybar) & +#volumectl up $volume + +#(sleep 5 && pidof polybar && i3-polybar) & diff --git a/bin/telegram-desktop b/bin/telegram-desktop index fb3a3195..3717f9e5 100755 --- a/bin/telegram-desktop +++ b/bin/telegram-desktop @@ -1,8 +1,16 @@ #!/bin/bash +# if args passed, then just run i3-msg 'workspace $1; exec telegram-desktop "$@"' + +set -x xd_class="telegram-desktop" ws=q +if [[ $# -gt 0 ]]; then + /bin/telegram-desktop "${@}" & + exit 0 +fi + :current() { i3-msg -t get_workspaces \ | jq '.[] | select(.focused==true).name' \ diff --git a/bin/wg-ui b/bin/wg-ui index 442a2208..84a34197 100755 --- a/bin/wg-ui +++ b/bin/wg-ui @@ -1,7 +1,7 @@ #!/bin/bash :peers() { - systemctl list-units --no-legend --no-pager | grep -Po 'wg-quick@\K.*(?=.service)' + sudo wg show all peers | awk '{print $1}' } :join() { @@ -14,19 +14,25 @@ :is-active() { local id="$1" - [[ "$(systemctl is-active "wg-quick@$id.service")" == "active" ]] + if :peers | grep -q "$id"; then + return 0 + fi + + return 1 } :down() { local id="$1" - sudo systemctl stop "wg-quick@$id.service" + sudo systemctl stop "wg-quick@$id.service" 2>/dev/null + wg-quick down "$id" 2>/dev/null } :up() { local id="$1" - sudo systemctl start "wg-quick@$id.service" + #sudo systemctl start "wg-quick@$id.service" 2>/dev/null + wg-quick up "$id" 2>/dev/null } :main() { @@ -73,23 +79,74 @@ fi if [[ "$mode" == "switch" ]]; then - # support only two id - id1="$2" - id2="$3" - - if :is-active "$id1"; then - :down "$id1" - echo "[!] $id1 is down" - :up "$id2" - echo "[!] $id2 is up" - else - if :is-active "$id2"; then - :down "$id2" - echo "[!] $id2 is down" + set -x + ## support only two id + #id1="$2" + #id2="$3" + + #if :is-active "$id1"; then + # :down "$id1" + # echo "[!] $id1 is down" + # :up "$id2" + # echo "[!] $id2 is up" + #else + # if :is-active "$id2"; then + # :down "$id2" + # echo "[!] $id2 is down" + # fi + # :up "$id1" + # echo "[!] $id1 is up" + #fi + list=(${@:2}) + total="${#list[@]}" + last="${list[-1]}" + + for ((i=0; i