Open the terminal in the current window of ubuntu

Source: Internet
Author: User

Open the directory in the Ubuntu Nautilus window (corresponding to the Windows Resource Manager). Sometimes you want to open the terminal in the current window for operations, if you select the menu-> application-> attachment-> terminal and then CD it to the directory, it is very troublesome for a lazy like me. So I thought, is there a way to start the terminal directly in the current window through the shortcut key?

Search for it first. A script is found:

1 #! /Bin/bash
2 # This script opens a gnome-terminal in the directory you select.
3 # Distributed under the terms of gnu gpl version 2 or later
4 # Install in ~ /. Gnome2/nautilus-scripts or ~ /Nautilus/scripts
5 # You need to be running Nautilus 1.0.3 + to use scripts.
6 # When a directory is selected, go there. Otherwise go to current
7 # directory. If more than one directory is selected, show error.
8
9 if [-n "$ NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"]; then
10 set $ nautilus_script_selected_file_paths
11 if [$ #-EQ 1]; then
12 Destination = "$1"
13
14 # Go To File's directory if it's a file
15 if [! -D "$ destination"]; then
16 Destination = "'dirname" $ destination "'"
17 fi
18 else
19 zenity -- error -- Title = "error-open terminal here "\
20 -- text = "You can only select one directory ."
21 Exit 1
22 fi
23 else
24 Destination = "'echo" $ nautilus_script_current_uri "| SED's/^ file :\/\///''"
25 fi
26
27 # It's only possible to go to local directories
28 if [-n "'echo" $ destination "| grep '^ [a-zA-Z0-9] \ +:'' "]; then
29 zenity -- error -- Title = "error-open terminal here "\
30 -- text = "only local directories can be used ."
31 Exit 1
32 fi
33
34 cd "$ destination"
35 exec X-terminal-emulator

 

Copy the script to./gnome2/Nautilus-scripts in the main directory, and set any name (for example, "open terminal"). chmod 777.

Test:

In any window, right-click "script" and "open terminal" (that is, the script name ).

It turns on a terminal and automatically switches to the current directory. This is exactly what I want!

(This script is based on nautilus. It is estimated that not only ubuntu, but all systems using nautilus should be able to run this script .)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.