Is there a way to edit the fg command so that it behaves like the one bash uses?

Instead of having:

fg %<job number>

in zsh, can I have:

fg <job number>

as in bash?


You could write your own function, fg, to check the arg and then run the builting fg:

fg(){ if [[ "$*" =~ ^[0-9]+$ ]]; then builtin fg %"$*";else builtin fg "$@";fi }
  • Is there a way to get rid of the statement that pops up after you use "fg 1"? For example, when using just "fg 2", I get: [2] + 15169 continued emacs .zshrc in the terminal, followed by a suspended line after I Ctrl-z out of the window. That doesn't happen with the default "fg %2" – CodeSammich Oct 26 '15 at 3:03
  • Oh, excuse me, it does happen with both %2 and 2. Is there a way to remove that line? – CodeSammich Oct 26 '15 at 3:05
  • Sorry, I don't know how to suppress the message. – meuh Oct 26 '15 at 8:10

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.