I'm fairly new at using the Terminal and Im trying to figure out how to open a program (say Safari) and insert text into the search box. I already know how to open safari using the terminal. I just want to know if there is a way to insert text into the address bar. any help?
It depends on your browser or the graphical application you are running. If the browser give you the option, you can.
firefox supports this. Lets say you have just opened
firefox from terminal, now you can use the following commands to open a new URL just like typing in the address bar:
firefox --new-tab gmail.com
gmail.com in a new tab.
firefox --new-window gmail.com
gmail.com in a new firefox window.
Check the manpage of your program (
man program) to check if it supports this feature.
If you want to quickly google something in the command line:
search="Hello php runner" googlesearch=$(echo $search | sed 's/ /+/g') firefox --new-window https://www.google.com/#q=$googlesearch
The second line converts blank spaces with pluses, since that is how Google deals with spaces