Compare commits

..

8 Commits

Author SHA1 Message Date
36f5f3c34b Fix typo in lr 2022-10-30 11:04:30 +01:00
010d20be83 Add command to start/stop server 2022-10-04 16:12:23 +02:00
a46eb7b5c5 Add option to reset server 2022-10-04 16:11:41 +02:00
e96b59654e Add makefile 2022-09-07 12:16:31 +02:00
94787ac0f5 Prefer ksh specific features 2022-09-07 12:16:23 +02:00
7a85d24714 jmod - quick jump to a module 2022-09-07 11:54:31 +02:00
519752ecd1 lr - trigger global build tasks 2022-09-06 16:51:46 +02:00
7d2f340758 Directory aliases and quick directory navigation
`diralias` allows you to map a symbolic name to an absolute path.

`j` takes an alias name, and jumps (cd) to it.
2022-05-27 21:23:25 +02:00
8 changed files with 58 additions and 83 deletions

View File

@ -1,6 +1,3 @@
BINDIR?=${HOME}/.local/bin
cmds=g pick
fns=diralias j jmod nsalias
fns=diralias j jmod lr tcat
install:
install ${fns} $${FPATH:?FPATH not defined}
install ${cmds} ${BINDIR}

View File

@ -1,9 +1,9 @@
function diralias
{
typeset -i i=0
typeset -i i
case $# in
0)
let i=0
while (( i < ${#DIRALIASNAM[@]} ))
do
printf "%s\t%s\n" ${DIRALIASNAM[i]} "${DIRALIASVAL[i]}"
@ -11,6 +11,7 @@ function diralias
done
;;
1)
let i=0
while [[ $i -lt ${#DIRALIASNAM[@]} && $1 != ${DIRALIASNAM[i]} ]]
do
let i++
@ -18,6 +19,7 @@ function diralias
(( i == ${#DIRALIASNAM[@]} )) && print $1 || print ${DIRALIASVAL[i]}
;;
2)
let i=0
while [[ $i -lt ${#DIRALIASNAM[@]} && $1 != ${DIRALIASNAM[i]} ]]
do
let i++

19
g
View File

@ -1,19 +0,0 @@
#!/usr/bin/env ksh
if [[ $1 = "pc" || ( $1 = "pr" && $2 = "create" ) ]]
then
tmp=$(mktemp /tmp/g.XXXXXXXXXXX.md)
if [[ -f ~/.g.template ]]
then
lps=$(git show --pretty='format:%s' --no-patch | cut -d' ' -f1)
if [[ ! -z $lps ]]
then
url="https://issues.liferay.com/browse/"$lps
sed -e "s/{lps}/$lps/g" -e "s,{url},$url," <~/.g.template >$tmp
fi
fi
${GH_EDITOR:-${VISUAL:-${EDITOR:-ed}}} ${tmp} >/dev/null
gh $@ --title "$(head -1 $tmp)" --body "$(tail -n +3 $tmp)"
mv -f $tmp /tmp/g.lastpr
else
gh $@
fi

25
jmod
View File

@ -1,26 +1,15 @@
function jmod
{
typeset dir root sel
typeset -a dirs names
typeset -i i=0
(( $# != 1 )) && return 64
root=$(jr && pwd)/modules/apps
set -A dirs $(find $root -maxdepth 2 -mindepth 2 -type d -iregex ".*/[^/]*$1[^/]*" | sort)
(( ${#dirs[@]} == 0 )) && return 1
for dir in ${dirs[@]}
do
names[$i]=${dir##*/}
let i++
done
if (( ${#names[@]} > 1 ))
typeset m=$(jr && pwd)/modules/apps
typeset d=$(find $m -maxdepth 2 -mindepth 2 -type d -iregex ".*/.*$1$")
[[ -z $d ]] && return 1
if (( $(print $d | wc -w) > 1 ))
then
select sel in ${names[@]}
select d in $d
do
print ${sel} && cd ${dirs[(( REPLY - 1 ))]}
break;
break
done
else
print ${names[0]} && cd ${dirs[0]}
fi
print ${d##*/} && cd $d
}

8
kpick
View File

@ -1,8 +0,0 @@
#!/usr/bin/env ksh
(( $# == 0 )) && exit 64
(( $# == 1 )) && echo $1 && exit 0
select choice in "$@"
do
print $choice
break
done

26
lr Normal file
View File

@ -0,0 +1,26 @@
function lr
{
(( $# != 1 )) && return 64
case $1 in
all)
(jr && ant all)
;;
bl)
(jr && cd modules/apps/portal-language/portal-language-lang && gw buildLang)
;;
kill)
pkill -9 -f Liferay
psql -c 'drop schema ce cascade;' -c 'create schema authorization ce;' postgres postgres
(jr && rm -rf ../bundles/data && rm -rf ../bundles/osgi/state)
;;
killdaemon)
pkill -9 -f gradle
;;
sf|fs)
(jr && cd portal-impl && ant format-source)
;;
*)
return 64
;;
esac
}

32
nsalias
View File

@ -1,32 +0,0 @@
function nsalias {
typeset -i i=0
case $# in
0|1)
while (( i < ${#NSCMDNS[@]} ))
do
[[ ( -z $1 ) || ( ${NSCMDNS[i]} = $1 ) ]] \
&& print -c "${NSCMDNS[i]}\t${NSCMDFN[i]}\t${NSCMDSH[i]}"
let i++
done
;;
2)
while [[ $i -lt ${#NSCMDNS[@]} && ( ${NSCMDNS[i]} != $1 || ${NSCMDFN[i]} != $2 ) ]]
do
let i++
done
(( i == ${#NSCMDNS[@]} )) && return 1
eval "${NSCMDSH[i]}"
;;
3)
(( $# != 3 )) && return 64
NSCMDNS[${#NSCMDNS[@]}]=$1
NSCMDFN[${#NSCMDFN[@]}]=$2
NSCMDSH[${#NSCMDSH[@]}]=$3
! alias $1 >/dev/null && alias $1="nsalias $1"
;;
*)
return 64
;;
esac
}

20
tcat Normal file
View File

@ -0,0 +1,20 @@
function tcat
{
(( $# != 1 )) && return 64
case $1 in
log)
(jr && less ../bundles/tomcat-*/logs/catalina.out)
;;
start)
pgrep -f tomcat && return 1
(jr && ../bundles/tomcat-*/bin/catalina.sh jpda start) >/dev/null
;;
stop)
pgrep -f tomcat || return 1
(jr && ../bundles/tomcat-*/bin/shutdown.sh) >/dev/null
;;
*)
return 64
;;
esac
}