terminal-run.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. # Run a terminal with title and command
  3. # User can already hack this file with their own terminal etc.
  4. # I didn't check the other ones
  5. # TODO: User can provide a "terminal-program" in the settings, say you can get inspired by Packages/CodePatcher/Server/linux-x64/terminal-run.sh
  6. # the script is run with 2 args, a title and a command script to run.
  7. # If called with 0 args, signal the capability to start a terminal.
  8. # If you add your own terminal, make sure to also return 0 when called with 0 args.
  9. TITLE="$1"
  10. COMMAND="$2"
  11. if [ -z "$1" ]; then
  12. [ -x "$(command -v gnome-terminal)" ] && exit 0
  13. [ -x "$(command -v xterm)" ] && exit 0
  14. [ -x "$(command -v konsole)" ] && exit 0
  15. [ -x "$(command -v terminator)" ] && exit 0
  16. [ -x "$(command -v urxvt)" ] && exit 0
  17. [ -x "$(command -v Alacritty)" ] && exit 0
  18. exit 1
  19. fi
  20. if [ -x "$(command -v gnome-terminal)" ]; then
  21. gnome-terminal --title="$TITLE" -- "$SHELL" -c "$COMMAND"
  22. elif [ -x "$(command -v xterm)" ]; then
  23. xterm -title "$TITLE" -e "$SHELL -c '$COMMAND'"
  24. elif [ -x "$(command -v konsole)" ]; then
  25. konsole --title "$TITLE" --noclose -e "$SHELL -c '$COMMAND'"
  26. elif [ -x "$(command -v terminator)" ]; then
  27. terminator --title="$TITLE" --command="$SHELL -c '$COMMAND'"
  28. elif [ -x "$(command -v urxvt)" ]; then
  29. urxvt -title "$TITLE" -e "$SHELL" -c "clear && $COMMAND"
  30. elif [ -x "$(command -v Alacritty)" ]; then
  31. alacritty -t "$TITLE" -e "$SHELL -c '$COMMAND'"
  32. fi