Created
January 3, 2014 19:31
-
-
Save jameswebb68/8244825 to your computer and use it in GitHub Desktop.
function to open explorer window for current working directory, provided absolute path, provided relative path, from within a cygwin
ex: open (opens current working directory in an explorer window), open /home (opens home directory), open ../home
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
# open explorer directory relative, absolute or empty for current path | |
open() { | |
local var="$1" | |
[[ -z "$var" ]] && cygstart -x "$(cygpath -wa "$PWD")" | |
if [[ "${var:0:1}" == "/" ]]; then | |
[[ -d "$var" ]] || { echo "bad path"; return 1; } | |
cygstart -x "$(cygpath -wa "$var")" | |
elif [[ "${var:0:3}" == "../" ]]; then | |
[[ -d "$(cd "$var" 2>/dev/null && pwd)" ]] || { echo "bad path"; return 1; } | |
cygstart -x "$(cygpath -wa "$(cd "$var"; pwd)")" | |
else | |
[[ -d "${PWD}/${var}" ]] || { echo "bad path"; return 1; } | |
cygstart -x "$(cygpath -wa "${PWD}/${var}")" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment