News for hackers. Stuff that matters.
Re:Do You Understand Job Control in Bash? by mooism2 on Thursday September 02, 2010 @04:10PM (#1657489)
Why would I want to use job control when I can use screen instead?
Re:Do You Understand Job Control in Bash? by sophacles on Thursday September 02, 2010 @04:31PM (#1657549)
One thing I do a lot, inside of a screen session, is:

  $ cd workingdir
  $ vim conffile
  (edit, then within file press CTRL-Z, which suspends)
  $ start_program
  (notice errors or misbehaviours based on bad config)
  $ fg
  (edit config file some more, open different buffer)
  ** repeat untill things are happy **
This is a minimal use of job control, but it is nice.

Other uses include juggling several programs at once, sometimes screen gets too annoying for simple progress monitoring of several processes at once. (One window per command for say 20 commands, makes it difficult to switch through to find the one vim one, or the sql prompt... 3 on the other hand is fairly easy).

Re:Do You Understand Job Control in Bash? by johkra on Thursday September 02, 2010 @05:21PM (#1657728)
You can also use :!command to execute a command from within vim. This is handy to execute :!make for instance.
Re:Do You Understand Job Control in Bash? by sophacles on Thursday September 02, 2010 @07:20PM (#1658092)
A lot of times yes, but others, the actions i simplify to "run process" are actually several commands based on output, to do things like verify side effects, etc. The scenario I describe is also very nice for developing shell scripts because of this.
Re:Do You Understand Job Control in Bash? by jallmann on Thursday September 02, 2010 @05:29PM (#1657752)
Actually in that case, just :make will suffice.
Re:Do You Understand Job Control in Bash? by nitrogen on Thursday September 02, 2010 @09:57PM (#1658358)
You can also use :sh to get to a shell, then type exit to get back to Vim.
Re:Do You Understand Job Control in Bash? by Altreus on Thursday September 02, 2010 @04:27PM (#1657535)
Why use the command line at all when you can use a GUI?

Understanding how your system works is a different level from choosing the tools in the first place.

Re:Do You Understand Job Control in Bash? by EvanK on Thursday September 02, 2010 @04:53PM (#1657624)
You may not always have your optimal tool set, such as when you're remoting into someone else's environment (common for sysadmins or contractors), or when you're stuck using someone else's computer rather than your own.
Re:Do You Understand Job Control in Bash? by loire280 on Thursday September 02, 2010 @05:16PM (#1657711)
It depends on what you do, I suppose. If your work doesn't have a large command-line component, using the command line might be disruptive.

A large part of my job involves working with remote Linux servers, so I chose to invest time learning Linux command line tools and vim. Now I'm more productive in a terminal than in a GUI environment. I use common tools that are installed by default on Linux/Unix/OSX, so I can sit down anywhere and do my work, or SSH directly into my machine and have my exact work environment securely and without latency.

Re:Do You Understand Job Control in Bash? by jacquesm on Thursday September 02, 2010 @07:40PM (#1658129)
A command line is a poor mans gui.

A gui is a poor mans command line.

Whichever I'm using there are always aspects of the work that you could do better with the other.

Re:Do You Understand Job Control in Bash? by bingaman on Friday September 03, 2010 @12:14AM (#1658615)
Give me an example of something that you could do better with a gui. Just curious.
Re:Do You Understand Job Control in Bash? by johkra on Friday September 03, 2010 @04:00AM (#1658925)
Selecting a number of unrelated items from a list. Example: You have a folder with music files and want to select some to copy onto your portable music player. It's easier to click on the items to select them than typing all the names, even with file name completion.
Re:Do You Understand Job Control in Bash? by jacquesm on Friday September 03, 2010 @05:51AM (#1659046)
- interactively increasing the contrast of an image

- browsing the web (sorry, lynx users)

- play games (not that I'm a gamer)

- desk-top publishing

- routing a PCB

- CAD

and so on...

But then, each of those has moments when you think to yourself 'Man, I wished I could script this' (well, maybe not the games).

Re:Do You Understand Job Control in Bash? by mooism2 on Thursday September 02, 2010 @05:19PM (#1657722)
Sure, but given that I already use screen, what use cases would I find easier using job control instead of plain screen?
Re:Do You Understand Job Control in Bash? by guns on Thursday September 02, 2010 @06:23PM (#1657929)
Simple command line timer:

    remind() {
        [[ $# -ge 2 ]] || { echo >&2 "Usage: $FUNCNAME time msg"; return 1; }
        local sec="$(($1*60))"
        (   trap "echo \"\$sec seconds left\"" QUIT
            while ((--sec > 0)); do sleep 1; done
            say "${@:2}" # OS X only, replace with your favorite notifier
        ) 2>/dev/null &
    }

    $ remind 30 get the laundry
Query time remaining with kill -QUIT %jobspec. Good for systems that don't have at(1).
Re:Do You Understand Job Control in Bash? by moe on Thursday September 02, 2010 @07:04PM (#1658055)
Hm. That looks like quite a typing exercise. What's wrong with:

    ( sleep 1800 ; say "get the laundry" )&
Re:Do You Understand Job Control in Bash? by symkat on Thursday September 02, 2010 @07:08PM (#1658063)
His can be added to your .bashrc/.bash_profile, and then all you have to type is:

  remind [minutes] [message]
Functions can be imported to your shell. =)
Re:Do You Understand Job Control in Bash? by steve19 on Thursday September 02, 2010 @07:43PM (#1658132)
neat trick
Re:Do You Understand Job Control in Bash? by symkat on Thursday September 02, 2010 @06:56PM (#1658028)
Thanks, that's useful!

Favorite notifier:

  echo "${@:2}" | growlnotify -t Reminder -s -m -
Re:Do You Understand Job Control in Bash? by doki_pen on Thursday September 02, 2010 @05:14PM (#1657707)
You may be on a machine that doesn't have screen installed and it may be quicker to use job control then install it. There is something to be said for travelling light.
Re:Do You Understand Job Control in Bash? by technomancy on Thursday September 02, 2010 @09:27PM (#1658299)
Say you're already in a screen session on host A and SSH from inside that session to host B. You want to run multiple commands on host B, but you don't want to start a nested screen session.