Skip to content

Commit

Permalink
Merge pull request #1 from Genzer/dev/0.2.0
Browse files Browse the repository at this point in the history
Dev/0.2.0
  • Loading branch information
Genzer authored Jan 11, 2021
2 parents 47d7708 + 77688e6 commit 03506d4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,15 @@ The following commands can be used:
help
Show this usage.
```
## Hooks
_since 0.2.0_
`focus.sh` supports hooks (like Git hooks) which will be called upon some commands get done. The commands at the moment support hooks are:
- `focus to`: the hook defined by an environment variable `FOCUS_TO__HOOK` or default to `$HOME/.focus/hooks/focus_to.sh`.
- `focus done`: the hook defined by an environment variable `FOCUS_DONE__HOOK` or default to `$HOME/.focus/hooks/focus_done.sh`.
A hook is an executable (a script file or a binary file) which, this is important, that the current user is granted execute permission (e.g `chmod u+x`).
The hook will be called with exactly the parameters passed in from the original `focus.sh` command.
7 changes: 6 additions & 1 deletion focus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
FOCUS_TRACKING_REPO=${FOCUS_TRACKING_REPO:-$HOME/work/focus.sh-tracking}

function focus__version() {
echo "0.1.0"
echo "0.2.0"
}

function focus__init() {
Expand All @@ -32,6 +32,8 @@ function focus__done() {
__git merge --no-ff --no-edit "$current_branch"
__git branch -D "${current_branch}"
__git switch "nothing"
local hook="${FOCUS_DONE__HOOK:-$HOME/.focus/hooks/focus_done.sh}"
[ -f ${hook} ] && ${hook}
}

function focus__all() {
Expand All @@ -58,6 +60,9 @@ function focus__to() {
focus__jot -m "Started on ${new_topic}"
fi

local hook="${FOCUS_TO__HOOK:-$HOME/.focus/hooks/focus_to.sh}"
[ -f ${hook} ] && ${hook} "${new_topic}"

echo "previous topic $(focus__before)"
}

Expand Down

0 comments on commit 03506d4

Please sign in to comment.