mirror of https://codeberg.org/glenneth/stash.git
75 lines
3.1 KiB
Markdown
75 lines
3.1 KiB
Markdown
|
||
# Stash
|
||
|
||
`stash` is a command-line utility written in Guile Scheme that helps manage symbolic links (symlinks) for files and directories. This tool is inspired by GNU Stow but written in Guile Scheme. It provides conflict resolution and an interactive interface, allowing users to move directories to a target location and create symlinks in the source directory's parent folder.
|
||
|
||
## Key Features
|
||
|
||
- **Move and Symlink**: `stash` moves entire directories to a specified target directory and creates a symlink in the original parent directory.
|
||
- **Conflict Handling**: When a conflict occurs (e.g., an existing symlink), the user is prompted to either overwrite, skip, or cancel.
|
||
- **Logging**: All actions, such as moving directories, creating symlinks, and resolving conflicts, are logged in `guile-stash.log`.
|
||
- **Command-Line Interface**: Command-line parsing allows for specifying the source and target directories.
|
||
|
||
## Usage
|
||
|
||
```sh
|
||
guile -L . stash.scm --target=<target-dir> --source=<package-dir>
|
||
```
|
||
|
||
- `<target-dir>`: Directory where the package directory will be moved.
|
||
- `<source>`: Directory to be moved and symlinked.
|
||
|
||
## Example
|
||
|
||
Suppose you want to move `~/.config/rofi` to `~/.dotfiles/.config` and create a symlink at `~/.config/rofi` pointing to the new location. You would run:
|
||
|
||
```sh
|
||
guile -L . stash.scm --target=~/.dotfiles/.config --source=~/.config/rofi
|
||
```
|
||
|
||
This moves the `rofi` directory to `~/.dotfiles/.config` and creates a symlink in `~/.config` pointing to the new location.
|
||
|
||
## Conflict Resolution
|
||
|
||
If a symlink already exists at the target location, `guile-stash` detects this and prompts the user to either:
|
||
|
||
- **Overwrite**: Remove the existing symlink and create a new one.
|
||
- **Skip**: Keep the existing symlink and skip creating a new one.
|
||
- **Cancel**: Cancel the operation.
|
||
|
||
## Logging
|
||
|
||
All actions taken by the program are logged in a file named `stash.log`. This includes:
|
||
|
||
- Moving directories.
|
||
- Creating symlinks.
|
||
- Conflict resolutions.
|
||
|
||
Example log entry:
|
||
```
|
||
Moved /home/glenn/.config/rofi to /home/glenn/.dotfiles/.config/rofi
|
||
Symlink created at /home/glenn/.config/rofi pointing to /home/glenn/.dotfiles/.config/rofi
|
||
```
|
||
|
||
## Improvements
|
||
|
||
Here’s a summary of the recent improvements:
|
||
|
||
1. **Move Entire Directory**: Instead of copying, the program now moves the entire directory from the package directory to the target directory.
|
||
|
||
2. **Path Expansion**: The program now correctly expands `~` to the full path using `$HOME`, ensuring compatibility with home directory shortcuts.
|
||
|
||
3. **Logging Functionality**: All operations are logged to `stash.log` to track actions like moving directories and creating symlinks.
|
||
|
||
4. **Modular Functions**: The program is now structured with modular functions for path expansion, conflict handling, and symlink creation.
|
||
|
||
## Future Enhancements
|
||
|
||
- Add support for a non-interactive mode for automation workflows.
|
||
- Improve error handling for more specific error types and exit codes.
|
||
- Extend conflict resolution options with more advanced features (e.g., backup, replace).
|
||
|
||
## License
|
||
|
||
`stash` is licensed under the GNU General Public License v3. See the LICENSE file for more information.
|