Feature suggestion: .stow-rename
Danielle McLean <[email protected]> Sun, 9 Oct 2016 17:36:09 -0400
| Newsgroups | gmane.comp.gnu.stow.devel |
|---|---|
| Message-ID | <CAJnbmRQbS4zdZaNJyWjE=s35qq-FTa4b584HZYe7eE1=BR4DRQ@mail.gmail.com> |
Although Stow's main use is the installation and control of separate software packages, usually in /usr/local, it's also popular as a way of managing dotfiles in your home directory, as discussed in http://brandon.invergo.net/news/2012-05-26-using-gnu-stow-to-manage-your-do= tfiles.html However, under standard Stow behaviour, this use case means that your packages must contain only hidden files, like this (where ~/dotfiles is the stow directory): ~/dotfiles =E2=94=9C=E2=94=80=E2=94=80 vim =E2=94=82 =C2=A0 =E2=94=9C=E2=94=80=E2=94=80 .config =E2=94=82 =C2=A0 =E2=94=9C=E2=94=80=E2=94=80 .gvimrc =E2=94=82 =C2=A0 =E2=94=9C=E2=94=80=E2=94=80 .ideavimrc =E2=94=82 =C2=A0 =E2=94=94=E2=94=80=E2=94=80 .vimrc =E2=94=94=E2=94=80=E2=94=80 zsh =C2=A0 =C2=A0 =E2=94=9C=E2=94=80=E2=94=80 .config =C2=A0 =C2=A0 =E2=94=94=E2=94=80=E2=94=80 .zshenv Typically it is significantly preferable for your package contents to be visible, and to that end I suggest an extension to Stow: the .stow-rename file. A file called .stow-rename may be placed in the root directory of each package - it is a text file in the format: stow_name =3D> target_name stow_name_2 =3D> target_name_2 (This format was chosen as it closely resembles a Perl hash - which is also what's used to store the rename information in my implementation. c: ) If a .stow-rename file exists, then Stow performs a two-way mapping of the paths within the package directory and the paths within the target directory. In particular, the symbolic link to the file "stow_name" will instead be given the name "target_name" when it is created in the target directory. If stow_name is a directory, then the directory created by tree unfolding is also renamed to "target_name" accordingly. This capability can then be used to create clean, visible dotfiles packages like so: $ tree ~/dotfiles ~/dotfiles =E2=94=9C=E2=94=80=E2=94=80 vim =E2=94=82 =C2=A0 =E2=94=9C=E2=94=80=E2=94=80 .stow-rename =E2=94=82 =C2=A0 =E2=94=9C=E2=94=80=E2=94=80 config =E2=94=82 =C2=A0 =E2=94=82 =C2=A0 =E2=94=94=E2=94=80=E2=94=80 vim =E2=94=82 =C2=A0 =E2=94=82 =C2=A0 =C2=A0 =C2=A0 =E2=94=9C=E2=94=80=E2=94=80= ftplugin =E2=94=82 =C2=A0 =E2=94=82 =C2=A0 =C2=A0 =C2=A0 =E2=94=82 =C2=A0 =E2=94=9C= =E2=94=80=E2=94=80 crontab.vim =E2=94=82 =C2=A0 =E2=94=82 =C2=A0 =C2=A0 =C2=A0 =E2=94=82 =C2=A0 =E2=94=94= =E2=94=80=E2=94=80 html.vim =E2=94=82 =C2=A0 =E2=94=82 =C2=A0 =C2=A0 =C2=A0 =E2=94=94=E2=94=80=E2=94=80= vimrc =E2=94=82 =C2=A0 =E2=94=9C=E2=94=80=E2=94=80 gvimrc =E2=94=82 =C2=A0 =E2=94=9C=E2=94=80=E2=94=80 ideavimrc =E2=94=82 =C2=A0 =E2=94=94=E2=94=80=E2=94=80 vimrc =E2=94=94=E2=94=80=E2=94=80 zsh =C2=A0 =C2=A0 =E2=94=9C=E2=94=80=E2=94=80 .stow-rename =C2=A0 =C2=A0 =E2=94=9C=E2=94=80=E2=94=80 config =C2=A0 =C2=A0 =E2=94=94=E2=94=80=E2=94=80 zshenv $ cat ~/dotfiles/vim/.stow-rename config =3D> .config gvimrc =3D> .gvimrc ideavimrc =3D> .ideavimrc vimrc =3D> .vimrc $ readlink ~/.config/vim ../dotfiles/vim/config/vim I have implemented this feature in my own copy of Stow, which may be found at=C2=A0https://github.com/00dani/dot-stow=C2=A0, and there are addit= ional examples of its use in all of my dot-* repos: https://github.com/00dani?tab=3Drepositories&q=3Ddot- A possible extension to this feature would be allowing $ENVIRONMENT_VARIABLES to appear in the .stow-rename file. This would enable true XDG support for individual packages: config =3D> $XDG_CONFIG_HOME However even with only static names I think the feature has merit, and I would recommend it be considered for addition to Stow upstream. Thoughts?