Add this to Windows Terminal settings (Settings -> Open JSON file) after launchMode
for example:
"startupActions": "new-tab -p Ubuntu wsl -- source ~/.bash_profile \\; cd ~/www/rails-project \\; bin/rails s \\; $SHELL; new-tab -p Ubuntu wsl -- source ~/.bash_profile \\; cd ~/www/rails-project \\; bin/webpack-dev-server \\; $SHELL; new-tab -p Ubuntu wsl -- source ~/.bash_profile \\; cd ~/www/rails-project \\; $SHELL"
Explanation:
Start rails server. Tab will not be closed if server stopped by user, because of $SHELL. Using source ~/.bash_profile
because rvm not loaded without it
new-tab -p Ubuntu wsl -- source ~/.bash_profile \\; cd ~/www/rails-project \\; bin/rails s \\; $SHELL
Start webpack
new-tab -p Ubuntu wsl -- source ~/.bash_profile \\; cd ~/www/rails-project \\; bin/webpack-dev-server \\; $SHELL
Just open tab in project folder
new-tab -p Ubuntu wsl -- source ~/.bash_profile \\; cd ~/www/rails-project \\; $SHELL
Alternatively combine rails server tab and webpack tab in single tab by changing new-tab
to split-pane
:
"startupActions": "new-tab -p Ubuntu wsl -- source ~/.bash_profile \\; cd ~/www/rails-project \\; bin/rails s \\; $SHELL; split-pane -p Ubuntu wsl -- source ~/.bash_profile \\; cd ~/www/rails-project \\; bin/webpack-dev-server \\; $SHELL; new-tab -p Ubuntu wsl -- source ~/.bash_profile \\; cd ~/www/rails-project \\; $SHELL"
To start apache2
and postgres
create /etc/wsl.conf
and add:
[boot]
command = "service apache2 start && service postgresql start"
Links:
- https://superuser.com/questions/1486054/windows-terminal-predefined-tabs-on-startup
- https://www.cloudwithchris.com/blog/fix-bashrc-not-executing-wsl/
- https://learn.microsoft.com/en-us/windows/terminal/command-line-arguments
- microsoft/terminal#7452 (comment)
- https://askubuntu.com/a/1356147/160368
- https://serverfault.com/a/877786/195251