Guest User

Untitled

a guest
Sep 14th, 2021
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.38 KB | None | 0 0
  1. ### Original (With a Few Comments):
  2. ####
  3. #!/bin/bash
  4. if [ "$1" == "-h" ]; then
  5.   echo "Script for https://github.com/daniel-seiler/ImageTheming"
  6.   echo "This script requires the .jar to be in the same folder as it" # Useless use of echo
  7.   echo "                                           -Script by Xyliad"
  8.   exit 0
  9. fi
  10. FILE=ImageTheming.jar
  11. # Uppercase variable names are usually associated with global (environment) variables, while the variable declared here is a local one, see https://www.youtube.com/watch?v=9ZpL8iDU7LY
  12. # for the difference between those and for more info on shell variables
  13. if [ -f "$FILE" ]; then
  14.   echo "Image Themer Script"
  15.   echo "Please enter absolute image path"
  16.   read imagepath
  17.   echo "Please enter theme name/absolute path"
  18.   read theme
  19.   echo "Please enter output absolute path"
  20.   read output
  21.   java -jar ImageTheming.jar $imagepath -t=$theme -o=$output # Quoting the variables is probably a good idea
  22.   echo "---Done---"
  23. else
  24.   echo "$FILE not found"
  25. fi
  26. exit # There's no need to explicitly exit at the end of the script
  27. ####
  28. ### My version:
  29. ####
  30. #!/bin/bash
  31. if [ "$1" == "-h" ]; then
  32.   echo "Script for https://github.com/daniel-seiler/ImageTheming
  33. This script requires the .jar to be in the same folder as it
  34.                                           -Script by Xyliad"
  35.   # You can also use echo -e 'Script for https://github.com/daniel-seiler/ImageTheming\nThis script requires the .jar to be in the same folder as it\n                                        -Script by Xyliad'
  36.   exit 0
  37. fi
  38. file=ImageTheming.jar
  39. if [ -f "$file" ]; then
  40.   echo "Image Themer Script
  41. Please enter absolute image path "
  42.   read imagepath
  43.   echo "Please enter theme name/absolute path "
  44.   read theme
  45.   echo "Please enter output absolute path "
  46.   read output
  47.   java -jar ImageTheming.jar "$imagepath" -t="$theme" -o="$output"
  48.   echo "---Done--- "
  49. else
  50.   echo "$file not found" > /dev/stderr # echo as an error
  51.   exit 1 # exit with non 0 exit code
  52. fi
  53. ####
  54.  
  55. ### An Overcomplicated Way to Always Print the Credit Message on the Right Side
  56. ####
  57. #!/bin/bash
  58. spaces=$(( $(tput cols) - 18 )) #number of columns in the terminal right now, minus 18
  59. [ $spaces -lt 1 ] && spaces=1 #shorthand way of writing if [ $spaces -lt 1 ]; then spaces = 1; fi
  60. for i in {1..$spaces}; do # shorthand way of writing for i in `range ...
  61.   echo -n ' '
  62. done
  63. echo '-Script by Xyliad'
  64. ####
  65.  
Advertisement
Add Comment
Please, Sign In to add comment