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 |
#130 in Filesystem
29KB
514 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:
- create a backup of
~/dev/project/my_script
at~/dev/project/my_script.bak
, - move
~/dev/project/my_script
to~/my/stow/directory/dev/project/my_script
, and - 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:
- Copy
~/.vimrc
to~/dotfiles/vim/.vimrc
- Rename the original
~/.vimrc
to~/.vimrc.bak
- 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 runningstow -D
on the stow package, but that would remove all symlinks into the package so we'd have to runstow
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
~37K SLoC