Skip to content

Commit 4cda512

Browse files
committed
Merge branch 'main' into feature/maven
2 parents 919919c + 43dee2c commit 4cda512

File tree

5 files changed

+77
-17
lines changed

5 files changed

+77
-17
lines changed

EasyKey.git/git.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ git fetch --all --tags 2> /dev/null
1616
while ${continuemenu:=true}; do
1717
clear
1818
menuInit "Super GIT Home"
19+
echo
1920
submenuHead "Working with remotes:"
2021
menuItemClm a "Gently push current" pushActual b "Set remote origin repo" setRemoteOrigin
2122
menuItemClm e "Set upstream to current" setUpstream f "Administer remotes" adminRemotes

EasyKey.kubectl/ezk-kubectl-functions.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
function listImagesInUse() {
44

5-
namespaces=("sls-alfred" "sls-pennyworth")
6-
5+
selectItem "kubectl get ns" "awk '{print \$1}'"
6+
if [[ $fname == "" ]]; then return 0; fi
7+
namespaces=("$fname")
78
contexts=$(kubectl config get-contexts -o name)
89

910
for context in $contexts; do

EasyKey.kubectl/kubectl.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ immediateMode=true
1414
while ${continuemenu:=true}; do
1515
clear
1616
menuInit "Super KUBECTL Home"
17+
echo
1718
echo "Current context: $(kubectl config current-context)"
1819
echo "Namespace: $(kubectl config view --minify -o jsonpath='{..namespace}')"
1920
echo

README.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,7 @@ Option 1: Use absolute paths
8080
source "/path/to/shellmenu.sh"
8181
```
8282

83-
Option 2: Relative paths
84-
85-
```
86-
# Source shellmenu.sh using relative paths
87-
source "relative/path/to/shellmenu.sh"
88-
```
89-
90-
Option 3: Set a variable for script directory
83+
Option 2: Set a variable for script directory
9184

9285
```
9386
# Set the variable for the main script directory

shellmenu.sh

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ menuHeadingBGClr="$clrBlue"
2626
submenuFGClr="$clrCyan"
2727
submenuBGClr="$clrBlack"
2828
delimiter=⊕
29+
formattedTop=""
30+
formattedBottom=""
31+
formattedMiddle=""
2932

3033
############################
3134
############################
@@ -45,7 +48,6 @@ menuInit () {
4548
actualsubmenuname="Your commands:"
4649
menudatamap=()
4750
${immediateMode} && printMenuHeading "$1"
48-
echo
4951
}
5052

5153
#################################################
@@ -102,8 +104,8 @@ menuItem () {
102104
#################################################
103105
menuItemClm () {
104106
clmLocalWidth=${globalClmWidth:=45}
105-
menudatamap+=("$1$delimiter$2$delimiter$3$delimiter$actualsubmenuname$delimiter$actualmenu$delimiter1")
106-
menudatamap+=("$4$delimiter$5$delimiter$6$delimiter$actualsubmenuname$delimiter$actualmenu$delimiter2")
107+
menudatamap+=("$1$delimiter$2$delimiter$3$delimiter$actualsubmenuname$delimiter$actualmenu${delimiter}1")
108+
menudatamap+=("$4$delimiter$5$delimiter$6$delimiter$actualsubmenuname$delimiter$actualmenu${delimiter}2")
107109
${immediateMode} && printMenuItemClm "$1" "$2" "$4" "$5"
108110
}
109111

@@ -115,6 +117,7 @@ menuItemClm () {
115117
#################################################
116118
startMenu() {
117119
while ${continuemenu:=true}; do
120+
clear
118121
generateMenu
119122
choice
120123
done
@@ -423,8 +426,12 @@ generateMenu () {
423426
OLD_IFS=$IFS
424427
local previoussubmenu previouscolumn submenucount;
425428
submenucount=0
426-
clear
429+
skipnext=false
427430
for ((index=0; index<${#menudatamap[@]}; index++)); do
431+
if [ "$skipnext" = "true" ]; then
432+
skipnext=false
433+
continue
434+
fi
428435
IFS="$delimiter" read -r key description action submenu menu column <<< "${menudatamap[index]}"
429436
IFS="$delimiter" read -r nextkey nextdescription nextaction nextsubmenu nextmenu nextcolumn <<< "${menudatamap[((index+1))]}"
430437
if [ "$index" -eq "0" ]; then printMenuHeading "$menu" && echo; fi
@@ -434,9 +441,10 @@ generateMenu () {
434441
submenucount=$((submenucount+1));
435442
fi
436443
if [ "$((nextcolumn))" -eq "$((column + 1))" ]; then
437-
printMenuItemClm "$key" "$description" "$action" "$nextkey" "$nextdescription" "$nextaction"
444+
printMenuItemClm "$key" "$description" "$nextkey" "$nextdescription"
445+
skipnext=true
438446
else
439-
printMenuItem "$key" "$description" "$action"
447+
printMenuItem "$key" "$description"
440448
fi
441449
previoussubmenu="$submenu"
442450
done
@@ -527,7 +535,7 @@ printMenuItem() {
527535
# The menu head to stdout
528536
#################################################
529537
printMenuHeading(){
530-
coloredLog "$1" "$menuHeadingFGClr" "$menuHeadingBGClr"
538+
draw_rounded_square "$1"
531539
}
532540

533541
#################################################
@@ -553,3 +561,59 @@ exitGently () {
553561
exit 1
554562
}
555563

564+
#################################################
565+
# Draw title graphic
566+
# Globals:
567+
# formattedTop - top line of graphic
568+
# formattedMiddle - middle line of graphic
569+
# formattedBottom - bottom line of graphic
570+
# tput colors
571+
# Arguments:
572+
# $1: menu head description
573+
# Outputs:
574+
# The menu head graphic to stdout
575+
#################################################
576+
draw_rounded_square() {
577+
578+
# Menu title cache
579+
if [ "$formattedTop" != "" ]; then
580+
echo -e "$formattedTop"
581+
echo -e "$formattedMiddle"
582+
echo -e "$formattedBottom"
583+
return
584+
fi
585+
586+
local text="$1"
587+
local width=${#text}
588+
589+
local horizontal_line=""
590+
local top_left_corner=""
591+
local top_right_corner=""
592+
local bottom_left_corner=""
593+
local bottom_right_corner=""
594+
local vertical_line=""
595+
596+
local border=""
597+
border+="$top_left_corner"
598+
for (( i=0; i<width+2; i++ )); do
599+
border+="$horizontal_line"
600+
done
601+
border+="$top_right_corner"
602+
603+
formattedTop=$(tput setaf $clrWhite)$(tput setab $clrBlue)$(tput bold)$border$(tput sgr0)
604+
formattedMiddle=$(tput setaf $clrWhite)$(tput setab $clrBlue)$(tput bold)"$vertical_line "$(tput setaf $clrWhite)$(tput setab $clrBlue)$(tput bold)$text$(tput sgr0)$(tput setaf $clrWhite)$(tput setab $clrBlue)$(tput bold)" $vertical_line"$(tput sgr0)
605+
606+
echo -e "$formattedTop"
607+
echo -e "$formattedMiddle"
608+
609+
border="$bottom_left_corner"
610+
for (( i=0; i<width+2; i++ )); do
611+
border+="$horizontal_line"
612+
done
613+
border+="$bottom_right_corner"
614+
615+
formattedBottom=$(tput setaf $clrWhite)$(tput setab $clrBlue)$(tput bold)$border$(tput sgr0)
616+
echo -e "$formattedBottom"
617+
618+
}
619+

0 commit comments

Comments
 (0)