aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/scripts/.local/bin/mkln.sh
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-03-29 16:50:45 -0500
committerToby Vincent <tobyv13@gmail.com>2022-03-29 16:50:45 -0500
commit6bfbdbf35365174903c305ec4b254c2523413ca6 (patch)
tree3b5b401cfaba667aaacca3db3eac455ac6930bd7 /scripts/.local/bin/mkln.sh
parenteea16815b501369da58a8c3886f41558022835ca (diff)
refactor: moved scripts into wsl package
Diffstat (limited to 'scripts/.local/bin/mkln.sh')
-rwxr-xr-xscripts/.local/bin/mkln.sh115
1 files changed, 0 insertions, 115 deletions
diff --git a/scripts/.local/bin/mkln.sh b/scripts/.local/bin/mkln.sh
deleted file mode 100755
index ef174c2..0000000
--- a/scripts/.local/bin/mkln.sh
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/usr/bin/env bash
-
-TEMP=$(getopt -o hvqdf --long help,verbose,quiet,debug,force \
- -n 'javawrap' -- "$@")
-
-if [ $? != 0 ]; then
- echo "Terminating..." >&2
- exit 1
-fi
-
-eval set -- "$TEMP"
-
-SCRIPT="$(basename $0)"
-VERBOSE=false
-QUIET=false
-DEBUG=false
-FORCE=false
-
-read -r -d '' USAGE <<-EOF
-USAGE: $SCRIPT [OPTIONS] <SOURCE> <TARGET>
-
-OPTIONS:
- -h, --help Show this message
- -v, --verbose Show more output
- -q, --quiet Suppress all output
- -d, --debug NOT IMPLEMENTED
- -f, --force Overwrite items
-
-ARGS:
- <SOURCE> <TARGET>... File to link.
-EOF
-
-while true; do
- case "$1" in
- -h | --help)
- echo "$USAGE"
- exit 0
- ;;
- -v | --verbose)
- VERBOSE=true
- shift
- ;;
- -q | --quiet)
- QUIET=true
- shift
- ;;
- -d | --debug)
- DEBUG=true
- shift
- ;;
- -f | --force)
- FORCE=true
- shift
- ;;
- --)
- shift
- break
- ;;
- *)
- break
- ;;
- esac
-done
-
-if ! command -v powershell.exe &>/dev/null; then
- [ "$QUIET" != true ] && echo "Powershell not found in path." >&2
- exit 1
-fi
-
-if [ -z "$2" ]; then
- 2="$(pwd)"
-fi
-
-[ "$VERBOSE" == true ] && echo "linking $2 -> $1"
-
-if [ -d "$1" ]; then
- [ "$VERBOSE" == true ] && echo "$1 is a directory. Creating symbolic link."
- args='/D'
-fi
-
-mkdir -p $(dirname $2)
-
-source=$(wslpath -w $1)
-target=$(wslpath -w $(dirname $2))\\$(basename $2)
-
-if ls -la "$(dirname $2)/" 2>/dev/null | grep -q "$(basename $2)"; then
-
- current_path=$(powershell.exe -c "(Get-Item $target).Target" 2>/dev/null)
-
- if [[ "${current_path/*wsl$/}" == *"${source/*wsl$/}"* ]]; then
- [ "$VERBOSE" == true ] && echo "$(basename $2) is set correctly. Skipping."
- exit 0
- fi
-
- if [ "$FORCE" == true ]; then
- [ "$VERBOSE" == true ] && echo "$(basename $2) exists. Overwriting."
- rm -rf "$2"
- else
- [ "$QUIET" != true ] && echo "$(basename $target) already exists. Use -f to overwrite." >&2
- exit 1
- fi
-fi
-
-mkdir -p "$(dirname $2)"
-cmd="cd ~; cmd /c mklink ${args} ${target} ${source}"
-
-if [ "$DEBUG" == true ]; then
- [ "$QUIET" != true ] && printf '\nCommand: \n%s\n\n' "powershell.exe -c ${cmd} &>/dev/null"
-else
- if $QUIET; then
- powershell.exe -c "${cmd}" &>/dev/null
- else
- powershell.exe -c "${cmd}"
- fi
-fi