Skip to content

Commit bde6030

Browse files
committed
Menu border in submenus
1 parent 2b0db7e commit bde6030

File tree

4 files changed

+58
-49
lines changed

4 files changed

+58
-49
lines changed

EasyKey.git/git.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ globalClmWidth=35
1313
git fetch --all --tags 2> /dev/null
1414

1515
menuInit "EasyKey.git"
16-
submenuHead "Working with remotes:"
16+
submenuHead "Working with remotes "
1717
menuItemClm a "Gently push current" pushActual b "Set remote origin repo" setRemoteOrigin
1818
menuItemClm e "Set upstream to current" setUpstream f "Administer remotes" adminRemotes
19-
submenuHead "Working on local branches:"
19+
submenuHead "Working on local branches "
2020
menuItemClm r "Show branch history" showBranchHisto g "Show reflog" showRepoHisto
2121
menuItemClm v "Checkout remote branch" coRemoteBranch n "Delete local/remote branch" deleteBranch
2222
menuItemClm o "Merge source to target branch" mergeSourceToTarget p "Show all branches (incl. remote)" showAllBranches
2323
menuItemClm k "New local/remote branch checkout" newLocalBranch c "Change last commit message" "git commit --amend"
24-
submenuHead "Other usefull actions:"
24+
submenuHead "Other usefull actions "
2525
menuItemClm s "Working with diffs" workingDiffs w "Working with commits" atlassiansView
2626
menuItemClm y "Setting up repositories" settingUp 5 "Git extras" gitExtras
27-
submenuHead "Git admin actions:"
27+
submenuHead "Git admin actions "
2828
menuItemClm 1 "Show local git config" localGitConfig 2 "Show global git config" globalGitConfig
2929
menuItemClm 3 "Administering aliases" adminAliases 4 "Show .gitignore" gitIgnore
3030
menuItem x "Descrease repo size" repoSize
31-
submenuHead "Shortcuts"
31+
submenuHead "Shortcuts "
3232
menuItemClm P "Change project" changeProject B "Change branch" changeBranch
3333
menuItem F "Fetch all" fetchAll
3434
startMenu "showStatus"

EasyKey.kubectl/kubectl.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,28 @@ source "$script_dir/../shellmenu.sh"
99
source "$script_dir/ezk-kubectl-functions.sh"
1010

1111
menuInit "EasyKey.kubectl"
12-
submenuHead "Kubectl Config:" "Test:"
12+
submenuHead "Kubectl Config "
1313
menuItemClm a "Show config" "kubectl config view" b "Switch context" switchContext
1414
menuItemClm c "Switch namespace" switchNamespace d "Add cluster" addCluster
1515
menuItemClm e "Add users (token)" addUsers f "Add context" addContext
1616
menuItemClm g "Edit config" "vim ~/.kube/config" h "Create namespace" createNamespace
17-
submenuHead "Pods:"
17+
submenuHead "Pods "
1818
menuItemClm j "List pods (ns=current)" "kubectl get pods -o wide" k "List pods (all namespaces)" "kubectl get pods --all-namespaces -o wide"
19-
menuItemClm l "Show pod manifest (desired/observed)" showPodManifest m "Describe pod" describePod
19+
menuItemClm l "Show pod manifest" showPodManifest m "Describe pod" describePod
2020
menuItemClm n "Get logs" getPodLogs o "Log on to pod" logOnPod
2121
menuItemClm p "Log on to DB" logOnDb r "Apply pod manifest" applyPodManifest
2222
menuItem s "Delete pod" deletePod
23-
submenuHead "Deployments:"
23+
submenuHead "Deployments "
2424
menuItemClm v "List deployments (ns=current)" "kubectl get deployments -o wide" w "List deployments (all namespaces)" "kubectl get deployments --all-namespaces -o wide"
25-
menuItemClm x "Show deployment manifest (desired/observed)" showDeploymentManifest y "Describe deployment" describeDeployment
25+
menuItemClm x "Show deployment manifest" showDeploymentManifest y "Describe deployment" describeDeployment
2626
menuItemClm z "List replicasets (ns=current)" "kubectl get rs -o wide" 1 "Describe replica set" describeReplicaset
2727
menuItemClm 2 "Redeploy" redeploy 3 "Deployment history" deplHist
2828
menuItemClm 4 "Undo deployment" rollbackDeployment 5 "Deployment status" deployState
2929
menuItem E "Edit deployment" editDeployment
30-
submenuHead "Services:"
30+
submenuHead "Services "
3131
menuItemClm 6 "List services (ns=current)" "kubectl get services -o wide" 7 "List services (all namespaces)" "kubectl get services --all-namespaces -o wide"
32-
menuItemClm 8 "Show service manifest (desired/observed)" showServiceManifest 9 "Describe service" describeService
33-
submenuHead "Other stuff:"
32+
menuItemClm 8 "Show service manifest" showServiceManifest 9 "Describe service" describeService
33+
submenuHead "Other stuff "
3434
menuItemClm I "List images in contexts" listImagesInUse J "Ingress configuration" "kubectl get ing -o json | jq -r '.items[].spec.rules[].http.paths[]'"
3535
menuItemClm K "Describe ingress" "kubectl describe ing" "L" "Edit config map" editConfigMap
3636
menuItem T "Edit Ingress" "kubectl edit ingress"

EasyKey.maven/maven.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ source "$script_dir/ezk-maven-functions.sh"
1111
globalClmWidth=20
1212

1313
menuInit "Super MAVEN Home"
14-
submenuHead "Maven:"
14+
submenuHead "Working with Maven POM "
1515
menuItemClm a "Clean all eclipse" "mvnCleanEclipse" b "Maven analyze dependencies" "mvn dependency:analyze"
1616
menuItemClm c "Clean install force updates" "mvn clean install -U -DskipTests" d "To maven repo" toRepo
1717
menuItemClm e "Show effective settings" "mvn help:effective-settings" f "Local repo location" "mvn help:evaluate -Dexpression=settings.localRepository | grep -v '\[INFO\]'"
@@ -20,11 +20,11 @@ menuInit "Super MAVEN Home"
2020
menuItemClm k "Download sources" downLoadSources l "Build with deps" "mvn clean compile assembly:single"
2121
menuItemClm m "New project from archetype" newProject p "Effective pom" "mvn help:effective-pom"
2222
menuItemClm t "Dependency tree" "mvn dependency:tree" u "Display dependency updates" "mvn versions:display-dependency-updates -DexcludeReactor=true"
23-
submenuHead "Lifecycle:"
23+
submenuHead "Lifecycle "
2424
menuItemClm C "Clean compile" "mvn clean compile" T "Clean test" "mvn clean test"
2525
menuItemClm I "Clean install" "mvn clean install -DskipTests" P "Clean package" "mvn clean package -DskipTests"
2626
menuItem D "Clean deploy" "mvn clean deploy -DskipTests"
27-
submenuHead "Spring-Boot:"
27+
submenuHead "Spring-Boot "
2828
menuItemClm o "Start Spring Boot App" startSpringBoot s "View application properties" showProperties
2929
menuItem v "Usefull notes" useFull
3030
startMenu "pwd"

shellmenu.sh

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@ clrWhite=7
1717
# Globals
1818
waitstatus=true # whether to wait for key press after menu command finished
1919
continuemenu=true # whether to continue menu loop (quit will set this to false)
20-
globalClmWidth=45 # the default (minimum) column width
20+
globalClmWidth=20 # the default (minimum) column width
2121
actualmenu="EasyKey.shellmenu" # the default menu heading
2222
actualsubmenuname="Your commands:" # the default sub menu heading
2323
menuHeadingFGClr="$clrWhite" # the default menu heading foreground color
2424
menuHeadingBGClr="$clrBlue" # the default menu heading background color
25-
submenuFGClr="$clrCyan" # the default sub menu heading foreground color
26-
submenuBGClr="$clrBlack" # the default sub menu heading background color
25+
submenuFGClr="$clrCyan" # the default sub menu heading foreground color
26+
submenuBGClr="$clrBlack" # the default sub menu heading background color
2727
delimiter=⊕ # the delimiter used in menu array
2828
formattedheading="" # the cache for formatted heading
2929
generatedmenu="" # the menu cache (menu will be compiled once and then cached)
3030
menudatamap=() # the menu data
31+
has_two_clms=false # whether the menu hast two columns (internal)
3132

3233
############################
3334
############################
@@ -98,7 +99,8 @@ menuItem () {
9899
menuItemClm () {
99100
menudatamap+=("$1$delimiter$2$delimiter$3$delimiter$actualsubmenuname$delimiter$actualmenu${delimiter}1")
100101
menudatamap+=("$4$delimiter$5$delimiter$6$delimiter$actualsubmenuname$delimiter$actualmenu${delimiter}2")
101-
update_column_width "$2" && update_column_width "$5"
102+
update_column_width "$2" && update_column_width "$5"
103+
has_two_clms=true
102104
}
103105

104106
#################################################
@@ -133,29 +135,13 @@ startMenu() {
133135
# Colored log to standard out.
134136
# Arguments:
135137
# $1: log text
136-
# $2: optional: foreground color (0-7)
137-
# $3: optional: background color (0-7)
138-
# $4: optional: width of heading line
138+
# $2: optional: foreground color
139+
# $3: optional: background color
139140
# Outputs:
140141
# Writes colored log to standard out
141142
#######################################
142143
coloredLog () {
143-
set_foreground=$(tput setaf "${2:-$clrWhite}")
144-
set_background=$(tput setab "${3:-$clrBlack}")
145-
echo -n "$set_background$set_foreground"
146-
printf "%s" "$1"
147-
tput sgr0
148-
if [ $# -eq 4 ]; then
149-
length=${#1}
150-
width=73
151-
pad=$(( width - length ))
152-
set_foreground=$(tput setaf "$3")
153-
set_background=$(tput setab "$clrBlack")
154-
echo -n "$set_background$set_foreground"
155-
printf "%s" $(pad_string_with_stars "" $pad)
156-
tput sgr0
157-
fi
158-
printf "\n\r"
144+
printf "\e[38;5;%sm\e[48;5;%sm%s\e[38;5;7m\e[48;5;0m" "$2" "$3" "$1"
159145
}
160146

161147
pad_string_with_stars() {
@@ -182,7 +168,7 @@ pad_string_with_stars() {
182168
#######################################
183169
blueLog() {
184170
log="$1"
185-
coloredLog "${log}" "$clrWhite" "$clrBlue"
171+
coloredLog "${log}" "$clrWhite" "$clrBlue" && printf "\n\r"
186172
}
187173

188174
#######################################
@@ -195,7 +181,7 @@ blueLog() {
195181
#######################################
196182
greenLog() {
197183
log="$1"
198-
coloredLog "${log}" "$clrWhite" "$clrGreen"
184+
coloredLog "${log}" "$clrWhite" "$clrGreen" && printf "\n\r"
199185
}
200186

201187
#######################################
@@ -208,7 +194,7 @@ greenLog() {
208194
#######################################
209195
redLog() {
210196
log="$1"
211-
coloredLog "${log}" "$clrRed" "$clrBlack"
197+
coloredLog "${log}" "$clrRed" "$clrBlack" && printf "\n\r"
212198
}
213199

214200
#######################################
@@ -219,7 +205,7 @@ redLog() {
219205
# Writes log to standard out
220206
#######################################
221207
importantLog() {
222-
coloredLog "$1" "$clrCyan" "$clrBlack"
208+
coloredLog "$1" "$clrCyan" "$clrBlack" && printf "\n\r"
223209
}
224210

225211
#################################################
@@ -364,7 +350,7 @@ coloredCsvTable() { #show csv file with header line in nice format
364350
if [ "${linefromXX}" = "1" ]; then linefromXX="2"; fi
365351
headers=$(head -1 $csvfile | sed 's/ /_/g' | awk -F, 'BEGIN {i=1} {while (i<=NF) {str=str substr($i,1,12)","; i++;}} END {print str}')
366352
importantLog "${csvfile}"
367-
! [ "${heading}" = "" ] && coloredLog "${heading}"
353+
! [ "${heading}" = "" ] && coloredLog "${heading}\n\r"
368354
if [ "${width}" = "" ]; then
369355
(echo "${headers}" && sed -n "${linefromXX},${linetoXX}p" "${csvfile}") \
370356
| perl -pe 's/((?<=,)|(?<=^)),/ ,/g;' \
@@ -570,11 +556,36 @@ printMenuHeading(){
570556
# Print the sub menu head.
571557
# Arguments:
572558
# $1: sub menu head description
559+
# $2: optional: menu width
560+
# $3: padding symbol
573561
# Outputs:
574562
# The sub menu head to stdout
575563
#################################################
576564
printSubmenuHeading(){
577-
coloredLog "$1" "$submenuFGClr" "$submenuBGClr"
565+
$has_two_clms && local dfltwidth=$(( globalClmWidth * 2 + 3 ))
566+
$has_two_clms || local dfltwidth=$(( globalClmWidth + 3 ))
567+
local width="${2:-$dfltwidth}"
568+
local symbol="${3:-""}"
569+
local paddedline="$(r_pad "$1" "$width" "$symbol")"
570+
coloredLog "$paddedline\n\r" "$submenuFGClr" "$submenuBGClr"
571+
}
572+
573+
#################################################
574+
# Right pad text
575+
# Arguments:
576+
# $1: text
577+
# $2: target width of line
578+
# $3: symbol for padding
579+
# Outputs:
580+
# Padded line to stdout
581+
#################################################
582+
r_pad() {
583+
local text=$1
584+
local length=${#text}
585+
local width=${2:-$length}
586+
local paddedcount=$(( width - length ))
587+
local printout="$text$(printf "%-${paddedcount}s" "" | tr " " "$symbol")"
588+
printf "%s" "$printout"
578589
}
579590

580591
quit () {
@@ -628,10 +639,9 @@ draw_rounded_square() {
628639
done
629640
border+="$top_right_corner"
630641

631-
formattedTop=$(tput setaf $clrWhite)$(tput setab $clrBlue)$(tput bold)$border$(tput sgr0)
632642
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)
633643

634-
formattedheading+=$(printf '%s\n\r' "$formattedTop")
644+
formattedheading+=$(coloredLog "$border\n\r" 7 20)
635645
formattedheading+=$(printf '%s\n\r' "$formattedMiddle")
636646

637647
border="$bottom_left_corner"
@@ -640,8 +650,7 @@ draw_rounded_square() {
640650
done
641651
border+="$bottom_right_corner"
642652

643-
formattedBottom=$(tput setaf $clrWhite)$(tput setab $clrBlue)$(tput bold)$border$(tput sgr0)
644-
formattedheading+=$(printf '%s\n\r' "$formattedBottom")
653+
formattedheading+=$(coloredLog "$border\n\r" 7 20)
645654

646655
printf '%s' "$formattedheading"
647656

0 commit comments

Comments
 (0)