I want to write a shell script that does the following:
mkdocs serve
which starts a local dev server for my mkdocs documentationIf I do the naïve thing and put this in my script:
cd <my-docs-directory>
pipenv shell
mkdocs serve
it fails because pipenv shell
"launches a subshell in the virtual environment". I need to pass the mkdocs serve
command into the virtual shell (and preferably land in that same shell after running the script ).
Thanks in advance!
Philippe's answer works. Here's why.
pipenv run bash -c 'mkdocs serve ; exec bash --norc'
$ pipenv run <insert command here>
bash -c <insert command here>
allows you to pass a command to bash to execute
$ bash -c "echo hello"
hello
exec
serves to replace current shell process with a command, so that parent goes a way and child owns pid. Here's a related question on AskUbuntu.You can use this command :
pipenv run bash -c 'mkdocs serve ; exec bash --norc'