1
0
Fork 0
This commit is contained in:
Arthur K. 2026-01-06 07:36:53 +03:00
parent c449dfcb5f
commit 559939e2f4
Signed by: wzray
GPG key ID: B97F30FDC4636357
49 changed files with 729 additions and 252 deletions

View file

@ -35,10 +35,12 @@ nnoremap <A-k> <C-w>k
nnoremap <A-l> <C-w>l nnoremap <A-l> <C-w>l
" yank/paste with system clipboard " yank/paste with system clipboard
nnoremap Y y$
vnoremap Y y$
nnoremap <leader>y \"+y nnoremap <leader>y \"+y
nnoremap <leader>Y \"+Y nnoremap <leader>Y \"+y$
vnoremap <leader>y \"+y vnoremap <leader>y \"+y
vnoremap <leader>Y \"+Y vnoremap <leader>Y \"+y$
nnoremap <leader>p \"+p nnoremap <leader>p \"+p
nnoremap <leader>P \"+P nnoremap <leader>P \"+P
vnoremap <leader>p \"+p vnoremap <leader>p \"+p
@ -61,7 +63,8 @@ nmap <leader>? <Action>(FindInPath)
nmap <leader>sf <Action>(GotoFile) nmap <leader>sf <Action>(GotoFile)
nmap <leader>af <Action>(GotoFile) nmap <leader>af <Action>(GotoFile)
nmap <leader>rn <Action>(RenameElement) nmap <leader>rn <Action>(RenameElement)
nmap <leader>ru <Action>(Run) nmap <leader>rj <Action>(Run)
nmap <leader>l <Action>(ActivateLogcatToolWindow)
" Plugins " Plugins

View file

@ -7,6 +7,8 @@ vim.api.nvim_create_autocmd('FileType', {
-- Remove trailing whitespaces on save -- Remove trailing whitespaces on save
vim.api.nvim_create_autocmd('BufWritePre', { vim.api.nvim_create_autocmd('BufWritePre', {
callback = function() callback = function()
if vim.fn.expand('%:e') == 'md' then return end
local view = vim.fn.winsaveview() local view = vim.fn.winsaveview()
vim.cmd('%s/\\s\\+$//e') vim.cmd('%s/\\s\\+$//e')
vim.fn.winrestview(view) vim.fn.winrestview(view)
@ -19,3 +21,18 @@ vim.api.nvim_create_autocmd('TextYankPost', {
vim.highlight.on_yank({ higroup = "Visual", timeout = 400 }) vim.highlight.on_yank({ higroup = "Visual", timeout = 400 })
end end
}) })
local filetypes = {
json = 'jsonc',
j2 = 'jinja',
service = 'systemd'
}
for ext, ft in pairs(filetypes) do
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, {
pattern = "*." .. ext,
callback = function()
vim.bo.filetype = ft
end,
})
end

View file

@ -2,8 +2,8 @@
vim.o.hlsearch = true vim.o.hlsearch = true
-- Enable line numbers -- Enable line numbers
vim.wo.number = true vim.o.number = true
vim.wo.relativenumber = true vim.o.relativenumber = true
-- Enable mouse mode -- Enable mouse mode
vim.o.mouse = 'a' vim.o.mouse = 'a'

View file

@ -0,0 +1,7 @@
return {
'RRethy/vim-illuminate', config = function()
require('illuminate').configure({
delay = 0,
})
end
}

View file

@ -19,12 +19,7 @@ return {
['<C-d>'] = false, ['<C-d>'] = false,
["<C-j>"] = actions.move_selection_next, ["<C-j>"] = actions.move_selection_next,
["<C-k>"] = actions.move_selection_previous, ["<C-k>"] = actions.move_selection_previous,
-- ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist,
["<C-b>"] = require("trouble.sources.telescope").open
}, },
n = {
["<C-q>"] = require("trouble.sources.telescope").open
}
}, },
}, },
} }

View file

@ -12,10 +12,10 @@ set -g status-justify "left"
# status # status
set -g status-left-length 0 set -g status-left-length 0
set -g status-left "#[bg=#{@theme-active-bg},fg=#{@theme-active-fg}]#{?client_prefix,[#{session_name}],#[bg=#{@theme-bg},fg=#{@theme-fg}][#{session_name}]}#[bg=#{@theme-bg},fg=#{@theme-fg}] " set -g status-left "#{?client_prefix,#[bg=#{@theme-active-bg}]#[fg=#{@theme-active-fg}][#{session_name}],#[bg=#{@theme-bg}]#[fg=#{@theme-fg}][#{session_name}]}#[bg=#{@theme-bg},fg=#{@theme-fg}] "
set -g status-right "#(sb-battery -s) | %a %m/%d %I:%M %P" set -g status-right "#(sb-battery -s) | %a %m/%d %I:%M %P"
set -g window-status-format " #I:#W " set -g window-status-format " #I:#W "
set -g window-status-current-format "#[bg=#{@theme-active-bg},fg=#{@theme-active-fg}, bold]#{?window_zoomed_flag, #I:#W 󰊓 , #I:#W }" set -g window-status-current-format "#[bg=#{@theme-active-bg},fg=#{@theme-active-fg},bold]#{?window_zoomed_flag, #I:#W 󰊓 , #I:#W }"
set -g window-status-style "bg=#{@theme-bg},fg=#{@theme-fg}" set -g window-status-style "bg=#{@theme-bg},fg=#{@theme-fg}"
set -g status-interval "5" set -g status-interval "5"

View file

@ -1,15 +1,2 @@
[ -f "$HOME/.config/.fix-tty" ] || return pkill -0 gpg-agent || gpg-agent --daemon
eval "$(ssh-agent)"
process_id="$$"
(
if [ "$(inxi -aG | grep -c 'Monitor')" = "1" ]; then
setfont ter-v32n
stty -F /proc/$process_id/fd/0 rows 65 cols 195
else
setfont ter-v16n
stty -F /proc/$process_id/fd/0 rows 90 cols 320
fi >/dev/null 2>&1 &
)
unset process_id
# vim: ft=sh

View file

@ -1,11 +1,6 @@
set -a set -a
PATH="\ # `time` format
$HOME/.local/share/go/bin:\
$HOME/.local/share/dotnet:\
$PATH"
PATH="${$(find -L ~/.local/bin ! -name '.*' -type d -printf %p:)%%:}:$PATH"
TIMEFMT=$'\ncmd\t%J\nreal\t%*E\nuser\t%U\nsys\t%S\ncpu\t%P' TIMEFMT=$'\ncmd\t%J\nreal\t%*E\nuser\t%U\nsys\t%S\ncpu\t%P'
# lc vars # lc vars
@ -39,8 +34,9 @@ XDG_MUSIC_DIR="$HOME/"
XDG_PICTURES_DIR="$HOME/" XDG_PICTURES_DIR="$HOME/"
XDG_VIDEOS_DIR="$HOME/" XDG_VIDEOS_DIR="$HOME/"
# default configs # other
ANDROID_HOME="${HOME}/.local/share/android-home" ANDROID_HOME='/opt/android-sdk'
ANDROID_SDK_ROOT='/opt/android-sdk'
ANDROID_USER_HOME="${HOME}/.local/share/android-home" ANDROID_USER_HOME="${HOME}/.local/share/android-home"
ANDROID_AVD_HOME="${ANDROID_HOME}/avd" ANDROID_AVD_HOME="${ANDROID_HOME}/avd"
BAT_THEME="TwoDark" BAT_THEME="TwoDark"
@ -61,5 +57,13 @@ COMPOSE_BAKE=true
GIT_DISCOVERY_ACROSS_FILESYSTEM=1 GIT_DISCOVERY_ACROSS_FILESYSTEM=1
DOTNET_CLI_TELEMETRY_OPTOUT=1 # clippy <3 DOTNET_CLI_TELEMETRY_OPTOUT=1 # clippy <3
DOTNET_ROOT="${HOME}/.local/share/dotnet" DOTNET_ROOT="${HOME}/.local/share/dotnet"
DELTA_FEATURES="-side-by-side"
PATH="\
$HOME/.local/share/go/bin:\
$HOME/.local/share/dotnet:\
$ANDROID_HOME/cmdline-tools/latest/bin:
$PATH"
PATH="${$(find -L ~/.local/bin ! -name '.*' -type d -printf %p:)%%:}:$PATH"
set +a set +a

View file

@ -1,8 +1,5 @@
. ~/.config/zsh/modes.sh
fpath=($HOME/.local/share/completions $fpath) fpath=($HOME/.local/share/completions $fpath)
eval "$(zoxide init zsh --cmd j)"
# ls colors
eval "$(dircolors -b)" eval "$(dircolors -b)"
# history # history
@ -10,7 +7,6 @@ HISTSIZE=10000000
SAVEHIST=10000000 SAVEHIST=10000000
HISTFILE="${HOME}/.cache/zsh_history" HISTFILE="${HOME}/.cache/zsh_history"
alias history='history 1000000000000000' alias history='history 1000000000000000'
alias hist='history'
setopt hist_expire_dups_first setopt hist_expire_dups_first
setopt hist_ignore_dups setopt hist_ignore_dups
@ -90,10 +86,9 @@ alias venv='source src_venv'
alias ex='source src_example' alias ex='source src_example'
alias pa='source src_add_path' alias pa='source src_add_path'
alias info='pinfo' alias info='pinfo'
alias bat='bat ' alias bat='bat'
alias img='nsxiv' alias img='nsxiv'
alias xclip='xclip -selection clipboard' alias xclip='xclip -selection clipboard'
alias xcp='perl -pe "chomp if eof" | xclip -selection clipboard'
alias rgf='rg --files | rg' alias rgf='rg --files | rg'
alias wt='watch --color -d -cn 0.1 ' alias wt='watch --color -d -cn 0.1 '
alias .e='set -a && source .env && set +a' alias .e='set -a && source .env && set +a'
@ -107,78 +102,98 @@ alias open='xdg-open'
alias m.='if mount | grep -q "$(pwd)"; then umount -l .; cd .; else mount .; cd .; fi' alias m.='if mount | grep -q "$(pwd)"; then umount -l .; cd .; else mount .; cd .; fi'
alias rs='stow -R .' alias rs='stow -R .'
alias sst='ssh -t' alias sst='ssh -t'
alias rdj='rmdir ./*' alias rdj='rmdir --ignore-fail-on-non-empty ./* 2>/dev/null'
alias rdr='rmdir --ignore-fail-on-non-empty ./**/* 2>/dev/null'
alias qr='qrencode -t ansiutf8' alias qr='qrencode -t ansiutf8'
alias rgi='rg --no-ignore --hidden' alias rgi='rg -i'
alias rgn='rg --no-ignore --hidden'
alias rgni='rg --no-ignore --hidden -i'
alias cal='cal -3'
alias s='s '
alias t='vi ~/todo.md'
alias c.='cloc --vcs=git .'
alias yt='noglob yt-dlp'
alias b64='base64'
# function aliases # function aliases
mkexe() { touch "${1?}"; chmod +x "$1"; }; compdef _files mkexe; mkexe() { touch "${1?}"; chmod +x "$1"; }; compdef _files mkexe;
bl() { brightnessctl set "$1"% > /dev/null; } bl() { brightnessctl set "$1"% > /dev/null; }
nosw() { alacritty --class 'noswallow' -e "$@"; }; compdef _command nosw nosw() { alacritty --class 'noswallow' -e "$@"; }; compdef _command nosw
vims() { filepath="$(type "$1" | rev | cut -d ' ' -f 1 | rev)"; [ $? -eq 0 ] && vim "${filepath}"; }; compdef _command vims vims() { filepath="$(type "$1" | rev | cut -d ' ' -f 1 | rev)"; [ $? -eq 0 ] && vim "${filepath}"; }; compdef _command vims
tl() { tree -C "$@" | bat }; compdef _tree tl tl() { tree -C "$@" | bat; }; compdef _tree tl
diff() { /usr/bin/diff --color -u "$@" | delta; }; compdef _files di; diff() { /usr/bin/diff --color -u "$@" | delta; }; compdef _files di;
xcp() { perl -pe "chomp if eof" | xclip -selection clipboard; }
# compdef # compdef
compdef -a '_git; _git-commit' gdc # todo
compdef '_files -g "*.md"' md compdef '_files -g "*.md"' md
compdef _command s
# ansible # ansible
alias ap='ansible-playbook' alias ap='ansible-playbook'
alias ag='ansible-galaxy' alias ag='ansible-galaxy'
# git aliases # git aliases
compdef -a '_git; _git-commit' gdc # todo
compdef -a '_git; _git-ls-files' gls # todo
# compdef -a '_git; _git-reset' grt # todo
alias grt='git reset'
gl() { git log --decorate "$@" | bat }; compdef '_git; _git-log' gl gl() { git log --decorate "$@" | bat }; compdef '_git; _git-log' gl
gus() { git branch --set-upstream-to="${1:?}/${2:?}" "${2:?}" }; compdef '_git; _git-push' gus gus() { git branch --set-upstream-to="${1:?}/${2:?}" "${2:?}" }; compdef '_git; _git-push' gus
gpo() { git push --set-upstream origin "$(git rev-parse --abbrev-ref HEAD)" "$@" } gpo() { git push --set-upstream origin "$(git rev-parse --abbrev-ref HEAD)" "$@" }
gru() { git remote get-url "${1-origin}" }; compdef '_gor' gru gru() { git remote get-url "${1-origin}" }; compdef '_gor' gru
gtr() { gls $1 | tree --fromfile . }
alias ga="git add" alias ga="git add"
alias ga.="git add ." # always fatfinger this
alias gb="git branch" alias gb="git branch"
alias gc="git commit" alias gc="git commit"
alias gca="git commit --allow-empty-message --amend --no-edit" alias gca="git commit --allow-empty-message --amend --no-edit --date now"
alias gcad='gca --no-gpg-sign' alias gcad='gca --no-gpg-sign'
alias gcan="git commit --allow-empty-message --amend --no-edit --no-date"
alias gcd='git commit --no-gpg-sign'
alias gck="git checkout" alias gck="git checkout"
alias gcl="git clone" alias gcl="git clone"
alias gcln!='git clean -xfd'
alias gcln='git clean -nxfd'
alias gcls="git clone --depth=1" alias gcls="git clone --depth=1"
alias gcm="git commit --allow-empty-message -m ''" alias gcm="git commit --allow-empty-message -m ''"
alias gcd='git commit --no-gpg-sign'
alias gcmd="git commit --allow-empty-message -m '' --no-gpg-sign" alias gcmd="git commit --allow-empty-message -m '' --no-gpg-sign"
alias gcn="git clean -nfd"
alias gcn!="git clean -fd" alias gcn!="git clean -fd"
alias gcn="git clean -nfd"
alias gcp="git cherry-pick" alias gcp="git cherry-pick"
alias gct="gc -am 'Add files via upload :trollface:'"
alias gd="git diff" alias gd="git diff"
alias gdj='DELTA_FEATURES="+side-by-side" gd'
alias gds="gd --staged" alias gds="gd --staged"
alias 'gd?'="gd --stat"
alias 'gds?'="gds --stat"
alias gdsj='DELTA_FEATURES="+side-by-side" gds'
alias gdv='git difftool --tool=vimdiff'
alias gf="git fetch" alias gf="git fetch"
alias gi="git init" alias gi="git init"
alias gla="gl --all" alias gla="gl --all"
alias glp='gl --pretty=fuller'
alias gm="git merge" alias gm="git merge"
alias gp="git push" alias gp="git push"
alias gpu="git pull" alias gpu="git pull"
alias gr="git restore" alias gr="git restore"
alias grc='git rm --cached'
alias grj="git rebase" alias grj="git rebase"
alias grjc="git rebase --continue" alias grjc="git rebase --continue"
alias grjs="git rebase --cancel" alias grjs="git rebase --cancel"
alias grm="git remote" alias grm="git remote"
alias grs="git restore --staged" alias grs="git restore --staged"
alias grt="git reset" alias grt!="grt --hard"
alias grt!="git reset --hard"
alias gsm='git submodule'
alias grc='git rm --cached'
alias gs="git status" alias gs="git status"
alias gs.='git status .'
alias gsc="git switch -C" alias gsc="git switch -C"
alias gsh="git show" alias gsh="git show"
alias 'gsh?'="git show --stat"
alias gshj='DELTA_FEATURES="+side-by-side" gsh'
alias gsj="git stash" alias gsj="git stash"
alias gsl="git stash list"
alias gsm='git submodule'
alias gsp="git stash pop" alias gsp="git stash pop"
alias gt="git tag" alias gt="git tag"
alias gus="git fetch --unshallow" alias gus="git fetch --unshallow"
alias gdj='DELTA_FEATURES="+side-by-side" gd'
alias gdsj='DELTA_FEATURES="+side-by-side" gds'
alias gshj='DELTA_FEATURES="+side-by-side" gsh'
alias gcln='git clean -nxfd'
alias gcln!='git clean -xfd'
alias gct="gc -am 'Add files via upload :trollface:'"
# docker aliases # docker aliases
alias d='docker' alias d='docker'
@ -188,6 +203,7 @@ alias dc!='d! compose'
alias di='d image' alias di='d image'
alias dj='dc up -d --force-recreate' alias dj='dc up -d --force-recreate'
alias djn='dc up -d'
alias djb='dj --build' alias djb='dj --build'
alias djbl='djb && dl' alias djbl='djb && dl'
alias djl='dj && dl' alias djl='dj && dl'
@ -197,16 +213,38 @@ alias dr='d run --rm -it'
alias drs='dc restart' alias drs='dc restart'
alias drsl='dc restart && dl' alias drsl='dc restart && dl'
alias dv='d volume' alias dv='d volume'
alias ds='dc stop'
# tmux stuff # tmux stuff
tn() { tmux new-session -s "${1-"$(basename "$(pwd)")"}" } tn() { tmux new-session -s "${1-"$(basename "$(pwd)")"}" }
alias ta='tmux a -t' ta() { tmux a -t "$1" }
# ta() { tmux a -t "$1" }; compdef '_tmux; _tmux-attach-session' ta # alias ta='tmux a -t'
# disable xon control chars # disable xon control chars
stty -ixon stty -ixon
# print tasks on startup # print tasks on startup
_ZSH_TODO_FILE="${HOME}/todo.md" TODO_FILE="${HOME}/todo.md"
[ -f "$_ZSH_TODO_FILE" ] && { cat "$_ZSH_TODO_FILE" | grep -v '>.*'; } [ -f "$TODO_FILE" ] && { cat "$TODO_FILE" | grep -v '>.*'; }
unset _ZSH_TODO_FILE unset TODO_FILE
setopt extendedglob
autoload add-zsh-hook
for file in "$ZDOTDIR/cd_hooks/"^_*; do
fname="cd_::$(basename "$file")"
eval "
$fname() {
$(cat "$file")"'
if [ -n "$DIRNAME" ]; then
if [[ "$PWD/" = "$DIRNAME"*/ && ( "$OLDPWD/" != "$DIRNAME"*/ || "$PWD" = "$OLDPWD" ) ]]; then cd::enter
elif [[ "$PWD/" != "$DIRNAME"*/ && "$OLDPWD/" = "$DIRNAME"*/ ]]; then cd::leave; fi
elif [ -n "$BASE_DIR" ]; then
: # TODO: handle
fi
}
'
add-zsh-hook chpwd "$fname"
"$fname"
done
unsetopt extendedglob
CD_HOOKS_COMPLETED=1

View file

@ -0,0 +1,13 @@
# shellcheck disable=SC2164,SC2168
local DIRNAME="$HOME/Services/cpu"
cd::enter() {
! mount | grep -q "$DIRNAME" && mount "$DIRNAME" && builtin cd -q "$DIRNAME"
}
cd::leave() {
! fuser -m "$DIRNAME" >/dev/null 2>&1 && umount "$DIRNAME"
}
# vim: ft=sh

View file

@ -0,0 +1,14 @@
# shellcheck disable=SC2168
local DIRNAME="$HOME/Services/gpu"
local MOUNT_DIRNAME="$DIRNAME/.volumes"
cd::enter() {
! mount | grep -q "$MOUNT_DIRNAME" && mount "$MOUNT_DIRNAME"
}
cd::leave() {
! fuser "$DIRNAME" >/dev/null 2>&1 && umount "$MOUNT_DIRNAME"
}
# vim: ft=sh

View file

@ -0,0 +1,73 @@
local DIRNAME="$HOME/University/"
mode::enable() {
local mode_path="$DIRNAME/$1/.env"
export MODE__ACTIVE_MODE="$1"
export MODE__OLD_PS1="$PS1"
export PS1="($1) $PS1"
. "$mode_path"
}
mode::get_functions() {
perl -ne '/^(?>function\s+)?([\x21-\x7e]+)\s*\(\)/ && print "$1\n"' < "$1"
}
mode::get_variables() {
perl -ne '/^(?>declare\s+(?>--?\w+\s*)+\s*)?\s*([\x21-\x3c\x3e-\x7e]+)=.*$/ && print "$1\n"' < "$1"
}
mode::get_aliases() {
perl -ne '/^(?:noglob\s+)?alias ([\x21-\x3c\x3e-\x7e]+)=(.*)\n/ && print "$1=$2\n"' < "$1"
}
mode::disable() {
export PS1="$MODE__OLD_PS1"
local mode_path="$DIRNAME/$MODE__ACTIVE_MODE/.env"
unset -v "MODE__OLD_PS1"
unset -v "MODE__ACTIVE_MODE"
for mode_variable in ${(@f)"$(mode::get_variables "$mode_path")"}; do
unset "$mode_variable"
done
for mode_function in ${(@f)"$(mode::get_functions "$mode_path")"}; do
unset -f "$mode_function"
done
for mode_alias in ${(@f)"$(mode::get_aliases "$mode_path")"}; do
unalias "${mode_alias%=*}"
done
}
cd::enter() {
[ -n "$MODE__ACTIVE_MODE" ] && mode::disable
local module_name="$(cut -d/ -f1 <<<"${PWD#"$DIRNAME"}" )"
[ ! -f "$DIRNAME/$module_name/.env" ] && return
mode::enable "$module_name"
}
cd::leave() {
[ -n "$MODE__ACTIVE_MODE" ] && mode::disable
}
m() {
[ -z "$MODE__ACTIVE_MODE" ] && return 1
local mode_path="$DIRNAME/$MODE__ACTIVE_MODE/.env"
for type in Aliases Functions Variables; do
local arr=(${(@f)"$(mode::get_"${type:l}" "$mode_path")"})
[ "${#arr}" -gt 0 ] && {
echo "$type:"
printf '%s\n' "${arr[@]}"
echo
}
done | head -n -1
}
# vim: ft=zsh

View file

@ -1,109 +0,0 @@
#!/usr/bin/zsh
mode::enable() {
local mode_path="${HOME}/.config/zsh/modes/$1.sh"
[ ! -f "$mode_path" ] && echo "Mode not found!" && return 1
export MODE__ACTIVE_MODE="$1"
export MODE__OLD_PS1="$PS1"
export PS1="($1) $PS1"
# shellcheck disable=SC1090
source "$mode_path"
}
mode::get_functions() {
perl -ne '/^(?>function\s+)?([\x21-\x7e]+)\s*\(\)/ && print "$1\n"' < "$1"
}
mode::get_variables() {
perl -ne '/^(?>declare\s+(?>--?\w+\s*)+\s*)?\s*([\x21-\x3c\x3e-\x7e]+)=.*$/ && print "$1\n"' < "$1"
}
mode::get_aliases() {
perl -ne '/^(?:noglob\s+)?alias ([\x21-\x3c\x3e-\x7e]+)=/ && print "$1\n"' < "$1"
}
mode::disable() {
export PS1="${MODE__OLD_PS1}"
local mode_path="${HOME}/.config/zsh/modes/$MODE__ACTIVE_MODE.sh"
unset -v "MODE__OLD_PS1"
unset -v "MODE__ACTIVE_MODE"
for mode_variable in $(mode::get_variables "$mode_path"); do
unset "$mode_variable"
done
for mode_function in $(mode::get_functions "$mode_path"); do
unset -f "$mode_function"
done
for mode_alias in $(mode::get_aliases "$mode_path"); do
unalias "$mode_alias"
done
}
mode::help() {
echo "Usage:"
echo " mode <MODENAME>"
echo
echo "Available modes:"
for mode in ~/.config/zsh/modes/*; do
printf " %s\n" "$(basename "${mode%.sh}")"
done
}
m() {
[ -n "$MODE__ACTIVE_MODE" ] && {
mode::disable
[ -z "$1" ] && return
}
[ -z "$1" ] && {
echo 'Error: Missing mode name!'
mode::help
return 1
} >&2
case "$1" in
"-h"|"--help")
mode::help
;;
*)
mode::enable "$1" || mode::help >&2
;;
esac
}
mm() {
[ -z "$MODE__ACTIVE_MODE" ] && return 1
local mode_path="${HOME}/.config/zsh/modes/$MODE__ACTIVE_MODE.sh"
echo "Active mode: $MODE__ACTIVE_MODE"
echo
echo 'Aliases: '
for mode_alias in $(mode::get_aliases "$mode_path"); do
printf ' '
alias "$mode_alias"
done
echo
echo 'Functions:'
for mode_function in $(mode::get_functions "$mode_path"); do
echo " $mode_function"
done
echo
echo 'Variables:'
for mode_variable in $(mode::get_variables "$mode_path"); do
echo " $mode_variable"
done
}
alias 'm?'=mm

View file

@ -1,18 +0,0 @@
# shellcheck disable=SC2139
CPP_MODE__BUILD_DIR="./cmake-build"
alias cb="cmake --build ${CPP_MODE__BUILD_DIR}"
alias cg="cmake -B ${CPP_MODE__BUILD_DIR} -DCMAKE_EXPORT_COMPILE_COMMANDS=1 && ln -sf ${CPP_MODE__BUILD_DIR}/compile_commands.json ."
cpp_mode::find_exec() {
find "${CPP_MODE__BUILD_DIR}/$1" -maxdepth 1 -type f -executable
}
ct() {
"$(cpp_mode::find_exec "tests")"
}
cr() {
"$(cpp_mode::find_exec)"
}

View file

@ -1,7 +0,0 @@
alias db='dotnet build'
alias df='dotnet format'
alias dt='dotnet test'
alias dr='dotnet restore'
noglob alias df?='dotnet format --verify-no-changes'
alias dff='df; df; df?'
alias da='dff && db && dt'

BIN
.fonts/Evolventa.ttf Normal file

Binary file not shown.

BIN
.fonts/Farabee.ttf Normal file

Binary file not shown.

View file

@ -26,3 +26,5 @@
smudge = git-lfs smudge -- %f smudge = git-lfs smudge -- %f
process = git-lfs filter-process process = git-lfs filter-process
required = true required = true
[advice]
detachedHead = false

126
.local/bin/scripts/aw Executable file
View file

@ -0,0 +1,126 @@
#!/bin/bash
# shellcheck disable=SC2016,SC2329
COMMAND='
[ "$(su -c settings get global adb_wifi_enabled)" != 1 ] && su -c settings put --user current global adb_wifi_enabled 1
su -c getprop service.adb.tls.port
'
PHONE_SERIAL=4B141JEBF23561
WIFI_NAME='🙂'
PHONE_DNS_PREFIX=phone
declare -a PHONE_VPN_HOSTS=(
'10.160.1.3'
'10.160.3.3'
'phone.spb.wzray.com'
'phone.msk.wzray.com'
)
find_host_wifi() {
local default_link domain
default_link="$(
resolvectl status |
grep 'Default Route: yes' -B10 |
grep 'Link' |
tail -1 |
grep -Eo '\(.*\)' |
tr -d '()'
)"
domain="$(resolvectl domain "$default_link" | cut -d: -f2 | awk '{ print $1 }')"
grep -q 'wzray.com' <<<"$domain" && printf "%s.%s" "$PHONE_DNS_PREFIX" "$domain"
}
find_hosts_vpn() {
[ "$( ip link | grep -o -e 'tun[[:digit:]]' -e 'awg_[a-z]\+' | wc -l)" != 0 ] &&
echo "${PHONE_VPN_HOSTS[@]}"
}
find_host_tethering() {
! find_host_wifi >/dev/null 2>&1 &&
[ "$(iwctl station wlan0 show | grep 'Connected network' | awk '{ print $3 }')" = "$WIFI_NAME" ] &&
ip route show dev wlan0 | grep default | grep -Eo 'via [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' | cut -d ' ' -f2
}
can_use_adb() {
adb devices | grep -q "$PHONE_SERIAL\s\+device"
}
host_port_adb() {
can_use_adb && adb -d shell '
host="$(for ifname in tun0 wlan1 wlan0 lo; do
ip a show dev $ifname 2>&1 | grep "inet " | awk '\''{ print $2 }'\'' | cut -d/ -f1
done | head -1)"
port="$('"$COMMAND"')"
printf "%s:%s" "$host" "$port"
'
}
can_use_ssh() {
nmap --system-dns -sT -p8022 "$1" | grep -q '8022/tcp\s\+open'
}
port_ssh() {
ssh -o HostName="$1" \
-o UserKnownHostsFile=/dev/null \
-o IdentityFile=/dev/null \
-o StrictHostKeyChecking=no \
-o ConnectTimeout=1 \
-o LogLevel=ERROR \
phone "$COMMAND" 2>/dev/null
}
host_port_ssh() {
for host in $1; do
can_use_ssh "$host" &&
port="$(port_ssh "$host")" &&
printf "%s:%s" "$host" "$port" &&
return
done
}
host_port_nmap() {
for host in $1; do
ping -c1 -W 0.35 "$host" >/dev/null 2>&1 &&
port="$(
nmap -Pn -n -oG - --system-dns -p10000-65535 -sT "$host" |
grep -o 'Ports: .*/' |
sed 's,^Ports: ,,' |
sed -s 's/, /\n/g' |
grep -o '[0-9]\+/open/tcp' |
cut -d/ -f1 |
head -1
)" &&
printf "%s:%s" "$host" "$port"
done
}
adb devices | grep -q ':' && {
adb shell settings put --user current global adb_wifi_enabled 0 >/dev/null 2>&1 &
disown %1
sleep 0.1
adb disconnect >/dev/null 2>&1
echo 'disconnected'
exit
}
if can_use_adb; then
host_port="$(host_port_adb)"
else
if [ -n "$1" ]; then
hosts="$1"
else
hosts="$(find_host_wifi) $(find_host_tethering) $(find_hosts_vpn)"
fi
host_port="$(host_port_ssh "$hosts" || host_port_nmap "$hosts")"
fi
if [ -n "$host_port" ]; then
if [ -z "$(cut -d: -f2 <<<"$host_port")" ]; then
echo "Unable to start adb server! Start it manually or start sshd!"
else
adb connect "$host_port"
fi
else
echo "Unable to find phone address. You need to specify it manually."
fi

10
.local/bin/scripts/caf Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
while [ "$#" -gt 0 ]; do
echo "### $1:"
echo '```'
cat "$1"
echo '```'
[ "$#" -gt 1 ] && printf "\n\n"
shift
done

View file

@ -1,7 +0,0 @@
#!/bin/bash
while IFS=$'\n' read -r file; do
echo "$file:"
cat "$file"
printf "\n\n"
done < <(find "${1?}" -type f)

15
.local/bin/scripts/ft Executable file
View file

@ -0,0 +1,15 @@
#!/bin/sh
process_id="$$"
(
if [ "$(inxi -aG | grep -c 'Monitor')" = "1" ]; then
setfont ter-v32n
stty -F /proc/$process_id/fd/0 rows 65 cols 195
else
setfont ter-v16n
stty -F /proc/$process_id/fd/0 rows 90 cols 320
fi >/dev/null 2>&1 &
)
unset process_id
# vim: ft=sh

13
.local/bin/scripts/git Executable file
View file

@ -0,0 +1,13 @@
#!/bin/bash
declare -a args
while [ "$#" -gt 0 ]; do
case "$1" in
'^'*) args+=("HEAD$1") ;;
*) args+=("$1") ;;
esac
shift
done
exec "$(command -vp git)" "${args[@]}"

5
.local/bin/scripts/gls Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
filter=(sed '/^\./d')
[ "$1" = '-a' ] && filter=('cat') && shift
git ls-files "$@" | "${filter[@]}"

View file

@ -4,10 +4,6 @@ url="$(git remote get-url "${1:-origin}")"
if [[ "$url" =~ ^https?:\/\/ ]]; then if [[ "$url" =~ ^https?:\/\/ ]]; then
xdg-open "${url%.git}" xdg-open "${url%.git}"
# elif [[ "$url" =~ ([a-zA-Z0-9_.-]+):(.*) ]]; then
# url="https://${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
# url="${url%.git}"
# xdg-open "$url"
elif [[ "$url" =~ ^[a-zA-Z0-9_-]+@([a-zA-Z0-9_.-]+):(.*) ]]; then elif [[ "$url" =~ ^[a-zA-Z0-9_-]+@([a-zA-Z0-9_.-]+):(.*) ]]; then
url="https://${BASH_REMATCH[1]}/${BASH_REMATCH[2]}" url="https://${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
url="${url%.git}" url="${url%.git}"
@ -16,6 +12,10 @@ elif [[ "$url" =~ ^ssh://[a-zA-Z0-9_-]+@([a-zA-Z0-9_.-]+)/(.*) ]]; then
url="https://${BASH_REMATCH[1]}/${BASH_REMATCH[2]}" url="https://${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
url="${url%.git}" url="${url%.git}"
xdg-open "$url" xdg-open "$url"
elif [[ "$url" =~ ([a-zA-Z0-9_.-]+):(.*) ]]; then
url="https://${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
url="${url%.git}"
xdg-open "$url"
else else
echo "TODO: $url" echo "TODO: $url"
fi fi

13
.local/bin/scripts/grt Executable file
View file

@ -0,0 +1,13 @@
#!/bin/bash
args=()
shopt -s extglob
while [ "$#" -gt 0 ]; do
case "$1" in
+(^)) args+=("HEAD$1");;
*) args+=("$1");
esac
shift
done
git reset "${args[@]}"

View file

@ -1,6 +1,4 @@
#!/bin/bash -e #!/bin/bash
set -o pipefail
API_ENDPOINT="http://ip-api.com/json/$1"'?fields=' API_ENDPOINT="http://ip-api.com/json/$1"'?fields='
FIELDS_FULL='7876383' FIELDS_FULL='7876383'
@ -24,7 +22,7 @@ elif [ -t 1 ]; then
notify-send -i /dev/null "IP Info" "$(get_stats)" notify-send -i /dev/null "IP Info" "$(get_stats)"
else else
if [ -n "$1" ]; then if [ -n "$1" ]; then
resp="$(dig +short "$1" | tr -d $'\n')" resp="$(dig +short "$1" | tail -1 | tr -d $'\n')"
[ -n "$resp" ] && printf "%s" "$resp" || { echo 'Not found!' >&2; exit 1; } [ -n "$resp" ] && printf "%s" "$resp" || { echo 'Not found!' >&2; exit 1; }
else else
curl "${API_ENDPOINT}${FIELDS_SHORT}" 2>/dev/null | jq -r .query | tr -d $'\n' curl "${API_ENDPOINT}${FIELDS_SHORT}" 2>/dev/null | jq -r .query | tr -d $'\n'

48
.local/bin/scripts/l2p Executable file
View file

@ -0,0 +1,48 @@
#!/usr/bin/python3
from io import BytesIO
import os
import subprocess
import random
from string import ascii_letters
from subprocess import PIPE
import sys
from PIL import Image
LATEX_TEMPLATE = r'''
\documentclass{{minimal}}
\begin{{document}}
$$
{}
$$
\end{{document}}
'''
dpi = 1024
padding = 72
run = lambda args: subprocess.run(args, stdout=PIPE, stderr=PIPE)
filename = "".join(random.choices(ascii_letters, k=8))
tex_fn = filename + '.tex'
try:
with open(tex_fn, 'w') as f:
f.write(LATEX_TEMPLATE.format(' '.join(sys.argv[2:])))
ps = run(['latex', '-interaction=nonstopmode', tex_fn])
print(ps.stdout.decode(), ps.stderr.decode())
ps.check_returncode()
ps = run(['dvipng', '-q', '-T', 'tight', '-D', str(dpi), filename + '.dvi', '-o', filename + '.png'])
print(ps.stdout.decode(), ps.stderr.decode())
ps.check_returncode()
img = Image.open(filename + '.png')
new_img = Image.new('RGB', (img.width + padding * 2, img.height + padding * 2), (255, 255, 255))
new_img.paste(img, (padding, padding))
new_img.save(sys.argv[1] + ".png", 'png')
finally:
for fn in [f'{filename}.{ext}' for ext in ('aux', 'dvi', 'log', 'tex', 'png')] + ['texput.log']:
if os.path.isfile(fn):
os.remove(fn)

View file

@ -3,17 +3,21 @@
pkill -0 picom || { pkill -0 picom || {
picom --config "$HOME/.config/picom.conf" & picom --config "$HOME/.config/picom.conf" &
disown -h %% disown -h %%
export START_PICOM=1 START_PICOM=1
} }
img="$HOME/.local/share/wallpaper/wallpaper_blur_desktop.png"
[ "$(xrandr | grep primary | cut -d ' ' -f1)" = 'eDP-1' ] &&
img="$HOME/.local/share/wallpaper/wallpaper_blur_laptop.png"
blank='00000000' blank='00000000'
hl='23232340' hl='23232350'
hl_red='5c222240' hl_red='5c222240'
fg='#a0a0a0' fg='#a0a0a0'
pkill i3lock
i3lock \ i3lock \
-F \ -i "$img" \
-i "$HOME/.local/share/wallpaper/wallpaper_blur.png" \
-c '00000000' \ -c '00000000' \
--clock \ --clock \
--date-color=$fg \ --date-color=$fg \
@ -21,15 +25,10 @@ i3lock \
--verif-color=$fg \ --verif-color=$fg \
--wrong-color=$fg \ --wrong-color=$fg \
--bshl-color=$hl \ --bshl-color=$hl \
--inside-color=$blank \
--insidever-color=$blank \
--insidewrong-color=$blank \
--keyhl-color=$hl \ --keyhl-color=$hl \
--line-uses-ring \ --line-uses-ring \
--ring-color=$blank \
--ringver-color=$blank \ --ringver-color=$blank \
--ringwrong-color=$hl_red \ --ringwrong-color=$hl_red \
--separator-color=$blank \
--date-str='%A %m/%d' \ --date-str='%A %m/%d' \
--time-str='%H:%M' \ --time-str='%H:%M' \
--time-size=82 \ --time-size=82 \
@ -38,7 +37,7 @@ i3lock \
--date-pos 'tx:ty+36' \ --date-pos 'tx:ty+36' \
--verif-text='' \ --verif-text='' \
--noinput-text='' \ --noinput-text='' \
--wrong-text='' \ --wrong-text='x' \
--time-font="Mononoki Nerd Font Propo" \ --time-font="Mononoki Nerd Font Propo" \
--date-font="Mononoki Nerd Font Propo" \ --date-font="Mononoki Nerd Font Propo" \
--layout-font="Mononoki Nerd Font Propo" \ --layout-font="Mononoki Nerd Font Propo" \
@ -47,9 +46,10 @@ i3lock \
--bar-color $blank \ --bar-color $blank \
--bar-base-width 2080 \ --bar-base-width 2080 \
--bar-max-height 2080 \ --bar-max-height 2080 \
--bar-step 0 \ --bar-step 2080 \
--bar-count 1 \ --bar-count 1 \
--bar-periodic-step 2080 \ --bar-periodic-step 2080 \
--redraw-thread \
--bar-indicator \ --bar-indicator \
[ -n "$START_PICOM" ] && { [ -n "$START_PICOM" ] && {

View file

@ -1,6 +1,8 @@
#!/bin/sh #!/bin/sh
pkill -0 i3lock || \ export DISPLAY=:0
DISPLAY=:0 lock
pkill i3lock
lock
xkb-switch -s us xkb-switch -s us
systemctl suspend systemctl suspend

3
.local/bin/scripts/nike Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
notify-send 'НИКИТА' "У тебя объективно НЕПРАВИЛЬНОЕ мнение насчет шорткатов, используй Win + Q "

3
.local/bin/scripts/oop Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
xdg-open https://github.com/is-oop-y28/.github/blob/master/profile/labs/"$(git rev-parse --abbrev-ref HEAD)".md

View file

@ -13,23 +13,25 @@ for i in {0..1}; do
done done
done done
echo [ -z "$1" ] && {
echo
for i in {0..5}; do
for _ in {0..1}; do
for ((j=36*i+16;j<36*(i+1)+16;++j)); do
printc "$j"
[ $(((j + -15) % 6)) -eq 0 ] && printf " " || printf ""
done
echo
done
done
echo
for i in {0..5}; do
for _ in {0..1}; do for _ in {0..1}; do
for ((j=36*i+16;j<36*(i+1)+16;++j)); do for i in {232..255}; do
printc "$j" printc "$i" " "
[ $(((j + -15) % 6)) -eq 0 ] && printf " " || printf ""
done done
echo echo
done done
done }
echo
for _ in {0..1}; do
for i in {232..255}; do
printc "$i" " "
done
echo
done

30
.local/bin/scripts/promt Executable file
View file

@ -0,0 +1,30 @@
#!/bin/bash
tmpfile="$(mktemp)"
if [ -t 0 ]; then
[ "$#" = 0 ] && exit 1
echo "$@" > "$tmpfile"
else
cat > "$tmpfile"
case "$1" in
r*) dir=en-ru;;
e*) dir=ru-en;;
esac
fi
[ -z "$dir" ] &&
if (( $(grep -oP '\p{Latin}' < "$tmpfile" | wc -l) > $(grep -oP '\p{Cyrillic}' < "$tmpfile" | wc -l) )); then
dir='en-ru'
else
dir='ru-en'
fi
curl -s \
http://ядро.орг:9000/translate \
-H 'Content-Type: text/html' \
-H "X-Translation-Direction: $dir" \
--data-binary @- -o- < "$tmpfile" | \
tail -n +2 | \
perl -pe 's,<SPAN CLASS=UNKNOWN_WORD>(.*?)</SPAN>,\1,g' |
sed -e 's/&gt;/>/g' -e 's/&lt;/</g' -e 's/&quot;/"/g'
echo

5
.local/bin/scripts/s Executable file
View file

@ -0,0 +1,5 @@
#!/bin/sh
[ "$#" = 0 ] && echo 'Missing command!' >&2 && exit 1
script -O /dev/null -E never -qfc "$*"

View file

@ -70,7 +70,7 @@ main() {
msg="" msg=""
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
'-h'|'--help') help; exit 0 ;; '-h'|'--help') help; exit 0;;
'-p'|'--parse-mode') shift; tg__params[parse_mode]="${_TELEGRAM__PARSE_MODES[$1]}" ;; '-p'|'--parse-mode') shift; tg__params[parse_mode]="${_TELEGRAM__PARSE_MODES[$1]}" ;;
'-c'|'--code') tg__code=1; tg__params[parse_mode]='HTML' ;; '-c'|'--code') tg__code=1; tg__params[parse_mode]='HTML' ;;
'-r'|'--print-response') print_response=1 ;; '-r'|'--print-response') print_response=1 ;;

View file

@ -1,4 +1,3 @@
#!/bin/sh #!/bin/sh
xr internal xr internal
lock-suspend

3
.local/bin/scripts/vimdiff Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
nvim -d "$@"

7
.local/bin/scripts/vix Executable file
View file

@ -0,0 +1,7 @@
#!/bin/sh
[ -z "$1" ] && echo 'Missing filename!' >&2 && exit 1
touch "$1"
chmod +x "$1"
vi "$1"

View file

@ -17,6 +17,7 @@ awg-quick() {
DEFAULT_LINK="$(resolvectl status | grep 'Default Route: yes' -B10 | grep 'Link' | tail -1 | grep -Eo '\(.*\)' | tr -d '()')" DEFAULT_LINK="$(resolvectl status | grep 'Default Route: yes' -B10 | grep 'Link' | tail -1 | grep -Eo '\(.*\)' | tr -d '()')"
IS_LOCAL=0
if resolvectl domain "$DEFAULT_LINK" | grep -q 'wzray.com'; then if resolvectl domain "$DEFAULT_LINK" | grep -q 'wzray.com'; then
IS_LOCAL=1 IS_LOCAL=1
fi fi
@ -26,6 +27,7 @@ IFNAME="awg_ext"
while [ "$#" -gt 0 ]; do while [ "$#" -gt 0 ]; do
case "$1" in case "$1" in
i|int|internal) IFNAME='awg_int';; i|int|internal) IFNAME='awg_int';;
-f) IS_LOCAL=0;;
*) echo "Wrong argument!" >&2; exit 1;; *) echo "Wrong argument!" >&2; exit 1;;
esac esac
shift shift
@ -35,7 +37,7 @@ UP_NAME="$(ip link | grep 'awg_' | cut -d ' ' -f 2 | sed 's,:,,')"
if [ -n "$UP_NAME" ]; then if [ -n "$UP_NAME" ]; then
awg-quick down "$UP_NAME" awg-quick down "$UP_NAME"
elif [ -n "$IS_LOCAL" ]; then elif [ "$IS_LOCAL" = 1 ]; then
send_router_cmd toggle send_router_cmd toggle
else else
awg-quick up "${IFNAME}" awg-quick up "${IFNAME}"

View file

@ -20,8 +20,8 @@ INT_RES="$(echo $INT_MODELINE | cut -d ' ' -f 1 | tr -d '\"')"
if [[ -z "${EXT_MON}" ]] || [ "$1" = "internal" ]; then if [[ -z "${EXT_MON}" ]] || [ "$1" = "internal" ]; then
xrandr --output eDP-1 --pos 0x0 --mode "3120x2080" --rate 90 --primary --output DP-1 --off --output DP-2 --off --output DP-3 --off --output DP-4 --off xrandr --output eDP-1 --pos 0x0 --mode "3120x2080" --rate 90 --primary --output DP-1 --off --output DP-2 --off --output DP-3 --off --output DP-4 --off
xrandr --delmode eDP-1 "${INT_RES}" # xrandr --delmode eDP-1 "${INT_RES}"
xrandr --rmmode "${INT_RES}" # xrandr --rmmode "${INT_RES}"
change_dpi 192 48 change_dpi 192 48
else else
: :

View file

@ -0,0 +1,3 @@
git clone "$1" && cd "$(basename "$1")" || exit 1
# vim: ft=sh

View file

@ -0,0 +1,18 @@
#compdef gor
__git_command_successful () {
if (( ${#*:#0} > 0 )); then
_message 'not a git repository'
return 1
fi
return 0
}
__git_remotes() {
local remotes expl
remotes=(${(f)"$(_call_program remotes git remote 2>/dev/null)"})
__git_command_successful $pipestatus || return 1
_wanted remotes expl remote compadd "$@" -a - remotes
}
_arguments -S $endopt ': :__git_remotes'

View file

@ -0,0 +1,136 @@
#compdef ollama
# Purpose:
# This script file `_ollama` should be placed in your fpath to provide zsh completions functionality for ollama commands.
# It utilizes zsh's native completion system by defining specific completion behaviors tailored to ollama commands.
# Installation:
# 1. Check your current fpath by executing: `echo $fpath` in your zsh shell.
# 2. To introduce a new directory to fpath, edit your .zshrc file:
# Example: `fpath=($HOME/.zsh-completions $fpath)`
# 3. Store this script file in the directory you have added to your fpath.
# 4. For a system-wide installation on Linux:
# Download and deploy this script with the following command:
# sudo wget -O /usr/share/zsh/site-functions/_ollama https://gist.githubusercontent.com/obeone/9313811fd61a7cbb843e0001a4434c58/raw/_ollama.zsh
# Contributions:
# Principal contributions by:
# - ChatGPT [ZSH Expert](https://chatgpt.com/g/g-XczdbjXSW-zsh-expert) as the primary creator.
# - Guidance and revisions by [obeone](https://github.com/obeone).
# Note:
# - This configuration file presupposes the utilization of Zsh as your primary shell environment.
# - It is crucial to restart your zsh session subsequent to alterations made to your fpath to ensure the updates are effectively recognized.
_fetch_ollama_models() {
if [[ ${#models} -ne 0 ]]; then
printf "here\n\n"
_describe 'model names' models
return 0
fi
local output="$(ollama list 2>/dev/null | sed 's/:/\\:/g')"
if [[ -z "$output" ]]; then
_message "no models available or 'ollama list' failed"
return 1
fi
export models=("${(@f)$(echo "$output" | awk 'NR>1 {print $1}')}")
if [[ ${#models} -eq 0 ]]; then
_message "no models found"
return 1
fi
_describe 'model names' models
}
# Main completion function
_ollama() {
local -a commands
declare -a models
_arguments -C \
'1: :->command' \
'*:: :->args'
case $state in
command)
commands=(
'serve:Start ollama'
'create:Create a model from a Modelfile'
'show:Show information for a model'
'run:Run a model'
'stop:Stop a running model'
'pull:Pull a model from a registry'
'push:Push a model to a registry'
'list:List models'
'ps:List running models'
'cp:Copy a model'
'rm:Remove a model'
'help:Help about any command'
)
_describe -t commands 'ollama command' commands
;;
args)
case $words[1] in
create)
_arguments \
'-f+[Specify the file name]:file:_files' \
'-q+[Quantize model to this level (e.g. q4_0)]' \
;;
show)
_arguments \
'--license[Show license of a model]' \
'--modelfile[Show Modelfile of a model]' \
'--parameters[Show parameters of a model]' \
'--system[Show system message of a model]' \
'--template[Show template of a model]' \
'*::model:->model'
if [[ $state == model ]]; then
_fetch_ollama_models
fi
;;
run)
_arguments \
'--format[Specify the response format]:format:' \
'--insecure[Use an insecure registry]' \
'--nowordwrap[Disable word wrap]' \
'--verbose[Show verbose output]' \
'*::model and prompt:->model_and_prompt'
if [[ $state == model_and_prompt ]]; then
_fetch_ollama_models
_message "enter prompt"
fi
;;
pull|push)
_arguments \
'--insecure[Use an insecure registry]' \
'*::model:->model'
if [[ $state == model ]]; then
_fetch_ollama_models
fi
;;
list|ls)
_message "no additional arguments for list"
;;
cp)
_arguments \
'1:source model:_fetch_ollama_models' \
'2:target model:_fetch_ollama_models'
;;
rm)
_arguments \
'*::models:->model'
if [[ $state == model ]]; then
_fetch_ollama_models
fi
;;
help)
_message "no additional arguments for help"
;;
esac
;;
esac
}
_ollama

View file

@ -0,0 +1,26 @@
#compdef ta
# from builtin _tmux
function __tmux-sessions-separately() {
local ret=1
local -a sessions detached_sessions attached_sessions
sessions=( ${${(f)"$(command tmux 2> /dev/null list-sessions)"}/:[ $'\t']##/:} )
detached_sessions=( ${sessions:#*"(attached)"} )
attached_sessions=( ${(M)sessions:#*"(attached)"} )
# ### This seems to work without a _tags loop but not with it. I suspect
# ### that has something to do with _describe doing its own _tags loop.
_tags detached-sessions attached-sessions
# Placing detached before attached means the default behaviour of this
# function better suits its only current caller, _tmux-attach-session().
_requested detached-sessions && _describe -t detached-sessions 'detached session' detached_sessions "$@" && ret=0
_requested attached-sessions && _describe -t attached-sessions 'attached session' attached_sessions "$@" && ret=0
return ret
}
_ta() {
_arguments '*:: : __tmux-sessions-separately'
}
_ta "$@"

Binary file not shown.

After

Width:  |  Height:  |  Size: 811 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View file

@ -8,6 +8,7 @@ Host vm.zvray.ru
StrictHostKeyChecking no StrictHostKeyChecking no
UpdateHostkeys no UpdateHostkeys no
UserKnownHostsFile /dev/null UserKnownHostsFile /dev/null
LogLevel ERROR
Host *.zvray.ru mx*.wzray.com Host *.zvray.ru mx*.wzray.com
User root User root
@ -18,6 +19,7 @@ Host phone
Port 8022 Port 8022
Host laptop laptop.*.wzray.com Host laptop laptop.*.wzray.com
Port 8022
Host hicpu hicpu.spb.wzray.com Host hicpu hicpu.spb.wzray.com
User root User root

View file

@ -8,10 +8,6 @@ dbus-update-activation-environment --verbose --all
systemctl --user import-environment XDG_CURRENT_DESKTOP systemctl --user import-environment XDG_CURRENT_DESKTOP
systemctl --user import-environment DISPLAY systemctl --user import-environment DISPLAY
# agents
gpg-agent -d
eval "$(ssh-agent)"
# resolution and autostart # resolution and autostart
"${HOME}"/.config/X11/runonce "${HOME}"/.config/X11/runonce
xr xr