I have CTRL key broken in my MBP. Is there any way to terminate process in terminal without it? I mean, can I change CTRL + C shortcut, or use mouse, or whatever? I know, I can use Karabiner to reassign CTRL globally, but this solution doesn't fit to me.
Thanks.
On OS X, you can use command-period. Additionally, you can use stty intr <something> to set a different interrupt character for the terminal.
You can use this:
<Alt><SysRq><k>
Kill all processes (including X) which are running on the currently active virtual console. This key combination is know as "secure access key" (SAK).
Yes, you can open another terminal and with the command ps aux you can find the process ID (column named PID) related to application that you want to kill and kill it with the command kill PID.
Related
I need script which works in the background, waiting for a key to be pressed. I have a script which works when terminal is on. When I try to use & - it's not working correctly. The script works in background but keypress doesn't do anything. When I try use nohup then I have error of read - bad descriptor.
Can someone help me?
When the terminal is on (and is selected, in case of a terminal emulator running on x server), the input (key strokes, etc.) is directed to the terminal; hence, your program works.
Now, consider an example: let's say that you created a script that runs on the background, and it is activated by pressing the letter "a". If pressing "a" triggered your script (with terminal closed), then the user would never be able to (for example) type the letter "a" in a word document or a web search without triggering the script!
Therefore, what you are looking for is a key bind, or a keyboard shortcut, which would bind a key (combination) such as ctl+j+k to launch the script you want.
In Linux, that can be done somewhat easily, see this for Ubuntu or this for Lubuntu.
Important: if your script needs to be root to work, then you generally will have to evoke it via gksu or gksudo, otherwise it will not run
I have variable stand alone shell routines which I execute one after another automatically. Since every routine produces several X-windows figures I want to close all of them at the end without modifying every single routine. Is there a certain command?
Cheers!
Based on answers to this question. xdotool looks like what you need.
To kill an X11 window given it's title, you can use:
xdotool search "Your window title here" windowkill
Windows are owned by processes. One way to close windows is to kill their owner processes.
Another way is to start another X server, run your scripts with DISPLAY environment variable referring to the display of that X server, then terminate that X server with all windows.
I've created a .screenrc config file to setup some split screen stuff for what im working on, and i've bound ctrl+d to quit it, but it only quits the screen, and leaves the actual processes running.
Heres the bind keys part of my .screenrc file atm, is there a way i can tweek it so it kills processes too?
bindkey ^D quit
It needs to quit and kill multiple split screens btw so that may add to the complexity of it.
Ultimately i'd like to bind it to Ctrl+C or Ctrl+D, either way a quick way to exit this script as its a custom script loading this custom .screenrc file.
Thanks.
Unsure if you are aware of the screen ctrl a functions
ctrl a c to create a new screen
ctrl a a or [0-9] to run through connections
ctrl a d to detach
where you can then use
screen -r -d to re-attach
and I think you need
ctrl a \
this will attempt to quit the screen session and prompt if you wish to cancel it all
I would like to create a keyboard shortcut to run an R function in an existing R session. How can I do this on a Mac?
My first idea was to use
% R --slave < foo.R
and create a keyboard-shortcut to a shell script with this command.
But this starts a new R session. Is there a way to send a command to an existing session from shell?
I can think of two similar ways to do this; neither is necessarily elegant, but both get the job done.
Run a tmux session which consists solely of an R session, and write a script that uses tmux send-keys to send your command.
Similarly, you could set up a dedicated iTerm2 session to receive the keys. If you were in iTerm2 already, you could set up a keyboard shortcut to send your command. Outside iTerm2, I think you're looking at some applescript.
In other terminals I would press Ctrl+z to suspend an application, often to then issue bg to send it into background.
In console2 Ctrl+z does nothing, probably because the key combination has a different meaning in Windows. But is there a way to achieve the same effect, save for 'process &'?
(I know I should use & and it works, but sometimes I would setup shell, start an editor, begin editing, then return to the console just to find that I forgot the & and I can't use the shell. It annoys me that I then have to either open a new shell and set it up again, or quit the editor, start it with & and set it up again).
In Console2, ctrl-c is bound by default to copy (text) you have to press ctrl-shift-c to cancel job.
You could also try to remove the hotkey that is conflicting with ctrl+z.
I was having trouble using ctrl+c to cancel the execution of a script. As soon as I removed that hotkey, ctrl+c had its default restored and I was able to cancel executions properly.
This annoying issue surely is a console2 bug. You may find something about at its issue tracker.
Anyway, what ctrl+z does is send a SIGSTOP signal to current process. So, you can still send that signal from another session/tab. (If it is less annoying than stop and start with &).
To do that, you can use the kill command.
kill -s SIGSTOP pid
(pid is the process PID number)
Hope it helps.