Skip to content

Commit dbddf0b

Browse files
authored
Merge pull request #7 from nschlimm/feature/EasyKey.bash
Feature/easy key.bash
2 parents 04c84f4 + 9c013d7 commit dbddf0b

File tree

11 files changed

+153
-59
lines changed

11 files changed

+153
-59
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EasyKey.git/.ezk-git-loca-conf

EasyKey.bash/.ezk-bash-config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[locations]
2+
mavenhome=~/.m2
3+
workspace=~/workspace
4+
easykey=~/workspace/EasyKey.shellmenu

EasyKey.bash/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# EasyKey.bash utility
2+
3+
Experimental state of menu with usefull bash commands.

EasyKey.bash/bashstuff.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
####################################
4+
# EasyKey.bash utility main script #
5+
####################################
6+
7+
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
8+
source "$script_dir/../shellmenu.sh"
9+
10+
findText(){
11+
echo "Text pattern:"
12+
read textPattern
13+
echo "File pattern:"
14+
read filePattern
15+
find . -name "$filePattern" -exec grep -H "$textPattern" {} + | awk -F ":" '{printf "%-40s %s\n", $1, $2}'
16+
}
17+
18+
menuInit "EasyKey.bash"
19+
submenuHead "Usefull:"
20+
menuItem f "Find text inside files" findText
21+
startMenu "$(pwd)"

EasyKey.bash/ezk-locations.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
unset locations
4+
5+
script_dir="$1"
6+
source "${script_dir}/shellmenu.sh"
7+
8+
configfilename=.ezk-bash-config
9+
10+
function toDirAndTerminate () {
11+
vars="$*" # all splitted words back to one var
12+
blueLog "toDir $vars"
13+
eval "cd ${vars// /\\ }" # escape spaces
14+
nowaitonexit
15+
}
16+
17+
# Reads the config into global array "workspaces"
18+
# The config needs to have that section [workspaces]
19+
initConfig "${script_dir}/EasyKey.bash/${configfilename}"
20+
21+
echo "${locations[@]}"
22+
23+
clear
24+
thekeys=($(echo {a..p}) $(echo {r..z}) $(echo {1..9}) $(echo {A..Z}))
25+
declare -x keycounter=1
26+
27+
immediateMode=true
28+
29+
menuInit "Quick Locations"
30+
echo
31+
submenuHead "Registered locations:"
32+
OLD_IFS=$IFS
33+
for (( i = 1; i < (( ${#locations[@]} + 1 )); i++ )); do
34+
IFS="=" read -r locname locdestination <<< "${locations[i]}"
35+
menuItem "${thekeys[keycounter]}" "$locdestination" "toDirAndTerminate ${locdestination}"
36+
((keycounter++))
37+
done
38+
IFS=$OLD_IFS
39+
echo
40+
submenuHead "Shortcuts"
41+
menuItem X "Purge git dir cache" purgDirCache
42+
choice
43+
44+
unset locations

EasyKey.git/.ezk-git-loca-conf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
[workspaces]
22
myworkspacelocation=~/workspace
33

4-
[locations]
5-
mavenrepohome=~/.m2
6-
userbin=/usr/local/bin
7-

EasyKey.git/ezk-git-functions.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ function atlassiansView() {
287287

288288
function changeProject () {
289289
source $script_dir/../EasyKey.git/ezk-git-loca.sh
290+
noterminate
290291
nowaitonexit
291292
}
292293

@@ -365,3 +366,15 @@ diffDrillDownAdvanced () {
365366
done
366367
fi
367368
}
369+
370+
repoSize() {
371+
executeCommand "git gc"
372+
executeCommand "git count-objects -vH"
373+
executeCommand "git rev-list --objects --all | grep -f <(git verify-pack -v .git/objects/pack/*.idx| sort -k 3 -n | cut -f 1 -d ' ' | tail -10)"
374+
echo "Enter file pattern to REMOVE in repo history:"
375+
read filePattern
376+
[ "${filename}" = "" ] && waitonexit && return
377+
executeCommand "git filter-repo --path-glob '"${filePattern}"' --invert-paths --force"
378+
executeCommand "git gc"
379+
executeCommand "git count-objects -vH"
380+
}

EasyKey.git/ezk-git-loca.sh

Lines changed: 5 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,53 +19,14 @@ function purgDirCache () {
1919
unset gitlocations
2020
}
2121

22-
initConfig () {
23-
# read config to global arrays
24-
INPUT="$script_dir"/"$configfilename"
25-
[ ! -f "$INPUT" ] && { echo "$INPUT file not found"; exit 99; }
26-
i=0
27-
configlines=$(cat "$INPUT")
28-
while read -r configline; do
29-
if echo "$configline" | grep -q "\[.*\]"; then
30-
configsection=$(echo "$configline" | grep -o "\[.*\]")
31-
configsectioname=${configsection:1:${#configsection}-2}
32-
i=0
33-
continue
34-
fi
35-
if [ -n "$configline" ]; then
36-
eval "${configsectioname[i]}='$configline'"
37-
fi
38-
((i++))
39-
done <<< "$(echo -e "$configlines")"
40-
}
41-
42-
initConfig
22+
# Reads the config into global array "workspaces"
23+
# The config needs to have that section [workspaces]
24+
initConfig "${script_dir}/${configfilename}"
4325

4426
clear
4527
thekeys=($(echo {a..p}) $(echo {r..z}) $(echo {1..9}) $(echo {A..Z}))
4628
declare -x keycounter=0
47-
menuInit "Favorite locations"
48-
submenuHead "Locations:"
49-
if [ -n ${locations+x} ]; then
50-
for j in "${locations[@]}"
51-
do
52-
locationname=$(echo "$j" | cut -f1 -d'=')
53-
locationdir=$(echo "$j" | cut -f2 -d'=')
54-
menuItem "${thekeys[$keycounter]}" "$locationname" "toDirAndTerminate $locationdir"
55-
((keycounter++))
56-
done
57-
fi
58-
echo
59-
submenuHead "Workspaces:"
60-
if [ -n ${workspaces+x} ]; then
61-
for j in "${workspaces[@]}"
62-
do
63-
locationname=$(echo "$j" | cut -f1 -d'=')
64-
locationdir=$(echo "$j" | cut -f2 -d'=')
65-
menuItem "${thekeys[$keycounter]}" "$locationname" "toDir $locationdir"
66-
((keycounter++))
67-
done
68-
fi
29+
menuInit "GIT locations"
6930
echo
7031
uncached=false
7132
priorlocation=$(pwd) # remember actual location
@@ -88,6 +49,7 @@ fi
8849
eval cd "${priorlocation// /\\ }" # return to previous location
8950
# print out git location cache
9051
submenuHead "GIT repos inside workspaces:"
52+
echo
9153
for (( i = 0; i < ${#gitlocations[@]}; i++ )); do
9254
arrIN=(${gitlocations[$i]})
9355
IFSOLD=$IFS
@@ -97,14 +59,8 @@ for (( i = 0; i < ${#gitlocations[@]}; i++ )); do
9759
menuItem "${arrIN[0]}" "${arrIN[1]}" "${arrIN[2]} ${arrIN[3]}"
9860
done
9961
if $uncached; then coloredLog "NEW" "1;42"; else coloredLog "CACHED" "1;42"; fi
100-
echo
10162
submenuHead "Shortcuts"
10263
menuItem X "Purge git dir cache" purgDirCache
103-
echo
104-
menuItem q "Quit" quit
105-
echo
106-
coloredLog "$(pwd)" "1;44"
107-
10864
choice
10965

11066
unset locations workspaces

EasyKey.git/git.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ menuItem r "Show branch history" showBranchHisto
3030
echo
3131
submenuHead "Other usefull actions:"
3232
menuItemClm s "Working with diffs" workingDiffs w "Atlassian's view" atlassiansView
33-
menuItem c "Change last commit message" "git commit --amend"
33+
menuItemClm c "Change last commit message" "git commit --amend" x "Descrease repo size" repoSize
3434
echo
3535
submenuHead "Git admin actions:"
3636
menuItemClm 1 "Show local git config" localGitConfig 2 "Show global git config" globalGitConfig
@@ -39,10 +39,9 @@ menuItemClm 5 "Git extras" gitExtras 6 "Change Git Passwords" gitPasswort
3939
echo
4040
submenuHead "Shortcuts"
4141
menuItemClm P "Change project" changeProject B "Change branch" changeBranch
42-
menuItemClm F "Fetch all" fetachAll C "Compile favorites" compileMenu
43-
menuItem X "Purge cache" purgeCash
42+
menuItem F "Fetch all" fetachAll
4443
echo
4544
showStatus
4645
choice
4746
done
48-
echo "bye, bye, homie!"
47+
echo "bye, bye, homie!"

EasyKey.maven/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# EasyKey.maven utility
2+
3+
EasyKey.maven is a sample menu used for daily work with Maven. Here is the menu:
4+
5+
<img width="574" alt="image" src="https://github.com/nschlimm/EasyKey.shellmenu/assets/876604/37f76f5e-55af-445a-987d-b2787473a057">
6+
7+
# Get started
8+
9+
To get startet with the full functionality:
10+
11+
1. Install `mvn` (Maven) on the command line.
12+
2. Clone this repository using `git clone https://github.com/nschlimm/EasyKey.shellmenu.git`
13+
3. Start the menu with `bash maven.sh` or with `bash path/to/maven.sh`

0 commit comments

Comments
 (0)