aboutsummaryrefslogtreecommitdiff
path: root/xtouch
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2024-01-27 23:45:11 +0200
committersrdusr <trevorgray@srdusr.com>2024-01-27 23:45:11 +0200
commit7d70dba918fc5c1808f8b0285f417cf21ed4ceef (patch)
tree1dd74d4688e2f58a5b31039e314558bd8eb419f8 /xtouch
parentc21cd44bd30b6856432f3bd98c1aa55752a916ce (diff)
downloaddotfiles-7d70dba918fc5c1808f8b0285f417cf21ed4ceef.tar.gz
dotfiles-7d70dba918fc5c1808f8b0285f417cf21ed4ceef.zip
Add xtouch script
Diffstat (limited to 'xtouch')
-rwxr-xr-xxtouch38
1 files changed, 38 insertions, 0 deletions
diff --git a/xtouch b/xtouch
new file mode 100755
index 0000000..a5eb23b
--- /dev/null
+++ b/xtouch
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+
+check_valid() {
+ if [ -f "$1" ]; then
+ echo "The file "$1" already exists!"
+ exit 1
+ fi
+}
+
+create_script() {
+ touch "$1"
+ chmod +x "$1"
+ echo "$0: $2 script file $1 created with exec permissions"
+ echo -e '#!/usr/bin/env '"$2" > "$1"
+}
+
+usage() {
+ echo -e "Quickly create executable script\n"
+ echo "Usage:"
+ echo " xtouch [ -w FILE LANG ]"
+ echo -e " xtouch ( -h | --help )\n"
+ echo "Arguments:"
+ echo "FILE Name to give the scripts"
+ echo -e "LANG Language in which the script will be written\n"
+ echo "Options:"
+ echo " -w FILE LANG Creates a <LANG> executable script file named <FILE>."
+ echo " -h --help Show this screen."
+}
+
+case "$1" in
+ '-w')
+ check_valid "$2"
+ create_script "$2" "$3"
+ ;;
+ *)
+ usage
+ ;;
+esac