Skip to content

Instantly share code, notes, and snippets.

@jakkaj
Created May 15, 2018 01:22
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 jakkaj/4b032b6e2d574922248f21ee3572b0b5 to your computer and use it in GitHub Desktop.
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
alias wcd='. ~/wcd.sh'
#!/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