Skip to content

Commit b4195a0

Browse files
geksiongguenhter
authored andcommitted
Fix 'can't manipulate jobs in subshell' error in zsh
1 parent 63e75f8 commit b4195a0

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

gitprompt.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ function async_run() {
99
}&
1010
}
1111

12-
function set_git_prompt_dir() {
12+
function async_run_zsh() {
13+
{
14+
eval "$@" &> /dev/null
15+
}&!
16+
}
17+
18+
19+
function git_prompt_dir() {
20+
# assume the gitstatus.sh is in the same directory as this script
1321
# code thanks to http://stackoverflow.com/questions/59895
1422
if [ -z "$__GIT_PROMPT_DIR" ]; then
1523
__GIT_PROMPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
@@ -441,8 +449,12 @@ function checkUpstream() {
441449
then
442450
if [[ -n $(git remote show) ]]; then
443451
(
444-
async_run "GIT_TERMINAL_PROMPT=0 git fetch --quiet"
445-
disown -h
452+
if [ -n $ZSH_VERSION ]; then
453+
async_run_zsh "GIT_TERMINAL_PROMPT=0 git fetch --quiet"
454+
else
455+
async_run "GIT_TERMINAL_PROMPT=0 git fetch --quiet"
456+
disown -h
457+
fi
446458
)
447459
fi
448460
fi

0 commit comments

Comments
 (0)