Is there any command that opens a new terminal tab or window and runs another command, eg. less +F ~/log.txt in the new tab/window?
2 Answers
Consider utilizing osascript to execute an Applescript.
For instance in your Terminal application run the following command:
osascript -e 'tell application "Terminal" to do script "less +F ~/log.txt"'
This will create a new Terminal window and run the less +F ~/log.txt command.
4 Comments
sadmansh
Thank you! Is there a way I could use this for other operating systems besides macOS? Linux and Windows basically.
RobC
No,
osascript exists on mac only. Why have you tagged your question with macos tag?TamaMcGlinn
@RobC or tmux for a more modern version. Personally I use :term in vim which gives me even more capabilities.
RobC
@TamaMcGlinn - Sure - I didn't mention that because macOS doesn't ship with builtin
tmux - a $ brew install tmux is required.