Last active
July 30, 2023 07:04
-
-
Save WingTillDie/3116a31c8240122b78601c75263ef694 to your computer and use it in GitHub Desktop.
wslpath -w for new file
This file contains 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
#!/usr/bin/env bash | |
# Useful for specifing new WSL file path to save by vscode | |
function winpath() { | |
file_path=$(wslpath -a "$1") # Absolute path (full path) | |
file_basename=$(basename "${file_path}") | |
file_dirname=$(dirname "${file_path}") | |
if [ "$#" -eq 0 ]; then | |
wslpath -w . | |
elif [ "$#" -eq 1 ]; then | |
# Also works for new files | |
echo $( wslpath -w "${file_dirname}" )"\\"${file_basename} | |
else | |
wslpath -w "$@" | |
fi | |
} | |
winpath "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment