Browse Source

ADD: Script to run command in terminal (OS X)

Alexander Koblov 9 years ago
parent
commit
014addb675
1 changed files with 24 additions and 0 deletions
  1. 24 0
      scripts/terminal.sh

+ 24 - 0
scripts/terminal.sh

@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+# Execute command in terminal emulator Mac OS X
+
+# Path to temporary script file
+SCRIPT_FILE=/var/tmp/doublecmd-$(date +%s)
+
+# Add shebang
+echo "#!/usr/bin/env bash" > $SCRIPT_FILE
+
+# Remove temporary script file at exit
+echo "trap 'rm -f $SCRIPT_FILE' INT TERM EXIT" >> $SCRIPT_FILE
+
+# Change to directory
+echo "cd $(pwd)" >> $SCRIPT_FILE
+
+# Copy over target command line
+echo "$@" >> $SCRIPT_FILE
+
+# Make executable
+chmod +x "$SCRIPT_FILE"
+
+# Execute in terminal
+open -b com.apple.terminal "$SCRIPT_FILE"