AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1014860
Accepted
user37342
user37342
Asked: 2018-03-15 03:45:26 +0800 CST2018-03-15 03:45:26 +0800 CST 2018-03-15 03:45:26 +0800 CST

Nautilus 的更多书签

  • 772

不幸的是,Nautilus 中的书签窗格没有提供子文件夹,在我的系统上,同时只能看到大约 40 个书签。

书签存储在预设文件~/.config/gtk-3.0/bookmarks中。目前,我为不同的项目使用不同的书签文件,这确实很麻烦。

任何关于如何改进这一点的提示都值得赞赏。

是否有可能在 Nautilus 启动时为不同的项目使用不同的书签文件,或者我们是否可以期待在不久的将来出现子文件夹?

nautilus bookmarks
  • 1 1 个回答
  • 361 Views

1 个回答

  • Voted
  1. Best Answer
    pa4080
    2018-03-15T07:33:34+08:002018-03-15T07:33:34+08:00

    我发现 Nautilus 书签在文件内容更改时会动态~/.config/gtk-3.0/bookmarks更改。所以我的建议是下面的脚本,可以绑定到自定义键盘快捷键。这是它的工作原理:

    在此处输入图像描述

    • 创建可执行文件,调用nautilus-bookmarks-manager并位于/usr/local/bin可作为 shell 命令访问的目录中(或使用不同的名称和位置):

      sudo touch /usr/local/bin/nautilus-bookmarks-manager
      sudo chmod +x /usr/local/bin/nautilus-bookmarks-manager
      sudo nano /usr/local/bin/nautilus-bookmarks-manager
      
    • 在命令应位于的位置创建自定义键盘快捷键:

      /usr/local/bin/nautilus-bookmarks-manager
      

    脚本内容为:

    #!/bin/bash
    
    # Initial variables; the last underscore in $PROFILE_NAME_TEMPLATE is important
    BOOKMARKS_DIR="$HOME/.config/gtk-3.0"
    BOOKMARKS="$BOOKMARKS_DIR/bookmarks"
    PROFILES_DIR="$BOOKMARKS_DIR/bookmarks_profiles"
    PROFILE_NAME_TEMPLATE="$PROFILES_DIR/bookmarks_profile_"
    
    # If the profiles directory doesn't exist create it,
    # otherwise renumber the existing profiles in case some of them were deleted
    [[ ! -d $PROFILES_DIR ]] && mkdir -p "$PROFILES_DIR" || rename 's/[0-9]*$/our $i; sprintf("%d", 1+$i++)/e' "$PROFILES_DIR/"*
    
    # Get the list of the profiles as an array,
    # the expression `[[ -z ${PROFILES[@]##*\*} ]]` means `if the directory is empty` or not empty when there is a `!`
    PROFILES=("$BOOKMARKS_DIR/bookmarks_profiles/"*)
    
    main() {
            # Compare the current profile to each existing profile in $PROFILES and find the $CURRENT_PROFILE if it exists
            for profile in "${PROFILES[@]}"; do cmp -s "$BOOKMARKS" "$profile" && CURRENT_PROFILE="$profile"; done
    
            # Get the number of the current profile
            CURRENT_PROFILE_NUMBER="${CURRENT_PROFILE##*_}"
    
            # If the $CURRENT_PROFILE doesn't exist in the list of profiles and the directory is epty: $NEW_PROFILE_NUMBER = 1
            # If it doesn't exist and the directory is not epty: $NEW_PROFILE_NUMBER = ( number of the profiles + 1 )
            # If this is the last profile from the list the next profile number is 1: $NEW_PROFILE_NUMBER = 1
            # In all other case increment the $CURRENT_PROFILE_NUMBER by 1
            if   [[ -z ${CURRENT_PROFILE+x} && -z ${PROFILES[@]##*\*} ]]; then
                    NEW_PROFILE_NUMBER=1
            elif [[ -z ${CURRENT_PROFILE+x} && ! -z ${PROFILES[@]##*\*} ]]; then
                    NEW_PROFILE_NUMBER=$(( ${#PROFILES[@]} + 1 ))
            elif [[ $CURRENT_PROFILE_NUMBER -eq ${PROFILES[-1]##*_} ]]; then
                    NEW_PROFILE_NUMBER=1
            else
                    NEW_PROFILE_NUMBER=$(( CURRENT_PROFILE_NUMBER + 1 ))
            fi
    
            # If the current profile doesn't exist in the list add it, else just switch to the next profile
            if   [[ -z ${CURRENT_PROFILE+x} ]]; then
                    cp "${BOOKMARKS}" "${PROFILE_NAME_TEMPLATE}${NEW_PROFILE_NUMBER}"
                    echo "Profile ${NEW_PROFILE_NUMBER} is CREATED"
            else
                    cp "${PROFILE_NAME_TEMPLATE}${NEW_PROFILE_NUMBER}" "${BOOKMARKS}"
                    echo "Profile ${NEW_PROFILE_NUMBER} is ACTIVATED"
            fi
    }
    
    killall notify-osd >/dev/null 2>&1  # Kill all notify-send messages
    notify-send "$(main 2>&1)"          # Call the `main` function and output all messages through `notify-send`
    

    该脚本会将每个新配置文件存储在目录中~/.config/gtk-3.0/bookmarks_profiles。如果此目录不存在,则会创建它。否则,脚本将尝试重新分配现有配置文件,以防您删除了其中一些配置文件。这导致两种情况:

    • 当你想删除某个配置文件时,首先你应该激活另一个配置文件;
    • 当您想将某个配置文件移动到列表末尾时,将其激活,然后将其删除并执行脚本。

    下一个。该脚本会将文件~/.config/gtk-3.0/bookmarks与~/.config/gtk-3.0/bookmarks_profiles. 如果发现巧合,脚本将切换到下一个配置文件。如果没有巧合,将创建一个新的配置文件。

    脚本的更高级版本可以使用命名(而不是编号)配置文件和一些工具(如zenity )来获取新配置文件的名称。

    • 1

相关问题

  • Nautilus 自动以 root 身份浏览

  • 在 nautilus 中刷新缩略图

  • 如何在 Nautilus 中管理保存的完整网页及其目录(例如 n.html 和 n_files)

  • 如何让 Nautilus windows 坚持拖放?[关闭]

  • Nautilus 中的 FTP 连接问题 - 一段时间后似乎超时

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve