问题
In the interest of avoiding an XY problem, I'm trying to set up an iTerm profile to do the following when I hit the hotkey.
- cd to ~/my/directory/
- start an http server in the background
- let me stay in ~/my/directory/
The command I'm working with so far is cd ~/my/directory/ && python -m SimpleHTTPServer 8000 &> /dev/null &
This works great for starting the server on the project root. The problem is, after it starts running in the background, my pwd is NOT ~/my/directory/. I guess that part is sent to the background too.
Is there a way to accomplish step 3 without having to cd again manually afterward?
回答1:
This works for me
;
instead of &&
cd ~/my/directory/ ; python -m SimpleHTTPServer 8000 &> /dev/null &
or second command in ( )
cd ~/my/directory/ && (python -m SimpleHTTPServer 8000 &> /dev/null &)
来源:https://stackoverflow.com/questions/55521091/can-i-run-two-bash-commands-at-once-and-send-only-one-to-the-background