From b4a5fa961579b73a43a95a0e0fe0f1c96c8e9917 Mon Sep 17 00:00:00 2001 From: Tarik02 Date: Mon, 15 Jul 2019 18:12:14 +0300 Subject: [PATCH] Use explorer.exe as file manager if available --- bin/autojump.bash | 32 ++++++++++++++++++-------------- bin/autojump.fish | 22 +++++++++++++--------- bin/autojump.zsh | 32 ++++++++++++++++++-------------- 3 files changed, 49 insertions(+), 37 deletions(-) diff --git a/bin/autojump.bash b/bin/autojump.bash index 379e529..60362eb 100644 --- a/bin/autojump.bash +++ b/bin/autojump.bash @@ -96,20 +96,24 @@ jo() { output="$(autojump ${@})" if [[ -d "${output}" ]]; then - case ${OSTYPE} in - linux*) - xdg-open "${output}" - ;; - darwin*) - open "${output}" - ;; - cygwin) - cygstart "" $(cygpath -w -a ${output}) - ;; - *) - echo "Unknown operating system: ${OSTYPE}." 1>&2 - ;; - esac + if command -v explorer.exe >/dev/null 2>&1; then + explorer.exe "${output}" + else + case ${OSTYPE} in + linux*) + xdg-open "${output}" + ;; + darwin*) + open "${output}" + ;; + cygwin) + cygstart "" $(cygpath -w -a ${output}) + ;; + *) + echo "Unknown operating system: ${OSTYPE}." 1>&2 + ;; + esac + fi else echo "autojump: directory '${@}' not found" echo "\n${output}\n" diff --git a/bin/autojump.fish b/bin/autojump.fish index e995506..65a8b04 100644 --- a/bin/autojump.fish +++ b/bin/autojump.fish @@ -83,15 +83,19 @@ end function jo set -l output (autojump $argv) if test -d "$output" - switch $OSTYPE - case 'linux*' - xdg-open (autojump $argv) - case 'darwin*' - open (autojump $argv) - case cygwin - cygstart "" (cygpath -w -a (pwd)) - case '*' - __aj_err "Unknown operating system: \"$OSTYPE\"" + if command --search explorer.exe >/dev/null 2>&1 do + explorer.exe (autojump $argv) + else + switch $OSTYPE + case 'linux*' + xdg-open (autojump $argv) + case 'darwin*' + open (autojump $argv) + case cygwin + cygstart "" (cygpath -w -a (pwd)) + case '*' + __aj_err "Unknown operating system: \"$OSTYPE\"" + end end else __aj_err "autojump: directory '"$argv"' not found" diff --git a/bin/autojump.zsh b/bin/autojump.zsh index a761206..706515b 100644 --- a/bin/autojump.zsh +++ b/bin/autojump.zsh @@ -91,20 +91,24 @@ jo() { setopt localoptions noautonamedirs local output="$(autojump ${@})" if [[ -d "${output}" ]]; then - case ${OSTYPE} in - linux*) - xdg-open "${output}" - ;; - darwin*) - open "${output}" - ;; - cygwin) - cygstart "" $(cygpath -w -a ${output}) - ;; - *) - echo "Unknown operating system: ${OSTYPE}" 1>&2 - ;; - esac + if command -v explorer.exe >/dev/null 2>&1; then + explorer.exe "${output}" + else + case ${OSTYPE} in + linux*) + xdg-open "${output}" + ;; + darwin*) + open "${output}" + ;; + cygwin) + cygstart "" $(cygpath -w -a ${output}) + ;; + *) + echo "Unknown operating system: ${OSTYPE}" 1>&2 + ;; + esac + fi else echo "autojump: directory '${@}' not found" echo "\n${output}\n"