Linux open new window

How can I open a new terminal window from a terminal in linux?

That’s system specific. On KDE, just type konsole . On Gnome, it’s gnome-terminal . What should work on every X system is xterm .

Edit: Removed the bit about $TERM , as it is an «identifier for the text window’s capabilities» and not necessarily the name of an executable binary.

In Linux Mint 18.1 Cinnamon I have TERM=»xterm-256color» that does not correspond to a binary command to open a terminal 🙁

Edited my answer, the thing I wrote about $TERM was based on a wrong assumption. I guess gnome-terminal should work on Mint.

Ctrl + Shift + N -> new terminal

+1 because it’s a keyboard shortcut. which doesn’t address the question asked (as I understand it), but sure helps me! 🙂

The command that I set to run on startup is «x-terminal-emulator» and that opens the terminal we all know and love.

I recommend using an external program such as pcmanfm to launch a new terminal. This way, your root permissions and login state remain in the new terminal.

    If you don’t have it already, include the first line, otherwise skip this step (or don’t, it won’t reinstall):

No problem, you may want to have a glance at the formatting help page — it’s a bit different to what you might be used to but you should get up to speed pretty quick 🙂

Press ALT + F2 , then type-in gnome-terminal or xterm and Enter.

If you just have command line access (via ssh, for example), you should research screen.

I am using xfce4 as my desktop environment (DE) on Arch Linux, so for me it was xfce4-terminal .
Ctrl + Alt + T should mostly works. But you might have a different desktop environment (DE). The command depends on your DE, not on your Linux distro.

For Kde -> konsole
For GNOME -> gnome-terminal
For xfce4 -> xfce4-terminal
For Cinnamon -> x-terminal-emulator
For MATE -> mate-terminal —window
For Unity -> gnome-terminal —profile=Default
For Pantheon -> pantheon-terminal -w »
for Pantheon DE look at this also

Источник

Command to open new terminal window from the current terminal?

I installed xdotool by running sudo apt-get install xdotool and throw xdotool key ctrl+alt+t command to open a new terminal window from the current one.But it was not working. What was the command to open a new terminal window from the current gnome-terminal?

3 Answers 3

Just this command will do:

Normally if you want a command to open from the terminal and separate (so it returns to the prompt without having to close the opened program), you have to use something like this:

Читайте также:  Linux return code bash

However the parent terminal seems to detect that the same command is being used so you don’t need to do that and gnome-terminal will suffice. This also seems to happen when running xfce4-terminal from Xfce’s terminal, konsole from KDE’s as well (doesn’t seem to work when running xterm from xterm (see also xterm xterm ) — Running konsole from Gnome/Unity & Xfce’s terminal works as well, but for Xfce’s terminal in gnome terminal you need xfce4-terminal & disown ).

 gnome-terminal [-e, --command=STRING] [-x, --execute ] [--window-with-profile=PROFILENAME] [--tab-with-profile=PRO‐ FILENAME] [--window-with-profile-internal-id=PROFILEID] [--tab-with-profile-internal-id=PROFILEID] [--role=ROLE] [--show-menubar] [--hide-menubar] [--geometry=GEOMETRY] [--disable-factory] [-t, --title=TITLE] [--working-direc‐ tory=DIRNAME] [--usage] [-?, --help] 

You probably want to run it in the background, like that: gnome-terminal & . Otherwise the current terminal will be unusable, as it will be busy running that other one — so you end up with just one usable terminal, which may be missing the point.

Interesting. You are apparently right, however, I am not wrong neither 🙂 I’ve just checked that in details. If I run gnome-terminal while another instance of it is already running (it may be the one I’m using to launch this command) — it indeed finishes immediately, because instead of running a new instance gnome-terminal , it tells that currently running one to open a new window. Tricky. But if I run gnome-terminal from anything else, and there are no other instances of gnome-terminal running, it does as I explained in the previous comment, blocking the terminal used to launch it.

@RafałCieślak — anyway, konsole doesn’t seem to need at all. weird. I have no idea why this question/answer is so popular 🙂

Thanks very much, if you want to open a terminal with the same directory you could do this, gnome-terminal .

Command to open new terminal window from the current terminal,

sudo apt-get install xdotool 

I don’t see any reason to use xdotool key ctrl+shift+n while using gnome-terminal you have many other options; see man gnome-terminal in this sense.

Still think this neat 🙂 is there any equivalent for Mir or Wayland (for implementations not compatible with X server stuff)

The following script will open a new tab in the current gnome-terminal window and optionally give that tab a title. This works from any window, you don’t have to be in a gnome-terminal window to run it. And, if there is no gnome-terminal running, it will start one. The only caveat is that if you changed the hotkey for opening a new tab you might have to change the line xdotool key ctrl+T to use your hotkey instead.

#!/bin/bash DELAY=1 # get title we are going to set tab too, default to Terminal title="Terminal" if [ $# -eq 1 ]; then title="$1" fi # get pid of running terminal server TPID=$(ps -C gnome-terminal-server -o pid | tail -1 | sed -e's/\s//g') if [ $ == "PID" ]; then # no terminal process running yet, so just start one gnome-terminal -t "$title" --tab exit 0 fi # there is a terminal, get window id of the running terminal server WID=$(wmctrl -lp | awk -v pid=$TPID '$3==pid') # get title of currently active tab TTITLE=`xwininfo -id 0x5000006 | grep xwininfo | awk ''` if [ "$TTITLE" == "\"Terminal\"" ]; then # so we don't go into an infinite loop later TTITLE="we had a terminal named terminal $$" fi # get focus on active terminal tab xdotool windowfocus $WID # use keyboard shortcut to open new tab xdotool key ctrl+T # see if we have created tab and are in terminal NTITLE=`xwininfo -id 0x5000006 | grep xwininfo | awk ''` waited=0 while [ "$TTITLE" == "$NTITLE" ]; do # sleep for 1 second before we try again xdotool sleep 1 NTITLE=`xwininfo -id 0x5000006 | grep xwininfo | awk ''` if [ $waited == 0 ]; then echo "Waiting " waited=1 fi echo -n "." done if [ $waited == 1 ]; then echo "" fi # active tab is the new one we created, wait DELAY seconds just to be sure we can type into it to set tab name xdotool sleep $DELAY xdotool type --clearmodifiers "termtitle $title" xdotool key Return # make tab the active window and raise it to top wmctrl -i -a $WID exit 0 

Источник

Читайте также:  Как ускорить работы linux

Keyboard shortcut/command for opening a new nautilus window and raise it

What is the shortcut for opening a new window (opening folders). for that I have to go to folder options and right click and then need to click on open new window. or I have to make focus on the folder icon or open a folder then press Ctrl + N for opening a new window is there any direct command spcific to open a new window in ubuntu.

3 Answers 3

keyboard shortcut screenshot

By default, the keyboard shortcut to launch the file browser is the special key Explorer , available on some keyboards (along with other special keys to laucnh music players, internet browsers and so on). You can change this to something else in the Shortcuts section of Keyboard settings: Change the Home folder shortcut to something else.

If I understand the question correctly, what @Sparhawk is looking to do is the equivalent of Right-click>Files>Open a New Window — particularly where a window may already be open. What (if any) is the shortcut for that (or a suitable Custom Shortcut)?

@NoviceUserFrance That would require focusing the window in question, if you want a copy of a window opened to particular folder, I think (or add a custom shortcut with command /usr/bin/nautilus /path/to/folder/ . I don’t really understand — right click what? The icon in the launcher? If so, that opens a new window with the home folder, I think, which is what this keyboard shortcut does.

I think that’s what the OP wants, the ability to open a new ‘file window’ when the focus is already on another ‘file window’ and yes, right click the Files icon in the launcher then select Open a New Window. If I have a ‘file window’ open, using my shortcut only refocuses on the already open window and doesn’t open a new window.

Читайте также:  Динамический контроль целостности astra linux

@NoviceUserFrance in which case the OP has already given the solution: Ctrl-N . It looks to me that OP only wants to open a new window, irrespective of the path. The keyboard shortcut mentioned in the answer always opens a new window to the home folder.

Quite right, thanks for that. I hadn’y appreciated that Ctrl-N works where the focus is already on an open window. Your answer then seems to fit the requirement admirably and works well for me.

To open a general window (12.04 / 14.04+)

I assume you would like to have a key combination to open a new Nautilus window (and raise it), no matter what application is in front.

You can do that, using a small script and adding a key combination to your shortcuts to run it.

    If not installed, install wmctrl :

sudo apt-get install wmctrl 
#!/usr/bin/env python import subprocess import socket def read_windowlist(): get_pid = subprocess.Popen(["wmctrl", "-l", "-p"], stdout=subprocess.PIPE) wlist = [(item[14:21].split(" ")[0], item.split(socket.gethostname()+" ")[-1]) for item in get_pid.communicate()[0].decode("utf-8").split("\n")] return wlist def read_pid(): get_pid = subprocess.Popen(["pidof", "nautilus"], stdout=subprocess.PIPE) return get_pid.communicate()[0].decode("utf-8").replace("\n", "") def find_window(): nautilus_window = [item for item in read_windowlist() if item[0] == read_pid()][-1] subprocess.Popen(["wmctrl", "-a", nautilus_window[1]]) subprocess.Popen(["nautilus"]) find_window() 
#!/usr/bin/env python3 import subprocess import socket def read_windowlist(): get_pid = subprocess.check_output(["wmctrl", "-lp"]).decode("utf-8").split("\n") return [(item[14:21].split(" ")[0], item.split(socket.gethostname()+" ")[-1]) for item in get_pid] def read_pid(): get_pid = subprocess.Popen(["pidof", "nautilus"], stdout=subprocess.PIPE) return get_pid.communicate()[0].decode("utf-8").replace("\n", "") def find_window(): nautilus_window = [item for item in read_windowlist() if item[0] == read_pid()][-1] subprocess.Popen(["wmctrl", "-a", nautilus_window[1]]) subprocess.Popen(["nautilus", "--new-window"]) find_window() 

Now add a command and a key combination of your preference to run the script (System Preferences > Keyboard > Shortcuts > Custom Shortcuts)

/path/to/script/new_window (don't forget to make the script executable) 

Open a new window in a specific directory (14.04+)

To open a specific directory in nautilus on top of everything, call the small script below to open the directory (under your key combination) with the directory as an argument, so that instead of using the command:

to open the directory, you can use the command:

How to use
This script also uses wmctrl . To install it:

sudo apt-get install wmctrl 
#!/usr/bin/env python3 import subprocess import sys window = sys.argv[1] subprocess.call(["nautilus", window]) wname = '"'+window.split("/")[-1]+'"' subprocess.Popen(["wmctrl", "-a", wname]) 

Copy it into an empty file, save it as raise_nautilus.py and run it by the command:

python3 /path/to/raise_nautilus.py 

*Note: if your directory contains spaces, use quotes around it.

Источник

Оцените статью
Adblock
detector