This commit is contained in:
parent
c449dfcb5f
commit
559939e2f4
49 changed files with 729 additions and 252 deletions
126
.local/bin/scripts/aw
Executable file
126
.local/bin/scripts/aw
Executable 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
10
.local/bin/scripts/caf
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
echo "### $1:"
|
||||
echo '```'
|
||||
cat "$1"
|
||||
echo '```'
|
||||
[ "$#" -gt 1 ] && printf "\n\n"
|
||||
shift
|
||||
done
|
||||
|
|
@ -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
15
.local/bin/scripts/ft
Executable 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
13
.local/bin/scripts/git
Executable 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
5
.local/bin/scripts/gls
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
filter=(sed '/^\./d')
|
||||
[ "$1" = '-a' ] && filter=('cat') && shift
|
||||
git ls-files "$@" | "${filter[@]}"
|
||||
|
|
@ -4,10 +4,6 @@ url="$(git remote get-url "${1:-origin}")"
|
|||
|
||||
if [[ "$url" =~ ^https?:\/\/ ]]; then
|
||||
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
|
||||
url="https://${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
|
||||
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="${url%.git}"
|
||||
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
|
||||
echo "TODO: $url"
|
||||
fi
|
||||
|
|
|
|||
13
.local/bin/scripts/grt
Executable file
13
.local/bin/scripts/grt
Executable 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[@]}"
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
set -o pipefail
|
||||
#!/bin/bash
|
||||
|
||||
API_ENDPOINT="http://ip-api.com/json/$1"'?fields='
|
||||
FIELDS_FULL='7876383'
|
||||
|
|
@ -24,7 +22,7 @@ elif [ -t 1 ]; then
|
|||
notify-send -i /dev/null "IP Info" "$(get_stats)"
|
||||
else
|
||||
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; }
|
||||
else
|
||||
curl "${API_ENDPOINT}${FIELDS_SHORT}" 2>/dev/null | jq -r .query | tr -d $'\n'
|
||||
|
|
|
|||
48
.local/bin/scripts/l2p
Executable file
48
.local/bin/scripts/l2p
Executable 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)
|
||||
|
|
@ -3,17 +3,21 @@
|
|||
pkill -0 picom || {
|
||||
picom --config "$HOME/.config/picom.conf" &
|
||||
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'
|
||||
hl='23232340'
|
||||
hl='23232350'
|
||||
hl_red='5c222240'
|
||||
fg='#a0a0a0'
|
||||
|
||||
pkill i3lock
|
||||
i3lock \
|
||||
-F \
|
||||
-i "$HOME/.local/share/wallpaper/wallpaper_blur.png" \
|
||||
-i "$img" \
|
||||
-c '00000000' \
|
||||
--clock \
|
||||
--date-color=$fg \
|
||||
|
|
@ -21,15 +25,10 @@ i3lock \
|
|||
--verif-color=$fg \
|
||||
--wrong-color=$fg \
|
||||
--bshl-color=$hl \
|
||||
--inside-color=$blank \
|
||||
--insidever-color=$blank \
|
||||
--insidewrong-color=$blank \
|
||||
--keyhl-color=$hl \
|
||||
--line-uses-ring \
|
||||
--ring-color=$blank \
|
||||
--ringver-color=$blank \
|
||||
--ringwrong-color=$hl_red \
|
||||
--separator-color=$blank \
|
||||
--date-str='%A %m/%d' \
|
||||
--time-str='%H:%M' \
|
||||
--time-size=82 \
|
||||
|
|
@ -38,7 +37,7 @@ i3lock \
|
|||
--date-pos 'tx:ty+36' \
|
||||
--verif-text='' \
|
||||
--noinput-text='' \
|
||||
--wrong-text='' \
|
||||
--wrong-text='x' \
|
||||
--time-font="Mononoki Nerd Font Propo" \
|
||||
--date-font="Mononoki Nerd Font Propo" \
|
||||
--layout-font="Mononoki Nerd Font Propo" \
|
||||
|
|
@ -47,9 +46,10 @@ i3lock \
|
|||
--bar-color $blank \
|
||||
--bar-base-width 2080 \
|
||||
--bar-max-height 2080 \
|
||||
--bar-step 0 \
|
||||
--bar-step 2080 \
|
||||
--bar-count 1 \
|
||||
--bar-periodic-step 2080 \
|
||||
--redraw-thread \
|
||||
--bar-indicator \
|
||||
|
||||
[ -n "$START_PICOM" ] && {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
pkill -0 i3lock || \
|
||||
DISPLAY=:0 lock
|
||||
export DISPLAY=:0
|
||||
|
||||
pkill i3lock
|
||||
lock
|
||||
xkb-switch -s us
|
||||
systemctl suspend
|
||||
|
|
|
|||
3
.local/bin/scripts/nike
Executable file
3
.local/bin/scripts/nike
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
notify-send 'НИКИТА' "У тебя объективно НЕПРАВИЛЬНОЕ мнение насчет шорткатов, используй Win + Q "
|
||||
3
.local/bin/scripts/oop
Executable file
3
.local/bin/scripts/oop
Executable 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
|
||||
|
|
@ -13,23 +13,25 @@ for i in {0..1}; do
|
|||
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 ((j=36*i+16;j<36*(i+1)+16;++j)); do
|
||||
printc "$j"
|
||||
[ $(((j + -15) % 6)) -eq 0 ] && printf " " || printf ""
|
||||
for i in {232..255}; do
|
||||
printc "$i" " "
|
||||
done
|
||||
echo
|
||||
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
30
.local/bin/scripts/promt
Executable 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/>/>/g' -e 's/</</g' -e 's/"/"/g'
|
||||
echo
|
||||
5
.local/bin/scripts/s
Executable file
5
.local/bin/scripts/s
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
[ "$#" = 0 ] && echo 'Missing command!' >&2 && exit 1
|
||||
|
||||
script -O /dev/null -E never -qfc "$*"
|
||||
|
|
@ -70,7 +70,7 @@ main() {
|
|||
msg=""
|
||||
while [ $# -gt 0 ]; do
|
||||
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]}" ;;
|
||||
'-c'|'--code') tg__code=1; tg__params[parse_mode]='HTML' ;;
|
||||
'-r'|'--print-response') print_response=1 ;;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
xr internal
|
||||
lock-suspend
|
||||
|
|
|
|||
3
.local/bin/scripts/vimdiff
Executable file
3
.local/bin/scripts/vimdiff
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
nvim -d "$@"
|
||||
7
.local/bin/scripts/vix
Executable file
7
.local/bin/scripts/vix
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
[ -z "$1" ] && echo 'Missing filename!' >&2 && exit 1
|
||||
|
||||
touch "$1"
|
||||
chmod +x "$1"
|
||||
vi "$1"
|
||||
|
|
@ -17,6 +17,7 @@ awg-quick() {
|
|||
|
||||
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
|
||||
IS_LOCAL=1
|
||||
fi
|
||||
|
|
@ -26,6 +27,7 @@ IFNAME="awg_ext"
|
|||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
i|int|internal) IFNAME='awg_int';;
|
||||
-f) IS_LOCAL=0;;
|
||||
*) echo "Wrong argument!" >&2; exit 1;;
|
||||
esac
|
||||
shift
|
||||
|
|
@ -35,7 +37,7 @@ UP_NAME="$(ip link | grep 'awg_' | cut -d ' ' -f 2 | sed 's,:,,')"
|
|||
|
||||
if [ -n "$UP_NAME" ]; then
|
||||
awg-quick down "$UP_NAME"
|
||||
elif [ -n "$IS_LOCAL" ]; then
|
||||
elif [ "$IS_LOCAL" = 1 ]; then
|
||||
send_router_cmd toggle
|
||||
else
|
||||
awg-quick up "${IFNAME}"
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ INT_RES="$(echo $INT_MODELINE | cut -d ' ' -f 1 | tr -d '\"')"
|
|||
|
||||
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 --delmode eDP-1 "${INT_RES}"
|
||||
xrandr --rmmode "${INT_RES}"
|
||||
# xrandr --delmode eDP-1 "${INT_RES}"
|
||||
# xrandr --rmmode "${INT_RES}"
|
||||
change_dpi 192 48
|
||||
else
|
||||
:
|
||||
|
|
|
|||
3
.local/bin/source/src_clone_cd
Normal file
3
.local/bin/source/src_clone_cd
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
git clone "$1" && cd "$(basename "$1")" || exit 1
|
||||
|
||||
# vim: ft=sh
|
||||
18
.local/share/completions/_gor
Normal file
18
.local/share/completions/_gor
Normal 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'
|
||||
136
.local/share/completions/_ollama
Normal file
136
.local/share/completions/_ollama
Normal 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
|
||||
26
.local/share/completions/_ta
Normal file
26
.local/share/completions/_ta
Normal 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 "$@"
|
||||
BIN
.local/share/wallpaper/wallpaper_blur_desktop.png
Normal file
BIN
.local/share/wallpaper/wallpaper_blur_desktop.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 811 KiB |
BIN
.local/share/wallpaper/wallpaper_blur_laptop.png
Normal file
BIN
.local/share/wallpaper/wallpaper_blur_laptop.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
Loading…
Add table
Add a link
Reference in a new issue