[转]给ubuntu添加"打开终端"的右键菜单

这里介绍如何为Gnome的右键菜单中添加“gnome-terminal“菜单项,其实现步骤如下:

在~/.gnome2/nautilus-scripts目录下添加名为“gnome-ternimal”的脚本文件,其内容为
bash代码
   #!/bin/bash  
       
    if [ -n "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]; then  
        set $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS  
       if [ $# -eq 1 ]; then  
           destination="$1"  
            # Go to file's directory if it's a file  
           if [ ! -d "$destination" ]; then  
                destination="`dirname "$destination"`"  
           fi  
       else  
           zenity --error --title="Error - Open terminal here" \  
              --text="You can only select one directory."  
           exit 1  
       fi  
   else  
       destination= \  
          "`echo "$NAUTILUS_SCRIPT_CURRENT_URI" | sed 's/^file:\/\///'`"  
   fi  
      
   # It's only possible to go to local directories  
   if [ -n "`echo "$destination" | grep '^[a-zA-Z0-9]\+:'`" ]; then  
       zenity --error --title="Error - Open terminal here" \  
       --text="Only local directories can be used."  
       exit 1  
   fi  
      
   cd "$destination"  
   exec x-terminal-emulator  

保存后,用chmod命令为这个bash脚本添加可执行属性。

你可能感兴趣的:(ubuntu,脚本,bash,Go)