There are quite a few commands that take subcommands (e.g.,
task from taskwarrior). Sometimes I have a terminal window that is devoted entirely to running this command with varying subcommands. What I wish is that I would not always need to type the main command. Let me explain this with an example from taskwarrior (a “todo list manager”):
$ task add proj:job +hard Refactor the API -- Add task to project 'job' tagged 'hard' $ task proj:job +easy add prio:H Fix typo in README -- Tag is 'easy', priority 'high' $ task proj:job next -- List tasks in project 'job', ordered by 'urgency'
As you can see,
task is quite flexible in where the subcommand (e.g.,
next) can be placed. Now, if I'm working on a certain project (say 'job') then I would like to drill down. Something like:
$ CONTEXT="task proj:job" [task proj:job] $ add +hard Refactor the API [task proj:job] $ +easy add prio:H Fix typo in README [task proj:job] $ next
The title of this question is very broad (suggesting you might want to run a sed-script over your command before executing it). However, I would be very happy with one of the following:
- I can set some variable (like
CONTEXTin the example) whose value is prepended to every command, before running it.
- Alternatively, and even better, the value of
CONTEXTcould be filled in on the command line before I start typing my commands. In that way, I can occasionaly hit backspace or
Ctrl-Uif I want to run a command outside of my context.
Q. Is there a shell (preferably bash-like, for example
zsh) that has the described feature?