mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-12 08:50:08 +00:00
Fix WSL check for WSL 2 and simplify nohup in open_command
WSL 2 changes the output of `uname -r`. For instance, WSL 1: 4.4.0-18980-Microsoft WSL 2: 4.19.67-microsoft-standard Since WSL 2 lowercases the M, we can match for the rest of the string which remains lowercase throughout both versions. Another option would be to match for both upper- and lower-case Ms, like that: $(uname -r) = *[Mm]icrosoft* Fixed use of nohup in open_command where it was only necessary for xdg-open (and actually harmful for cmd.exe in WSL 2). The current logic is simpler and more future-proof.
This commit is contained in:
parent
32338fd40c
commit
095d56b5ea
2 changed files with 3 additions and 8 deletions
|
@ -21,7 +21,7 @@ function open_command() {
|
||||||
case "$OSTYPE" in
|
case "$OSTYPE" in
|
||||||
darwin*) open_cmd='open' ;;
|
darwin*) open_cmd='open' ;;
|
||||||
cygwin*) open_cmd='cygstart' ;;
|
cygwin*) open_cmd='cygstart' ;;
|
||||||
linux*) ! [[ $(uname -a) =~ "Microsoft" ]] && open_cmd='xdg-open' || {
|
linux*) [[ "$(uname -r)" != *icrosoft* ]] && open_cmd='nohup xdg-open' || {
|
||||||
open_cmd='cmd.exe /c start ""'
|
open_cmd='cmd.exe /c start ""'
|
||||||
[[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 }
|
[[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 }
|
||||||
} ;;
|
} ;;
|
||||||
|
@ -31,12 +31,7 @@ function open_command() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# don't use nohup on OSX
|
${=open_cmd} "$@" &>/dev/null
|
||||||
if [[ "$OSTYPE" == darwin* ]]; then
|
|
||||||
${=open_cmd} "$@" &>/dev/null
|
|
||||||
else
|
|
||||||
nohup ${=open_cmd} "$@" &>/dev/null
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -15,7 +15,7 @@ alias stn=create_project
|
||||||
declare -a _sublime_paths
|
declare -a _sublime_paths
|
||||||
|
|
||||||
if [[ "$OSTYPE" == linux* ]]; then
|
if [[ "$OSTYPE" == linux* ]]; then
|
||||||
if [[ "$(uname -r)" = *Microsoft* ]]; then
|
if [[ "$(uname -r)" = *icrosoft* ]]; then
|
||||||
_sublime_paths=(
|
_sublime_paths=(
|
||||||
"$(wslpath -u 'C:\Program Files\Sublime Text 3\subl.exe')"
|
"$(wslpath -u 'C:\Program Files\Sublime Text 3\subl.exe')"
|
||||||
"$(wslpath -u 'C:\Program Files\Sublime Text 2\subl.exe')"
|
"$(wslpath -u 'C:\Program Files\Sublime Text 2\subl.exe')"
|
||||||
|
|
Loading…
Reference in a new issue