# see if gnome-terminal is running at all (raising error if not) Return subprocess.check_output(cmd).decode("utf-8").strip() Since the script takes the targeted command as an argument, you can put multiple commands under multiple shortcuts. If not, the script does nothing, So it won't paste into other applications. if so, it pastes the command in the active gnome-terminal window, presses Return.looks if the active window is a gnome-terminal window (by its pid).This would however type the command blindly, in any application, and typing the command is not the cleanest option. Of course you could place a simple one-liner under a shortcut key (assuming you have xdotool installed): xdotool type "" Running a command in the currently active gnome-terminal window This way, you can run any (complex) command in the terminal, without having it closed immediately: $ gnome-terminal -e 'bash -c "wmctrl -d read line"'Īfter pressing Enter the terminal will close. Is then to keep the terminal open (until you hit Enter) after the command runs. However, although the command will run successfully, the terminal window will close immediately before you can read the output. To have a new gnome-terminal window opened from command line, and run a command in it, you can use: gnome-terminal -e 'bash -c ' Click the "+" and add the command: gnome-terminal -e 'bash -c "git status read line"'Īlthough your suggested shortcut works, you might pick another key combination then Ctrl+ Enter, since it at least clashes with the LibreOffice shortcut to jump to a new page. Add it to a shortcutĬhoose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". It will open a new gnome-terminal window and run the command inside it. Under a shortcut key combination, will do the job. Since you need to keep the terminal open after the command ran, putting: gnome-terminal -e 'bash -c "git status read line"' Automatically open a new terminal window, showing the output of your command Update Ubuntu 21.10: Fortunately, the scripts-accels file works again in Files 40 (Ubuntu 21.1. Update Ubuntu 20.10: Unfortunately, this does not anymore work in Nautilus 3.38 (Ubuntu 20.10). Or, use the keyboard shortcut that you've just configured :) Test it! Open Nautilus, right click, and choose Scripts > Terminal. Commented lines must have a space after the semicolon Make it executable, then close any Nautilus instance: $ chmod +x TerminalĬreate (or edit) the ~/.config/nautilus/scripts-accels file adding these lines: F12 Terminal In short:Ĭreate a script called Terminal (yes, without an extension) inside the folder ~/.local/share/nautilus/scripts with the following content: #!/bin/sh Long explanation/useful resources can be found here and also here. Since version 3.15.4 Nautilus doesn't load the accel file anymore (Source).įortunately, there's a better approach in order to get what you want. Notice that is again removed.įinally, log out for changes to take effect. To (gtk_accel_path "/ExtensionsMenuGroup/TerminalNautilus:OpenFolderLocal" "F12") ( NautilusOpenTerminal::open_terminal is still present in the file, but doesn't seem to have any effect.) So follow the instructions above, except change the line (gtk_accel_path "/ExtensionsMenuGroup/TerminalNautilus:OpenFolderLocal" "") Here, the relevant command in ~/.config/nautilus/accels is TerminalNautilus:OpenFolderLocal. Save the file and restart Nautilus by clicking on the Nautilus icon in your launcher/dash. If the line doesn't exist just copy and paste the one found in this answer at the end of the file. For a list of all possible key codes please consult this answer. If the line exists, add your keyboard shortcut in the second double-quoted segment and uncomment the line by removing : (gtk_accel_path "/DirViewActions/OpenInTerminal" "F12") Try to see if you can find the following line: (gtk_accel_path "/DirViewActions/OpenInTerminal" "") Open ~/.config/nautilus/accels in a text editor of your choice, e.g. If you can't find the can-change-accels key in your dconf configuration you can try the following solution: If you don't see Open in terminal in the File menu and you've just installed nautilus-open-terminal, you might need to first run nautilus -q. Now you can mouseover the action in the file menu, and change the accel by typing your key while the action is highlighted, finally restart your nautilus. Then open nautilus using this command (to disable Unity global menu Temporarily): nautilus -q first sudo apt-get install dconf-tools nautilus-open-terminal, then run dconf-editor and set the org/gnome/desktop/interface/can-change-accels boolean on. Edit: not anymore applicable for Ubuntu 16.10 and newerįinally figured it out.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |