And if you want to get really hairy and avoid applications that aren't installed by default:
xkill -id `xprop -root _NET_ACTIVE_WINDOW | cut -d\# -f2`
Again, this seems to work fairly well.
NOTE: In the case of some applications (see comments) this may mean that all windows for an application are closed. gnome-terminal
is one such application but terminator
and xterm
are not affected. I would suggest this is more a bug (maybe by design) with those applications rather than one with my command.
To keep Firefox
minimized after closing its current tab (according to OP, see the comment) use the following commands in a terminal,
wmctrl -a firefox; xdotool key Ctrl+w; wmctrl -r firefox -b add,shaded
How it works
wmctrl -a firefox
Go to the window with a name containing 'firefox' in it
xdotool key Ctrl+w
Send the keystroke Ctrl+W to firefox which is the shortcut to close current tab in firefox.
wmctrl -r firefox -b add,shaded
Shade a window with a title that contains the word 'firefox' in it.
To know more about these see man xdotool
and man wmctrl
Alias for above command
You can make an alias for the above commands, say the alias name be cfct
( Close Firefox Current Tab) in ~/.bashrc
or better in ~/.bash_aliases
from a terminal as,
echo -e "\nalias cfct='wmctrl -a firefox; xdotool key Ctrl+w; wmctrl -r firefox -b add,shaded'" >> ~/.bash_aliases
. ~/.bash_aliases
If you don't have ~/.bash_aliases
replace ~/.bash_aliases
in the above commands with ~/.bashrc
Usage
open a terminal and enter
cfct
And it will close Firefox’s current tab instantaneously.
Note: You need to have wmctrl
and xdotool
installed in your system. To install them use,
sudo apt-get install wmctrl xdotool
Best Answer
Now every file is handled by another program say
gedit
and folders the same, so to kill [ the program handling that file or folder ] we can use two methods:The program name with:
use of program
PID
(process id)PID
withpgrep <name_of_program>
, thenkill <PID>
Information:
Note: When closed this way any unsaved changes will be lost.