Add k script
This commit is contained in:
parent
f30d0805aa
commit
35af86de58
|
@ -6,9 +6,8 @@ GUI scripts for popular cli tools, based on dialog and fzf
|
||||||
- `a` - for managing apt packages
|
- `a` - for managing apt packages
|
||||||
- `g` - for managing git repo
|
- `g` - for managing git repo
|
||||||
- `s` - for managing systemd services
|
- `s` - for managing systemd services
|
||||||
|
- `k` - for managing kubernetes (depends on kubectl)
|
||||||
- `r` - for running named commands from ~/.aliases.txt file
|
- `r` - for running named commands from ~/.aliases.txt file
|
||||||
- `f` - open `lf` file manager
|
|
||||||
- `lk` - listen for keys above (except `r`)
|
|
||||||
|
|
||||||
See [Screenshots](#screenshots) section
|
See [Screenshots](#screenshots) section
|
||||||
|
|
||||||
|
@ -24,7 +23,7 @@ Install dependencies: `fzf`, `dialog`, `xdotool`, `x11-xkb-utils`
|
||||||
Then clone this repo and copy all scripts to one of the PATH folder:
|
Then clone this repo and copy all scripts to one of the PATH folder:
|
||||||
```
|
```
|
||||||
git clone https://git.digitalstudium.com/digitalstudium/gui-scripts.git
|
git clone https://git.digitalstudium.com/digitalstudium/gui-scripts.git
|
||||||
sudo cp gui-scripts/{a,g,s,r} /usr/local/bin/
|
sudo cp gui-scripts/{a,g,s,r,k} /usr/local/bin/
|
||||||
```
|
```
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
trap 'clear' SIGINT
|
||||||
|
cat > /tmp/.dialogrc << EOL
|
||||||
|
# Item color
|
||||||
|
tag_color = (BLACK,WHITE,ON)
|
||||||
|
EOL
|
||||||
|
namespace=$(kubectl get ns --no-headers | awk '{ print $1 }' | fzf --multi --cycle --reverse --preview 'kubectl get pods -o wide -n {1}')
|
||||||
|
resource=$(DIALOGRC=/tmp/.dialogrc dialog --stdout --erase-on-exit --menu "Choose resource in $namespace" 10 40 0 "Pods" 1 "Services" 2 "Ingress" 3 "Secrets" 4)
|
||||||
|
set +ex
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$resource" = "Pods" ]; then
|
||||||
|
pod=$(kubectl -n $namespace get pods --no-headers | awk '{ print $1 }' | fzf --multi --cycle --reverse --preview "kubectl get pod -n $namespace {1} -o yaml")
|
||||||
|
if [ ! -z "$pod" ]; then
|
||||||
|
action=$(DIALOGRC=/tmp/.dialogrc dialog --stdout --erase-on-exit --menu "Choose action for $pod in $namespace" 10 40 0 "Logs" 1 "Describe pod" 2 "Exec -it" 3 "Delete pod" 4)
|
||||||
|
fi
|
||||||
|
if [ ! -z "$action" ]; then
|
||||||
|
xdotool type --delay 0 "kubectl -n $namespace ${action,,} $pod" && xdotool key --delay 0 Return
|
||||||
|
fi
|
||||||
|
elif [ "$resource" = "Services" ]; then
|
||||||
|
svc=$(kubectl -n $namespace get svc --no-headers | awk '{ print $1 }' | fzf --multi --cycle --reverse --preview "kubectl get svc -n $namespace {1} -o yaml")
|
||||||
|
if [ ! -z "$svc" ]; then
|
||||||
|
action=$(DIALOGRC=/tmp/.dialogrc dialog --stdout --erase-on-exit --menu "Choose action for $pod in $namespace" 10 40 0 "Get endpoints" 1 "Edit service" 2)
|
||||||
|
fi
|
||||||
|
if [ ! -z "$action" ]; then
|
||||||
|
xdotool type --delay 0 "kubectl -n $namespace ${action,,} $svc" && xdotool key --delay 0 Return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
18
lk
18
lk
|
@ -1,18 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
clear
|
|
||||||
while true; do
|
|
||||||
echo Listen to keys...
|
|
||||||
read -rsn1 input
|
|
||||||
if [ "$input" = "a" ]; then
|
|
||||||
a
|
|
||||||
elif [ "$input" = "f" ]; then
|
|
||||||
f
|
|
||||||
elif [ "$input" = "g" ]; then
|
|
||||||
g
|
|
||||||
elif [ "$input" = "s" ]; then
|
|
||||||
s
|
|
||||||
elif [ "$input" = "q" ]; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
done
|
|
2
r
2
r
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
trap 'clear' SIGINT
|
trap 'clear' SIGINT
|
||||||
setxkbmap
|
setxkbmap
|
||||||
cat ~/.aliases.txt | fzf | cut -d : -f 2- | (stty -F /dev/tty -echo; xargs -0 -I _ xdotool type --delay 0 _; stty -F /dev/tty echo) && xdotool key Return
|
cat ~/.aliases.txt | fzf | cut -d : -f 2- | sed s/\ // | (stty -F /dev/tty -echo; xargs -0 -I _ xdotool type --delay 0 _; stty -F /dev/tty echo) && xdotool key Return
|
||||||
|
|
Loading…
Reference in New Issue