Last active
July 24, 2019 17:25
-
-
Save traveaston/f881ce63c86493c8b733df06a750d95d to your computer and use it in GitHub Desktop.
Function for mounting windows network shares on Windows Subsystem for Linux (WSL)
This file contains hidden or 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
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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