this repo has no description

wip

+51
+50
create_symlink.sh
··· 1 + #!/bin/bash 2 + 3 + while getopts ":s:t:tu:tw:" opt; do 4 + case $opt in 5 + s) 6 + source_file="$OPTARG" 7 + ;; 8 + t) 9 + symlink_name_generic="$OPTARG" 10 + ;; 11 + tu) 12 + symlink_name_unix="$OPTARG" 13 + ;; 14 + tw) 15 + symlink_name_windows="$OPTARG" 16 + ;; 17 + \?) 18 + echo "Invalid option: -$OPTARG" >&2 19 + exit 1 20 + ;; 21 + :) 22 + echo "Option -$OPTARG requires an argument." >&2 23 + exit 1 24 + ;; 25 + esac 26 + done 27 + 28 + # Check if the required options are provided 29 + if [ -z "$source_file" ] || ([ -z "$symlink_name_generic" ] && [ -z "$symlink_name_unix" ] && [ -z "$symlink_name_windows" ]); then 30 + echo "Usage: create_symlink -s source_file [-t symlink_name_generic] [-tu symlink_name_unix] [-tw symlink_name_windows]" 31 + exit 1 32 + fi 33 + 34 + if [ -n "$symlink_name_generic" ] && [ -z "$symlink_name_windows" ] && [ -z "symlink_name_unix" ]; then 35 + symlink_name_windows="$symlink_generic"; 36 + symlink_name_unix="$symlink_generic"; 37 + # else 38 + # target_name_windows="$symlink_name_windows"; 39 + fi 40 + 41 + # Check the operating system 42 + if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then 43 + # Windows (using PowerShell) 44 + powershell -Command "New-Item -ItemType SymbolicLink -Path $symlink_name_windows -Value $source_file" 45 + echo "Symbolic link created (Windows): $symlink_name_windows -> $source_file" 46 + else 47 + # Unix-like (using Bash) 48 + ln -s "$source_file" "$symlink_name_unix" 49 + echo "Symbolic link created (Unix): $symlink_name_unix -> $source_file" 50 + fi
+1
source.txt
··· 1 + test