https://github.com/okomestudio/symlinkto
Create symlinks to version-controlled files.
https://github.com/okomestudio/symlinkto
bash dotfiles shell symlink-management
Last synced: 4 months ago
JSON representation
Create symlinks to version-controlled files.
- Host: GitHub
- URL: https://github.com/okomestudio/symlinkto
- Owner: okomestudio
- License: mit
- Created: 2024-09-13T06:38:03.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-21T10:18:47.000Z (over 1 year ago)
- Last Synced: 2025-04-05T18:16:09.505Z (about 1 year ago)
- Topics: bash, dotfiles, shell, symlink-management
- Language: Shell
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# symlinkto
Create symlinks to version-controlled files.
## Install
``` shellsession
$ make
```
This will install the script `symlinkto` in `$HOME/.local/bin`.
## Usage
Let us first describe what we want to achieve.
Consider a `$HOME` (`~`) directory tree as follows:
``` text
~/
└── github.com/
└── okomestudio/
└── symlinkto/
```
In these directories, we want to have three files, `.bashrc`, `.gitconfig`, and
`.dir-locals.el`:
``` text
~/
├── .bashrc
└── github.com/
├── .gitconfig
└── okomestudio/
└── symlinkto/
└── .dir-locals.el
```
Instead of creating files there, we want to put them under version control, e.g., with a
"dotfiles" Git repo, and have symlinks pointing to them. Say we have such a
version-controlled repository at `~/github.com/okomestudio/dotfiles`:
``` text
~/
└── github.com/
└── okomestudio/
└── dotfiles/
├── .bashrc
└── github.com/
├── .gitconfig
└── okomestudio/
└── symlinkto/
└── .dir-locals.el
```
In this case, we set `SYMLINKTO_TREE` to `~/github.com/okomestudio/dotfiles`
``` shell
export SYMLINKTO_TREE=~/github.com/okomestudio/dotfiles
```
in one of the shell startup files (e.g., `.bashrc`) (or in `.envrc` of `direnv`).
Then, after running `symlinkto`, the following symlinks are created:
``` text
~/
├── .bashrc -> $SYMLINKTO_TREE/.bashrc
└── github.com/
├── .gitconfig -> $SYMLINKTO_TREE/github.com/.gitconfig
└── okomestudio/
└── symlinkto/
└── .dir-locals.el -> $SYMLINKTO_TREE/github.com/symlinkto/.dir-locals.el
```
There you have it. This is what `symlinkto` is for.
### Running symlinkto
The `symlinkto` shell command behaves differently based on the current directory.
``` shellsession
$ symlinkto
... for each symlink candidate, it prompts for a user action ...
```
When the current directory is in or under `SYMLINKTO_TREE`, all the symlink candidates are
recursively searched for in the subdirectories, and for each, `symlinkto` prompts the user
for an action (i.e., create, delete, or skip).
When the current directory is outside `SYMLINKTO_TREE`, `symlinkto` recursively searches
for relevant symlink candidates in or under the current directory, and for each candidate
found, it prompts the user for an action (i.e., create, delete, or skip).