shell-hooks

Crates.ioshell-hooks
lib.rsshell-hooks
version0.1.2
sourcesrc
created_at2019-02-11 12:35:34.78708
updated_at2019-02-11 12:40:40.959459
descriptionRun ``pre`` and ``post`` hooks while executing a command, just like githooks but for all programs.
homepage
repository
max_upload_size
id114066
size8,623
Dinesh Bhattarai (dineshdb)

documentation

README

Shell-hooks

Run pre and post hooks while executing a command, just like githooks but for all programs.

Future plans

  • Block the command based on status of prehook.
  • Extract async hooks and run using tokio.
  • Run sync hooks parallely but before the command.

Maybe someday

  • Implement this as a feature atop pre-existing shells (mayb ion?).

Getting Started

  • Install rust
  • Clone this repo.
  • Install this tool: cargo install --path ..
  • Alias any tool in ~/.bashrc by wrapping it with shell-hooks. Like alias git = 'shell-hooks git'.
  • Now add your pre and post hook definitions in ~/.local/share/dshell/definitions/. The file format is toml. The filename does not matter, only content does.

Writing hooks

Currently there are only two useful fields for hook type, the trigger and action.

  • Trigger: It is any command with space replaced with / and preceded by /cmd/. So git commit becomes /cmd/git/commit.
  • Action: It is any shell command defined as string.
  • Execution: Execution mode. Sync can run paralley yet completes before the command. Return status can block the execution of program. Async run parallely with actual command, return code does not matter. Default: Async

Contributing

If you have any contribution idea, please create an issue.

License

MIT License

Copyright

Commit count: 0

cargo fmt