Skip to content

Instantly share code, notes, and snippets.

@feklee
Last active November 23, 2023 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feklee/588974dffcf6cc72df9f6f79a9fe3c65 to your computer and use it in GitHub Desktop.
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.
#!/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 <felix.klee@inka.de>
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