aboutsummaryrefslogtreecommitdiff
path: root/common/scripts/utils/xtouch
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2025-09-24 05:45:26 +0200
committersrdusr <trevorgray@srdusr.com>2025-09-24 05:45:26 +0200
commitd96a422496fe3a6b80659a720e63c6abc41b7de9 (patch)
tree20f90abb5ce91875a40027333efbb52877902132 /common/scripts/utils/xtouch
parent521215add7da7fef6722c7b5adec839b84d72db0 (diff)
parenta1627ac743289e768b138f1a60753a62e0869cc4 (diff)
downloaddotfiles-d96a422496fe3a6b80659a720e63c6abc41b7de9.tar.gz
dotfiles-d96a422496fe3a6b80659a720e63c6abc41b7de9.zip
Add 'common/scripts/' from commit 'a1627ac743289e768b138f1a60753a62e0869cc4'
git-subtree-dir: common/scripts git-subtree-mainline: 521215add7da7fef6722c7b5adec839b84d72db0 git-subtree-split: a1627ac743289e768b138f1a60753a62e0869cc4
Diffstat (limited to 'common/scripts/utils/xtouch')
-rwxr-xr-xcommon/scripts/utils/xtouch38
1 files changed, 38 insertions, 0 deletions
diff --git a/common/scripts/utils/xtouch b/common/scripts/utils/xtouch
new file mode 100755
index 0000000..a5eb23b
--- /dev/null
+++ b/common/scripts/utils/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