Use xdg-open to open a url with a new process
Strange, it works like that out of the box on my Debian. Try running it in the background:
xdg-open http://www.google.com &
You can make this into a function by adding these lines to your ~/.bashrc
file:
function open () {
xdg-open "$*" &
}
You can then simply run open http://www.google.com
and it will run in the background.
If you want to detach the process from the current shell rather than starting it as a background job with xdg-open http://www.google.com &
, I like the detach
utility:
detach xdg-open http://www.google.com
One could create an alias for this. I like detach
over nohup
as closes stdin stdout and stderr by default so its invocation is cleaner.
xdg-open
waits for the program to finish. This is by design. If the program is a text mode program, it has to stay in the foreground in the terminal. Even if the program is a GUI one, this behavior is useful in case xdg-open
is used from a script and the script wants to perform something after the file has been edited (e.g. send the new version somewhere or otherwise make something with the new version).
If you don't want to wait, run xdg-open
in the background. You can run any shell command in the background by putting an ampersand at the end.
xdg-open http://www.google.com &
With some programs, xdg-open
returns immediately. What happens is actually that the program that xdg-open
invokes returns immediately. This typically happens with GUI programs that open all files in a single instance: when you start them a second time, they send a message the running instance to tell it to open the file, and exit immediately.