Sending signal to bash shell launched in GVim - bash

How do I send a signal (say, SIGINT), to a shell launched inside GVim, using a keyboard shortcut?
Neither Ctrl+C nor Ctrl+D seem to work.

Ctrl+D seems to work for me, at least for closing a terminal session. Crl+C however does not. If you only want to kill a running process, you can do this workaround (provided Ctrl+Z) works for you.
Press Ctrl+Z to pause the process, then
kill %1
to kill the process in the background.

Inside vim, use command :shto temporarily exit vim and go to shell
If you want to go back to vim then press Ctrl + D. This work for me for years.

Related

Terminal stops working on MacOs after opening gedit

I have MacOs 10.14 and I installed gedit on my Mac via HomeBrew . When I open gedit typing :
gedit nameoffile
Terminal stops responding to commands.
The only thing I can do in order to use Terminal again is to close gedit and terminate the session of Terminal and reopen it.
Is there anything I can do to solve this ?
*** I managed to find a solution for not closing gedit when I terminate the session of Terminal : I have to open gedit with
sudo gedit nameoffile
However also in this way Terminal stops responding to any command ...
When you run a command from terminal, the command takes over. It's possible that after you close the gedit window, the process continues to run for some reason.
You can send a command to the background when starting it by adding & to the end:
gedit nameoffile &
This should instantly bring you back to the prompt when the process starts.
Alternatively, you could pause the process by hitting Ctrl-Z, then do a variety of things with that process like: kill it using kill, unpause the process and send it to the background using bg, bring it back to the foreground using fg, see list of running jobs with jobs and more.
You can read more about how terminal processes work here

shell: reuse backgrounded emacsclient windows, when invoking emacsclient

Is it possible to reuse backgrounded emacsclient windows, when invoking emacsclient?
Here's some background information (I mainly use emacs in terminal mode, not gui frames)
When the computer boots, an emacs daemon is started.
In the OS X terminal when I want to open a file, I do emacsclient /filename -nw
Now when I want to do bash stuff I press C-z to background emacs.
Now emacs appears in the jobs command. The fg command would also
make it re-appear.
But while I'm browsing around in bash, I see another file I want to open.
Now, how can I reuse that minimized emacsclient session with a single command?
Yes, put this in your .bashrc:
ec() {
kill %emacsclient 2> /dev/null
emacsclient -nw --eval '(find-file "'"$PWD/$1"'")'
}
Open files with ec file.txt. It's a bit hacky, but I think it will do what you want it to.
I open the file find-file so it'll stay open after you close the Emacs window (C-x C-c). Then when you open a new file, I kill the old Emacs window and open a new one. The effect is that the old file stays open forever, so it seems like you reused the Emacs window.

octave 3.8.1 can't stop execution in gui command window

I'm running octave 3.8 with the gui in Ubuntu 14.04. I have an infinite loop somewhere in my program and it seems like the terminal doesn't respond to the typical keypresses to stop execution. (eg. Ctrl+C, Ctrl+Z) When I run programs in the terminal, I can just press Ctrl+C, but that doesn't seem to work here. What can I do to halt execution?
To stop a running command or script in octave GUI or prompt:
Ctrl+C
you will see:
less -- (f)orward, (b)ack, (q)uit
To abort (and close the GUI or command line):
Control+C
To just stop printing the output of the command or script (?):
q
Enter
It's a long-running bug that hasn't been fixed since 2012, run with --no-gui if possible.
after going through lots of bugs report and all.
Finally by hitting (ctr + c + Enter) at command window (below the pause statment) execution gets terminated.
hope it works for u too.

Is there a way to revert back to the command line after opening an application through it?

I want to be able to open an application on the command line, but instead of switching to the application, I want to stay on my terminal emulator. Is there a way of accomplishing this? I am using OS X.
Use the -g flag of open, which avoids bringing the app to the foreground.
$ open -g /Applications/TextEdit.app
$
open will start the app, and then return to the command prompt.
After you run the program hit ctrl+z and type bg. You will return to your terminal CLI.
Whenever you want to go back to your program, just type fg.
You can background the job. In the Bash shell, this is done with the &. For example:
some_script_or_application &
Note that some daemons and processes background themselves. For example, on OS X, running open some.pdf will preview the PDF in a GUI while returning the command prompt immediately without needing to do anything special.
See the GNU Bash Manual for more on job control for background jobs.

Implicitly launch detached program (&) from terminal

I feel sure this will end up as a duplicate, but I don't know how to word it so that I can search for it...
I like to do my programming in emacs, which I launch from the terminal. When I use my mac I use aquamacs and the command
aquamacs Program.py
will launch aquamacs in a separate window ready to edit Program.py. When I work on my linux machine however to get the same result I must type
emacs Program.py &
And I'm always forgetting the "&". So 70% of the time I end up closing the emacs window, and relaunching again with the "&". Now I understand why that "&" is there, but is there a way to set up my system so that the command
emacs Program.py
always launches as a detached process? The only time I might not want that behavior is if I was SSHing in over a slow connection, in which case I usually use "-nw" anyway.
You can click on the terminal and press Ctrl-Z to move an already running foreground process to the background.
Alternatively you could add this function to your ~/.bashrc:
emacs() {
command emacs "$#" &
}
For the specific case of emacs, I use a shell script, which is more complicated than this but for your purposes boils down to
#!/bin/csh -f
/bin/emacs $*:q &
Put it in a directory which is earlier in your $path than where the "real" emacs is, and replace /bin/emacs with the real path to emacs on your system.

Resources