在ubuntu的当前窗口打开终端

在ubuntu的nautilus窗口(对应的就是windows中的资源管理器)中打开目录,有时候想在当前窗口打开终端进行操作,如果选择菜单-》应用程序-》附件-》终端,然后再cd到该目录下,对于我这样的懒人来说,是一件非常麻烦的事。于是我就想,有没有办法通过快捷键直接在当前窗口启动终端?


动手之前,先搜索一番。找到了一个脚本:

 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

 


将该脚本拷到主目录的./gnome2/nautilus-scripts下,任意起个名字(例如“打开终端”),chmod 777.就ok了。


测试一下:

在任意窗口,右键-》脚本-》“打开终端”(就是脚本的名字)。

果然就打开了一个终端,并且也自动切换到了当前目录。这正是我想要的!

(该脚本是基于nautilus的,估计不仅ubuntu,所有使用nautilus的系统应该都可以运行这个脚本。)


转载于:https://www.cnblogs.com/chutianyao/archive/2011/07/23/2114791.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值