I am trying to run an sh (or bash) script that cd into a folder, run a few commands and keep me there so I can start using that terminal. The problem is I can't figure out how to keep me there. the bash command at the end opens the terminal in my home folder instead of /tmp:
#!/bin/sh
xterm -hold -e "cd /tmp && ls && bash" &I would like to open a few terminals like this since I am working on a project that require multiple terminals (run backend service in one, frontend dev server in the other etc..)
Any ideas?
31 Answer
I solved the issue. I had the following lines in my .bashrc:
PROMPT_COMMAND='pwd > "${HOME}/.cwd"' # Save current working dir
[[ -f "${HOME}/.cwd" ]] && cd "$(< ${HOME}/.cwd)" # Change to saved working dirThe reason I have them is due to i3. I want i3 to open new terminal in the recent working dir.
I solved the issue by deleting the .cwd file:
xterm -e "cd /tmp && ls && rm ~/.cwd; bash" &