使用 stow 忽略目录

使用 stow 忽略目录

我在stow正确使用时遇到问题。我用来安装所有的脚本stow是:

cd ~/Utility/configs
for file in *; do
  # Only run Stow on the directories in the dotfiles folder and not the individual files.
  # Using 'basename' strips the filepath from the directory name. 
  if [ -d ${file} ]; then
    stow  $(basename $file) -t ~/
    echo "$(basename $file) stowed."; 
  fi
done

现在,我在vim目录为:中包含~Utility/configs/vim/

tree . -a  -L 2
.
├── .stow-local-ignore
├── .vim
│   ├── autoload
│   ├── plugged
│   └── UltiSnips
└── .vimrc

其中,我想忽略plugged不被存放,因此.stow-local-ignore

\.vim/plugged
\.vim/spell

但这并没有达到预期目的,并且插入总是被收起。基本上, ~/.vim/ 里面的内容都在 里面~/Utility/configs/vim/.vim。这是我不想要的。我特别想要仅有的 autoload并且Ultisnips可以存放,没有别的。

我怎样才能做到这一点?

注意:我以 vim 为例,但这与 vim 无关,而是与 stow 相关。所以我在这里发帖,而不是在 vim 频道。

存储输出,详细信息=5

Stowing contents of Utility/configs/vim (cwd=/home/rudra)
  => Utility/configs/vim
  is_a_node(.)
  link_task_action(.): no task
  dir_task_action(.): no task
    parent_link_scheduled_for_removal(.): prefix 
    parent_link_scheduled_for_removal(.): returning false
  is_a_node(.): really exists
  Using ignore file: Utility/configs/vim/.stow-local-ignore
    Ignore list regexp for paths:    /(?^:(^|/)(\.vim/spell|^/\.stow\-local\-ignore$|\.vim/plugged)(/|$))/
    Ignore list regexp for segments: none
  Not ignoring .vimrc
Stowing Utility/configs / vim / .vimrc
  => Utility/configs/vim/.vimrc
  is_a_link(.vimrc)
  link_task_action(.vimrc): no task
  is_a_link(.vimrc): returning 0
  is_a_node(.vimrc)
  link_task_action(.vimrc): no task
  dir_task_action(.vimrc): no task
    parent_link_scheduled_for_removal(.vimrc): prefix .vimrc
    parent_link_scheduled_for_removal(.vimrc): returning false
  is_a_node(.vimrc): returning false
LINK: .vimrc => Utility/configs/vim/.vimrc
  Using ignore file: Utility/configs/vim/.stow-local-ignore
    Using memoized regexps from Utility/configs/vim/.stow-local-ignore
    Ignore list regexp for paths:    /(?^:(^|/)(\.vim/spell|^/\.stow\-local\-ignore$|\.vim/plugged)(/|$))/
    Ignore list regexp for segments: none
  Ignoring path /.stow-local-ignore
  Using ignore file: Utility/configs/vim/.stow-local-ignore
    Using memoized regexps from Utility/configs/vim/.stow-local-ignore
    Ignore list regexp for paths:    /(?^:(^|/)(\.vim/spell|^/\.stow\-local\-ignore$|\.vim/plugged)(/|$))/
    Ignore list regexp for segments: none
  Not ignoring .vim
Stowing Utility/configs / vim / .vim
  => Utility/configs/vim/.vim
  is_a_link(.vim)
  link_task_action(.vim): no task
  is_a_link(.vim): returning 0
  is_a_node(.vim)
  link_task_action(.vim): no task
  dir_task_action(.vim): no task
    parent_link_scheduled_for_removal(.vim): prefix .vim
    parent_link_scheduled_for_removal(.vim): returning false
  is_a_node(.vim): returning false
LINK: .vim => Utility/configs/vim/.vim
Planning stow of package vim... done

@Kusalananda:这就是我正在做的事情,verbose=2:

pwd
/home/rudra/Utility/configs
 mv vim/.stow-local-ignore ~/
stow -D vim --verbose=2
stow dir is /home/rudra/Utility/configs
stow dir path relative to target /home/rudra/Utility is configs
Planning unstow of package vim...
CONFLICT when unstowing vim: existing target is neither a link nor a directory: .vimrc
.vim did not exist to be unstowed
Planning unstow of package vim... done
WARNING! unstowing vim would cause conflicts:
  * existing target is neither a link nor a directory: .vimrc
All operations aborted.

cd vim/
stow -D .vim --verbose=2
stow dir is /home/rudra/Utility/configs/vim
stow dir path relative to target /home/rudra/Utility/configs is vim
Planning unstow of package .vim...
UltiSnips did not exist to be unstowed
autoload did not exist to be unstowed
plugged did not exist to be unstowed
Planning unstow of package .vim... done
Processing tasks...

stow -D .vimrc --verbose=2
stow dir is /home/rudra/Utility/configs/vim
stow dir path relative to target /home/rudra/Utility/configs is vim
stow: ERROR: The stow directory vim does not contain package .vimrc
cd ..
ll ~/.vim*
lrwxrwxrwx. 1 rudra rudra  24 Apr 30 16:16 /home/rudra/.vim -> Utility/configs/vim/.vim
-rw-------. 1 rudra rudra 13K Apr 30 16:17 /home/rudra/.viminfo
lrwxrwxrwx. 1 rudra rudra  26 Apr 30 16:10 /home/rudra/.vimrc -> Utility/configs/vim/.vimrc
unlink ~/.vim
unlink ~/.vimrc
cp ~/.stow-local-ignore vim/
stow vim -t ~/ --verbose=2
stow dir is /home/rudra/Utility/configs
stow dir path relative to target /home/rudra is Utility/configs
Planning stow of package vim...
LINK: .vimrc => Utility/configs/vim/.vimrc
LINK: .vim => Utility/configs/vim/.vim
Planning stow of package vim... done
Processing tasks...
Processing tasks... done
tree ~/.vim -L 1
/home/rudra/.vim
├── autoload
├── plugged
└── UltiSnips

答案1

您的忽略文件的语法是正确的。

.stow-local-ignore文件一经创建即生效。

当它生效时,它会影响装载、重新装载和卸载。

这意味着如果您存放了一个目录,并且然后添加了忽略文件,恢复或取消该目录将不是影响了已存储的文件,这些文件在.stow-local-ignore.指向它们的符号链接将保留安装状态。

因此,将 a 添加.stow-local-ignore到目录时请遵循以下工作流程:

  1. 确保该目录是不是收起。
  2. 添加.stow-local-ignore文件。
  3. 存放目录。

您现在应该做的是删除/重命名忽略文件,取消存放目录,添加忽略文件,然后再次存放目录。

相关内容