JessiBaughman

Open Directory in Windows Explorer

Aug 15th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.99 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. #
  3. # This will open the Windows File Explorer to the specified directory.
  4. #      - Default directory is present working directory, else $1
  5. #      - If $1 is a filename, then Windows will attempt to open that file.
  6. #
  7. # G+ Post: https://plus.google.com/+JessiBaughman/posts/Q7qTDAEHgAP
  8. # Created by: Jessi A. Baughman
  9. # Last Modified: 2018-04-04
  10.  
  11. # For 'Bash on Ubuntu on Windows' version
  12. # Must manually expand %localappdata%\lxss
  13. # Uncomment and replace USERNAME with your Windows account name
  14. #root='C:\Users\USERNAME\AppData\Local\lxss'
  15.  
  16. #For Windows Store WSL Version use (may need to change the 'CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc' directory name):
  17. #root='C:\Users\USERNAME\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs'
  18.  
  19. if [ $# -gt 0 ]; then
  20.         path=$(readlink -f $1)
  21. else
  22.         path=$(readlink -f .)
  23. fi
  24.  
  25. # Convert / to \
  26. path=$(echo $path | sed 's/\//\\/g')
  27.  
  28. explorer.exe $root$path &>/dev/null
Add Comment
Please, Sign In to add comment