#stow #symlink #directory #backup #original #package #create

app stowsave

Automates moving files into a stow directory then using stow to create symlinks back to where the files came from

4 releases

0.1.7 Oct 11, 2024
0.1.6 Sep 22, 2024
0.1.1 Sep 22, 2024
0.1.0 Sep 22, 2024

#79 in Filesystem

Download history 222/week @ 2024-09-16 175/week @ 2024-09-23 81/week @ 2024-09-30 181/week @ 2024-10-07 24/week @ 2024-10-14

683 downloads per month

MIT license

28KB
493 lines

StowSave

stowsave automates the process of moving files from their original location to a Stow package directory then running GNU stow to create symlinks. Backups of the original files are created to prevent data loss.

For example, say your working on ~/dev/project/my_script. Invoking stowsave as

stowsave ~/dev/project/my_script ~/my/stow/directory

will do the following:

  1. create a backup of ~/dev/project/my_script at ~/dev/project/my_script.bak,
  2. move ~/dev/project/my_script to ~/my/stow/directory/dev/project/my_script, and
  3. run stow in ~/my/stow/directory to create a symlink at ~/dev/project/my_script pointing to ~/my/stow/directory/dev/project/my_script.

Installation

cargo install stowsave

Usage

stowsave <PATH_TO_SAVE> <STOW_PACKAGE>
  • <PATH_TO_SAVE>: The path to the file or directory you want to save
  • <STOW_PACKAGE>: The directory where your Stow packages are stored

What does the above do?

  • Creates a backup of the given <PATH_TO_SAVE> file or directory, backing up to <PATH_TO_SAVE>.bak. For directories, the backup is recursive is a recursive copy operation.
  • Move the original <PATH_TO_SAVE> to the given <STOW_PACKAGE>.
  • Run stow to create symlinks from the <STOW_PACKAGE> to the original location of <PATH_TO_SAVE>.

Example

stowsave ~/.vimrc ~/dotfiles/vim

This command will:

  1. Copy ~/.vimrc to ~/dotfiles/vim/.vimrc
  2. Rename the original ~/.vimrc to ~/.vimrc.bak
  3. Run stow vim in the ~/dotfiles directory

Requirements

  • Rust (for building)
  • GNU Stow

Roadmap

  • improve tests
    • end-to-end tests
    • create DSL for setup and and verification of directory structures with nested files and symlinks
  • add command line flags such as --no-backup
  • add a command to undo stowsave. This should reverse the stowsave operation: - remove the symlink that points into the stow package. This could possibly be done by running stow -D on the stow package, but that would remove all symlinks into the package so we'd have to run stow again on the package later to restore the other symlinks. - move the original file out of the stow package and to the location where the symlink was. - remove empty directorie(s) within the stow package that contained the file that's been moved.
  • ask for confirmation if it seems that the user is going to stow a directory that contains symlinks that point into the current or another stow package. For example, running
stowsave .config ~/dotfiles/pkg

might be unwanted if the .config folder already contains some symlinks that point into the

This README file is generated based on the docs in src/main.rs.

Dependencies

~1.4–2MB
~36K SLoC