Skip to content

Insert command in command prompt

Compare
Choose a tag to compare
@dvorka dvorka released this 08 Dec 07:04

New HSTR release brings parameter which can be used to insert commands in terminal prompt:

$ hstr --insert-in-terminal="ls -hal"
$ ls -hal|

It is useful whenever you need to:

  • construct complex command using a shell script to modify current shell with source and check and/or edit it prior running:
$ hstr --insert-in-terminal="`my-script-which-constructs-command.sh`"
$ export CONDA_INSTALL_DIR=/opt/conda/acme && unset PYTHONPATH && source ../.rc_conda && conda activate env_prj|
  • insert command to terminal prompt directly from a shell script to modify current shell:
$ cat my-script-which-inserts-command.sh
...
hstr --insert-in-terminal="${CMD} -vvv ${REQUIRED_PARAMS} ${OPTIONAL_PARAMS} ${2}"
...
$ ./my-script-which-inserts-command.sh
ACME builder:
  clean ... DONE
  build ... DONE
Ready to test product:
$ pytest -vvv -n 8 --use-fixture-cache tests/feature_test.py::test_case|

Overall this feature aims to help you to be faster and get more out of your shell scripts.

Enjoy!


| in the examples above indicates cursor position