Weird “jobs” behavior within zsh

You may be used to fg N (where N is a job number) working in Bash. But it’s a little different in Zsh, requiring a %; e.g., fg %1. The Bash behavior is convenient, so you can make Zsh do the same:

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

The same can be done for bg and history. This was originally from this thread.

You can also just type fg and the %1 is implied. Tab-completion is great for this too when you have a few jobs going: fg<tab>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)