2015-09-16 62 views
7

Ricevo un comportamento strano con i comandi jobs, fg e bg nella mia shell zsh. Ecco un esempio (questo accade per tutti i comandi, non solo python):Comportamento strano dei "lavori" all'interno di zsh

$ python & 
[1] 21214 
Python 2.7.8 (default, Oct 19 2014, 16:02:00) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
[1] + 21214 suspended (tty output) python 
$ jobs 
[1] + suspended (tty output) python 
$ fg 1 
fg: job not found: 1 
$ bg 1 
bg: job not found: 1 

Sto usando lo standard oh-my-zsh installazione su OS X.

risposta

19

Si può essere utilizzato per fg N (dove N è un numero di lavoro) che funziona in Bash. Ma è un po 'diverso in Zsh, che richiede un %; ad es., fg %1. Il comportamento Bash è conveniente, in modo da poter fare Zsh fare lo stesso:

fg() { 
    if [[ $# -eq 1 && $1 = - ]]; then 
     builtin fg %- 
    else 
     builtin fg %"[email protected]" 
    fi 
} 

Lo stesso può essere fatto per bg e history. Originariamente era this thread.

+2

Oppure impara il * reale * breve modo: digita semplicemente '% 1'. Viene assunto' fg'. –

+0

Pensavo che zsh fosse un severo superset di bash. Come mai questo comportamento non è lo stesso? –

+0

Zsh non è un superset rigido di Bash: http://zsh.sourceforge.net/FAQ/zshfaq02.html –