mirror of
https://github.com/kristoferssolo/solorice.git
synced 2026-02-04 06:32:03 +00:00
Update 2024-12-10
This commit is contained in:
32
local/bin/typst-port
Normal file
32
local/bin/typst-port
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
copy_to_clipboard() {
|
||||
if [[ "$XDG_SESSION_TYPE" == "wayland" ]]; then
|
||||
# Wayland
|
||||
wl-copy
|
||||
else
|
||||
# X11
|
||||
xclip -selection clipboard
|
||||
fi
|
||||
}
|
||||
|
||||
get_tinymist_ports() {
|
||||
local line_num=${1:-0} # Default to 0 if no argument provided
|
||||
|
||||
# Get all lines and store in array
|
||||
mapfile -t lines < <(ss -tunlp | grep tinymist | awk '{
|
||||
split($5, addr, ":")
|
||||
print addr[1] ":" addr[2]
|
||||
}')
|
||||
|
||||
# Check if requested line exists
|
||||
if [ "$line_num" -lt 0 ] || [ "$line_num" -ge "${#lines[@]}" ]; then
|
||||
echo "Error: Line $line_num does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Output the requested line
|
||||
echo "${lines[$line_num]}" | tee >(copy_to_clipboard)
|
||||
}
|
||||
|
||||
get_tinymist_ports "$1"
|
||||
Reference in New Issue
Block a user