Skip to content

Instantly share code, notes, and snippets.

@traveaston
Last active July 24, 2019 17:25
Show Gist options
  • Save traveaston/f881ce63c86493c8b733df06a750d95d to your computer and use it in GitHub Desktop.
Save traveaston/f881ce63c86493c8b733df06a750d95d to your computer and use it in GitHub Desktop.
Function for mounting windows network shares on Windows Subsystem for Linux (WSL)
# mounts windows drives for each folder in /srv/ using convention /srv/backups = drive B:
function map_drives() {
local share letter
for share in /srv/*; do
letter="${share:5:1}"
letter="${letter^}:"
# avoid unnecessary remounts
if ! mount | grep -i "$letter on $share" &>/dev/null; then
mount -t drvfs "$letter" "$share"
fi
done
}
# after defining the function, call it, then source basherk (https://github.com/traveaston/basherk)
map_drives
. ~/.basherk
@traveaston
Copy link
Author

traveaston commented Jul 24, 2019

Add gist to the end of ~/.bashrc

Requires bash 4.0+ for case manipulation (${letter^})
Feel free to remove the curlies and caret if you somehow have a lower version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment