#!/bin/sh # # explorer-here - start an explorer.exe in . or the given directory # # $Id$ Die() { echo Fatal error: $@ >&2; exit 1; } IsCommand() { type "$1" >/dev/null } if IsCommand wslpath then # we're on WSL Doit() { exec explorer.exe `wslpath -w "$1"` } elif IsCommand cygpath then # we're on Cygwin IsCommand run.exe || Die cannot find run.exe, are you on Cygwin\? SYSTEMDRIVE=${SYSTEMDRIVE:-'C:'} WINDIR=${WINDIR:-${SYSTEMDRIVE}'\windows'} [ -d "$WINDIR" ] || Die cannot find WINDOWS directory $WINDIR explorer="$WINDIR\\explorer.exe" [ -x "$explorer" ] || Die cannot find EXPLORER executable $explorer Doit() { run -p "$1" $explorer `cygpath -w "$1"` } else Die unsupported platform, expecting WSL or Cygwin fi [ $# -eq 0 ] && set . for d in "$@" do [ -d "$d" ] || d=`dirname "$d"` Doit "$d" done