Work on project management
This commit is contained in:
parent
54bcccfe08
commit
74b30900ab
9 changed files with 634 additions and 256 deletions
83
bin/.bin/project-management/project-current
Executable file
83
bin/.bin/project-management/project-current
Executable file
|
@ -0,0 +1,83 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
NOTIFY=0
|
||||
PRINTPATH=0
|
||||
|
||||
function print_help(){
|
||||
echo -e "current\t\tPrints the current project"
|
||||
echo -e "\t--notify\tUses notify send to print current project"
|
||||
echo -e "\t--path\tPrints the full path rather than the name"
|
||||
}
|
||||
|
||||
function get_name(){
|
||||
local path=$(get_path)
|
||||
local name
|
||||
if [ $? -eq "0" ]; then
|
||||
if [ -f "$path"/index.yaml ]; then
|
||||
name=$(cat "$path/index.yaml" | yq -r '.name')
|
||||
fi
|
||||
if [ -z "$name" ]; then
|
||||
name=$(basename "$path")
|
||||
fi
|
||||
echo "$name"
|
||||
exit 0
|
||||
fi
|
||||
exit 1
|
||||
}
|
||||
|
||||
function get_path(){
|
||||
if [ -L "$SYMLINC" ]; then
|
||||
readlink "$SYMLINC"
|
||||
exit 0
|
||||
fi
|
||||
exit 1
|
||||
}
|
||||
|
||||
function get_current(){
|
||||
local ret
|
||||
if [ "$PRINTPATH" -eq 1 ]; then
|
||||
ret=$(get_path)
|
||||
else
|
||||
ret=$(get_name)
|
||||
fi
|
||||
|
||||
if [ "$NOTIFY" -eq 1 ]; then
|
||||
if [ -n "$ret" ]; then
|
||||
notify-send "Current Project" "$ret"
|
||||
else
|
||||
notify-send "Current Project" "Not Set"
|
||||
fi
|
||||
else
|
||||
echo "$ret"
|
||||
fi
|
||||
|
||||
if [ -n "$ret" ]; then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
while [ -n "$1" ]; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
print_help | column -t -s" "
|
||||
exit 0
|
||||
;;
|
||||
--parent-help)
|
||||
print_help
|
||||
exit 0
|
||||
;;
|
||||
--notify)
|
||||
NOTIFY=1
|
||||
shift
|
||||
;;
|
||||
--path)
|
||||
PRINTPATH=1
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
get_current
|
||||
exit $?
|
Loading…
Add table
Add a link
Reference in a new issue