Nautilus本身仍然不支持它,但是您可以使用允许多个参数重用的脚本,或者在不运行时打开Nautilus的新实例。
为了使用这个解决方案,您需要安装pachages wmctrl
和xclip
。您可以使用软件中心(单击链接)或通过带有的终端安装wmctrl和xclipsudo apt-get install wmctrl xclip
。
创建一个新文件nautab.sh
并添加以下代码:
#!/bin/bash
# Nautilus opens folders in new tabs
# Dependencies: sudo apt-get install wmctrl xclip
# Pass directories as parameters, i.e. nautab /opt /var/log /usr/local/etc
# Wrong parameters will be shown as invalid directories
if [ "$(wmctrl -xl | grep "nautilus\.Nautilus")" == "" ]; then
# wmctrl reports Nautilus not running
if [[ -d $1 ]]; then
nautilus "$1" &
else
>&2 echo Not a directory: $1
nautilus &
fi
shift
# Nautilus takes some time to become responsive to automation
sleep 2
fi
#Save old clipboard value
oldclip="$(xclip -o -sel clip)"
for folder in "$@"
{
if [ -d "$folder" ]; then
echo -n $folder | xclip -i -sel clip
wmctrl -xF -R nautilus.Nautilus && xdotool key --delay 120 ctrl+t ctrl+l ctrl+v Return
# Use this if you suspect funny clipboard behaviour
#xclip -verbose -o -sel clip
#Leave some time before opening a new tab
sleep 0.5
else
>&2 echo Not a directory: $folder
fi
}
#Restore old clipboard value
echo -n "$oldclip" | xclip -i -sel clip
该代码基于对其他问题的答案:http://askubuntu.com/questions/55656/open-nautilus-as-new-tab-in-existing-window
。
运行nautab [directory]...
,将在其上打开新选项卡。注意会有一些延迟。这是为了等待Nautilus响应。随意玩数字。