Skip to content

Instantly share code, notes, and snippets.

@yousefamar
Last active August 29, 2015 14:06
Show Gist options
  • Save yousefamar/26f2128dadbd20340db2 to your computer and use it in GitHub Desktop.
Save yousefamar/26f2128dadbd20340db2 to your computer and use it in GitHub Desktop.
Runs a command multiple times in new terminals with different arguments
#!/usr/bin/sh
#
# Runs a command multiple times in new terminals with different arguments
#
# Authors:
# Yousef Amar <[email protected]>
#
if [ $# -lt 1 ]; then
echo "syntax: spawn.sh COMMAND [ARGS...]"
exit
fi
TERMINAL="evilvte"
if [ $# -lt 2 ]; then
$TERMINAL -e "$1" &
exit
fi
for args in "${@:2}"
do
$TERMINAL -e "$1" "$args" &
done
@yousefamar
Copy link
Author

Notes:

  1. Best used with something like alias sp='spawn.sh ' in your shell's rc file
  2. Further aliasing: alias vv='spawn.sh vim' will vim each file argument in a new terminal
  3. Wildcards do not necessarily need to be tabbed out; this will work: vv scripts/*.py
  4. Use quotes at your leisure, e.g. sp ping "-c 10 google.com" "-v facebook.com" youtube.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment