aboutsummaryrefslogtreecommitdiffstats
path: root/hm/soispha/pkgs/scripts/specific/neorg/sh
diff options
context:
space:
mode:
Diffstat (limited to 'hm/soispha/pkgs/scripts/specific/neorg/sh')
-rwxr-xr-xhm/soispha/pkgs/scripts/specific/neorg/sh/functions/add.sh12
-rwxr-xr-xhm/soispha/pkgs/scripts/specific/neorg/sh/functions/context.sh28
-rwxr-xr-xhm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu.sh6
-rwxr-xr-xhm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start.sh4
-rwxr-xr-xhm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop.sh4
-rwxr-xr-xhm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh25
-rwxr-xr-xhm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils.sh28
-rwxr-xr-xhm/soispha/pkgs/scripts/specific/neorg/sh/main.sh129
8 files changed, 117 insertions, 119 deletions
diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add.sh
index bd700775..5a830a10 100755
--- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add.sh
+++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add.sh
@@ -1,23 +1,23 @@
#!/usr/bin/env dash
add0open_taskwarrior_project_file() {
- task_project_file="%TASK_PROJECT_FILE";
+ task_project_file="%TASK_PROJECT_FILE"
cd "$(dirname $task_project_file)" || die "BUG: task_project_file ('$task_project_file') can't be accessed"
- git_dir="$(search_flake_base_dir)";
+ git_dir="$(search_flake_base_dir)"
[ "$git_dir" ] || die "(BUG): No git directory?"
cd "$git_dir" || die "Unreachable, this MUST exists"
- nvim "$task_project_file";
- git add "$task_project_file";
+ nvim "$task_project_file"
+ git add "$task_project_file"
base_task_project_file_path="$(awk "{ gsub(\"$git_dir/\", \"\", \$0); print }" "$(ptmp "$task_project_file")")"
- git add $task_project_file;
+ git add $task_project_file
# Check that only the project file has been added (and that our file is actually
# modified)
if git status --porcelain=v2 | awk -v path="$base_task_project_file_path" 'BEGIN { hit = 0 } { if ($2 ~ /A./ || $2 ~ /M./) { if ($NF ~ path) { hit = 1 } else { hit = 0; exit 1 } } } END { if (hit == 1) { exit 0 } else { exit 1 } }'; then
- git commit --verbose --message="chore($(dirname "$base_task_project_file_path")): Update"
+ git commit --verbose --message="chore($(dirname "$base_task_project_file_path")): Update"
fi
}
diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context.sh
index b9ae4463..7095847d 100755
--- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context.sh
+++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context.sh
@@ -4,40 +4,40 @@ context0open_current_task_context() {
current_context="$(utils0get_current_context)"
if [ "$current_context" ]; then
- context_path="$(utils0get_current_context_path "$current_context")";
+ context_path="$(utils0get_current_context_path "$current_context")"
- extended_neorg_project_dir="$(utils0get_neorg_project_dir)";
- cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir";
+ extended_neorg_project_dir="$(utils0get_neorg_project_dir)"
+ cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir"
- nvim "$extended_neorg_project_dir/$context_path";
+ nvim "$extended_neorg_project_dir/$context_path"
- git add .;
+ git add .
git commit --message="chore($(dirname "$context_path")): Update" --no-gpg-sign
else
- warn "No context active";
+ warn "No context active"
fi
}
context0open_current_task_context_at_task_id() {
- task_id="$1";
+ task_id="$1"
current_context="$(utils0get_current_context)"
if [ "$current_context" ]; then
- context_path="$(utils0get_current_context_path "$current_context")";
- extended_neorg_project_dir="$(utils0get_neorg_project_dir)";
+ context_path="$(utils0get_current_context_path "$current_context")"
+ extended_neorg_project_dir="$(utils0get_neorg_project_dir)"
task_uuid="$(task "$task_id" uuids)"
- cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir";
+ cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir"
if ! grep -q "% $task_uuid" "$extended_neorg_project_dir/$context_path"; then
- echo "* TITLE (% $task_uuid)" >> "$extended_neorg_project_dir/$context_path"
+ echo "* TITLE (% $task_uuid)" >>"$extended_neorg_project_dir/$context_path"
fi
- nvim "$extended_neorg_project_dir/$context_path" -c "/% $task_uuid";
+ nvim "$extended_neorg_project_dir/$context_path" -c "/% $task_uuid"
- git add .;
+ git add .
git commit --message="chore($(dirname "$context_path")): Update" --no-gpg-sign
else
- warn "No context active";
+ warn "No context active"
fi
}
diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu.sh
index 36133004..73e9460a 100755
--- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu.sh
+++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu.sh
@@ -1,12 +1,12 @@
#!/usr/bin/env dash
dmenu0open_context_in_browser() {
- project="$(echo "%ALL_PROJECTS_PIPE" | rofi -sep "|" -dmenu)";
+ project="$(echo "%ALL_PROJECTS_PIPE" | rofi -sep "|" -dmenu)"
if [ "$project" ]; then
- project0open_project_in_browser "$project";
+ project0open_project_in_browser "$project"
else
- notify-send "(neorg/dmenu) No project selected";
+ notify-send "(neorg/dmenu) No project selected"
exit 1
fi
}
diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start.sh
index c75986a7..2423dd44 100755
--- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start.sh
+++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start.sh
@@ -1,7 +1,7 @@
#!/usr/bin/env dash
fstart0start_new_task() {
- task_id="$1";
- fstop0stop_current_task;
+ task_id="$1"
+ fstop0stop_current_task
task start "$task_id"
}
diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop.sh
index d60cb46f..e4ff0b94 100755
--- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop.sh
+++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop.sh
@@ -2,6 +2,6 @@
fstop0stop_current_task() {
# we ensured that only one task may be active
- active="$(task +ACTIVE _ids)";
- [ "$active" ] && task stop "$active";
+ active="$(task +ACTIVE _ids)"
+ [ "$active" ] && task stop "$active"
}
diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh
index 8def0930..64591850 100755
--- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh
+++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh
@@ -1,33 +1,32 @@
#!/usr/bin/env dash
project0open_current_context_in_browser() {
- current_context="$(utils0get_current_context)";
- [ "$current_context" ] || die "No current context to use";
- project0open_context_in_browser "$(utils0context2project "$current_context")";
+ current_context="$(utils0get_current_context)"
+ [ "$current_context" ] || die "No current context to use"
+ project0open_context_in_browser "$(utils0context2project "$current_context")"
}
project0open_project_in_browser() {
- project="$1";
+ project="$1"
[ "$project" ] || die "BUG: No context supplied to project0open_context_in_browser"
- old_context="$(utils0get_current_context)";
+ old_context="$(utils0get_current_context)"
# We have ensured that only one task may be active
- old_started_task="$(task +ACTIVE _ids)";
+ old_started_task="$(task +ACTIVE _ids)"
- tracking="$(mktmp)";
- task "project:$project" _ids | xargs --no-run-if-empty task _zshids > "$tracking";
+ tracking="$(mktmp)"
+ task "project:$project" _ids | xargs --no-run-if-empty task _zshids >"$tracking"
task context "$(utils0project2context "$project")"
while read -r description; do
- desc="$(echo "$description" | awk -F: '{print $2}' )";
+ desc="$(echo "$description" | awk -F: '{print $2}')"
if [ "$desc" = "tracking" ]; then
- task_id="$(echo "$description" | awk -F: '{print $1}' )";
- notify-send "(Neorg)" "Starting task $project -> $desc";
+ task_id="$(echo "$description" | awk -F: '{print $1}')"
+ notify-send "(Neorg)" "Starting task $project -> $desc"
task start "$task_id"
break
fi
- done < "$tracking"
-
+ done <"$tracking"
firefox -P "$project"
diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils.sh
index 91da811a..c3843e8e 100755
--- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils.sh
+++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils.sh
@@ -3,19 +3,20 @@
# Runs it's first argument and then the second, regardless if the first failed or
# succeeded
utils0chain() {
- eval "$1"; eval "$2"
+ eval "$1"
+ eval "$2"
}
utils0get_current_context() {
- current_context="$(task _get rc.context)";
- printf "%s\n" "$current_context";
+ current_context="$(task _get rc.context)"
+ printf "%s\n" "$current_context"
}
utils0get_current_context_path() {
- current_context="$1";
- context_path="$(task _get rc.context."$current_context".rc.neorg_path 2>/dev/null)";
+ current_context="$1"
+ context_path="$(task _get rc.context."$current_context".rc.neorg_path 2>/dev/null)"
if ! [ "$context_path" ]; then
- context_path="$(grep "context.$current_context.rc.neorg_path" "%HOME_TASKRC" | awk 'BEGIN {FS="="} {print $2}')";
+ context_path="$(grep "context.$current_context.rc.neorg_path" "%HOME_TASKRC" | awk 'BEGIN {FS="="} {print $2}')"
[ "$context_path" ] || die "All contexts should have a 'neorg_path' set!"
fi
printf "%s\n" "$context_path"
@@ -23,18 +24,17 @@ utils0get_current_context_path() {
utils0get_neorg_project_dir() {
# Perform shell expansion of Tilde
- neorg_project_dir="$(sed "s|^~|$HOME|" "$(ptmp "%DEFAULT_NEORG_PROJECT_DIR")")";
+ neorg_project_dir="$(sed "s|^~|$HOME|" "$(ptmp "%DEFAULT_NEORG_PROJECT_DIR")")"
printf "%s\n" "$neorg_project_dir"
}
-
utils0project2context() {
- project="$1";
- context="$(sed 's|\.|_|g' "$(ptmp "$project")")";
- printf "%s\n" "$context";
+ project="$1"
+ context="$(sed 's|\.|_|g' "$(ptmp "$project")")"
+ printf "%s\n" "$context"
}
utils0context2project() {
- context="$1";
- project="$(sed 's|_|\.|g' "$(ptmp "$context")")";
- printf "%s\n" "$project";
+ context="$1"
+ project="$(sed 's|_|\.|g' "$(ptmp "$context")")"
+ printf "%s\n" "$project"
}
diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh
index 25b434fc..dc746ef8 100755
--- a/hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh
+++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh
@@ -14,7 +14,6 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH
. ./functions/utils
. ./functions/workspace
-
# these are used in version()
# shellcheck disable=2034
AUTHORS="Soispha"
@@ -24,7 +23,7 @@ YEARS="2023"
NAME="neorg"
help() {
-cat << EOF
+ cat <<EOF
This is the core interface to the system-integrated task management
USAGE:
@@ -82,75 +81,75 @@ EOF
for arg in "$@"; do
case "$arg" in
- "--help" | "-h")
- help;
- exit 0;
- ;;
- "--version" | "-v")
- version;
- exit 0;
- ;;
+ "--help" | "-h")
+ help
+ exit 0
+ ;;
+ "--version" | "-v")
+ version
+ exit 0
+ ;;
esac
done
while [ "$#" -ne 0 ]; do
case "$1" in
- "t"*) # task
- shift 1;
- task_id="$1";
- [ "$task_id" ] || utils0chain context0open_current_task_context "exit 0"
- context0open_current_task_context_at_task_id "$task_id";
- exit 0;
- ;;
- "w"*) # workspace
- shift 1;
- workspace_to_open="$1";
- # TODO: Exit with 1 on error, instead of the 0 <2023-10-20>
- [ "$workspace_to_open" ] || utils0chain workspace0open_neorg_workspace_prompt "exit 0";
- workspace0open_neorg_workspace "$workspace_to_open";
- exit 0;
- ;;
- "p"*) # project
- shift 1;
- project_to_open="$1";
- # TODO: Exit with 1 on error, instead of the 0 <2023-10-20>
- [ "$project_to_open" ] || utils0chain project0open_current_context_in_browser "exit 0";
- if ! grep -q "$project_to_open" "$(ptmp "%ALL_PROJECTS_NEWLINE")"; then
- die "Your project ('$project_to_open') is not in the list of available projects:
-%ALL_PROJECTS_COMMA";
- fi
- project0open_project_in_browser "$project_to_open";
- exit 0;
- ;;
- "l"*) # list
- list0list_all_contexts_newline;
- exit 0
- ;;
- "a"*) # add-project
- add0open_taskwarrior_project_file;
- exit 0
- ;;
- "d"*) # dmenu
- dmenu0open_context_in_browser;
- exit 0
- ;;
- "fsta"*) # fstart
- shift 1;
- task_id="$1";
- [ "$task_id" ] || die "No task id provided to fstart";
- fstart0start_new_task "$task_id";
- exit 0
- ;;
- "fsto"*) # fstop
- fstop0stop_current_task;
- exit 0
- ;;
- *)
- die "Command '$1' does not exist! Please look at:\n $NAME --help";
- exit 0;
- ;;
+ "t"*) # task
+ shift 1
+ task_id="$1"
+ [ "$task_id" ] || utils0chain context0open_current_task_context "exit 0"
+ context0open_current_task_context_at_task_id "$task_id"
+ exit 0
+ ;;
+ "w"*) # workspace
+ shift 1
+ workspace_to_open="$1"
+ # TODO: Exit with 1 on error, instead of the 0 <2023-10-20>
+ [ "$workspace_to_open" ] || utils0chain workspace0open_neorg_workspace_prompt "exit 0"
+ workspace0open_neorg_workspace "$workspace_to_open"
+ exit 0
+ ;;
+ "p"*) # project
+ shift 1
+ project_to_open="$1"
+ # TODO: Exit with 1 on error, instead of the 0 <2023-10-20>
+ [ "$project_to_open" ] || utils0chain project0open_current_context_in_browser "exit 0"
+ if ! grep -q "$project_to_open" "$(ptmp "%ALL_PROJECTS_NEWLINE")"; then
+ die "Your project ('$project_to_open') is not in the list of available projects:
+%ALL_PROJECTS_COMMA"
+ fi
+ project0open_project_in_browser "$project_to_open"
+ exit 0
+ ;;
+ "l"*) # list
+ list0list_all_contexts_newline
+ exit 0
+ ;;
+ "a"*) # add-project
+ add0open_taskwarrior_project_file
+ exit 0
+ ;;
+ "d"*) # dmenu
+ dmenu0open_context_in_browser
+ exit 0
+ ;;
+ "fsta"*) # fstart
+ shift 1
+ task_id="$1"
+ [ "$task_id" ] || die "No task id provided to fstart"
+ fstart0start_new_task "$task_id"
+ exit 0
+ ;;
+ "fsto"*) # fstop
+ fstop0stop_current_task
+ exit 0
+ ;;
+ *)
+ die "Command '$1' does not exist! Please look at:\n $NAME --help"
+ exit 0
+ ;;
esac
done
-context0open_current_task_context;
+context0open_current_task_context
# vim: ft=sh