Created
May 15, 2018 01:22
-
-
Save jakkaj/4b032b6e2d574922248f21ee3572b0b5 to your computer and use it in GitHub Desktop.
Windows CD for WSL - changes to /mnt/x based paths from windows paths
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
alias wcd='. ~/wcd.sh' |
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
#!/bin/bash | |
if [ "$#" -ne 1 ]; then | |
echo "Please pass just one argument surrounded by quotes" | |
else | |
replaced="${1//\\//}" | |
replaced="${replaced//:/}" | |
lowered="$(echo $replaced | sed 's/^[A-Z]*./\L&/')" | |
dir="/mnt/$lowered" | |
if [ ! -d "$dir" ]; then | |
echo "Dir does not exist - make sure you surround paramter in \"quotes\" - $dir" | |
else | |
cd "$dir" | |
fi | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment