Last active
November 23, 2023 07:26
-
-
Save feklee/588974dffcf6cc72df9f6f79a9fe3c65 to your computer and use it in GitHub Desktop.
Creates link to DIR on Windows desktop. Only works for certain directories inside my Linux virtual machine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Depends on: | |
# | |
# * Mikaël Le Bohec's [mslink][1], and | |
# | |
# * my [winpath][2]. | |
# | |
# [1]: http://www.mamachine.org/mslink/index.en.html | |
# [2]: https://gist.github.com/feklee/678c630aa7f84ceda1c766333b37e7d3 | |
# Felix E. Klee <[email protected]> | |
MSLINK=mslink_v1.3.sh | |
DESKTOP_DIR="/home/felix/windows/Desktop" | |
# Usage info | |
show_help() { | |
cat << EOF | |
Usage: ${0##*/} DIR | |
Creates link to DIR on Windows desktop. Only works for certain | |
directories. | |
EOF | |
} | |
if [ "$#" -ne 1 ]; then | |
show_help >&2 | |
exit 1 | |
fi | |
DIR="$1" | |
if [ ! -d "$DIR" ]; then | |
echo "Only links to directories are supported" >&2 | |
exit 1 | |
fi | |
WINPATH="$(winpath "$DIR")" || exit 1 | |
FULLPATH="$(realpath "$DIR")" | |
LINKNAME="$(basename "$FULLPATH").lnk" | |
LINKPATH="$DESKTOP_DIR/$LINKNAME" | |
"$MSLINK" -l "$WINPATH\\\\" -o "$LINKPATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment