|
1 | 1 | # d |
2 | 2 |
|
3 | | -I'm implementing another dotfile manager 😮💨 |
| 3 | + |
4 | 4 |
|
5 | | -- I stopped working on [dotfox ](https://github.com/fox-archives/dotfox) because I [lost confidence ](https://forum.nim-lang.org/t/10312#68553) in the [social ](https://forum.dlang.org/post/[email protected]) and [technical ](https://news.ycombinator.com/threads?id=carterza) leadership for the language I was using, Nim |
6 | | -- [dotmgr](https://github.com/hyperupcall/dotmgr) was supposed to replace it, but it grew too much in scope and it doesn't work on all platforms (Cygwin) |
| 5 | +--- |
7 | 6 |
|
8 | | -I've learned some things: |
| 7 | +A dotfile manager. |
9 | 8 |
|
10 | | -- Continue to use symlinks |
11 | | -- Continue to implement undeploy |
12 | | -- Continue to properly test |
13 | | -- Explicitly specify if file/directory |
14 | | - - That way, a directory can exist at source location (with multiple choices) |
15 | | -- Implement interactive mode |
16 | | -- Implement command to interactively swap out file |
17 | | -- Make status updates one line |
| 9 | +## Features |
18 | 10 |
|
19 | | -## Additional Goals |
20 | | - |
21 | | -- Heapless (TODO) |
22 | | -- Multi-platform |
| 11 | +- NOT "SUCKLESS" (IF YOU HAVE TO CONVINCE ME THAT YOUR SOFTWARE "SUCKS LESS", THEN IT ACTUALLY SUCKS!) |
| 12 | +- NO "CONFIGURATION FILES" (THE CONCEPT OF "CONFIGURATION FILES" SHOULD NOT EXIST!) |
| 13 | +- NO "DOCUMENTATION" (WHAT IS THAT?) |
| 14 | +- NOT WRITTEN IN RUST (NO, I'M NOT INSANE!) |
23 | 15 |
|
24 | 16 | ## Summary |
25 | 17 |
|
26 | | -### Config |
| 18 | +On a more serious note, `d` is your standard dotfile manager, with the twist that it can be configured using C, hopefully leveraging the ~~cursed~~ C preprocessor. It's meant to be small and only does what it says it does. |
27 | 19 |
|
28 | | -Configure which files to manage with an INI-style file. |
| 20 | +It approaches reconciliation using symlinks. It doesn't support templates or any of that nonsense. |
29 | 21 |
|
30 | | -First, label the location of the source and target directories. All paths are relative to these |
| 22 | +A disclaimer for those curious to use `d`: currently, the code is dogshit. But I'm sure that many of you wouldn't mind one bit. |
31 | 23 |
|
32 | | -```ini |
33 | | -source_root_dir = $pwd/source |
34 | | -target_root_dir = $pwd/target |
35 | | -``` |
| 24 | +### Usage |
36 | 25 |
|
37 | | -Then, come the variables. By default, `$home` and `$pwd` (relative to the file) are defined, but you can define more (TODO) |
| 26 | +```bash |
| 27 | +git clone [email protected]:fox-incubating/d |
| 28 | +cd ./d |
| 29 | +# Currently a few things are hardcoded. If you're still as brave as you think you are, |
| 30 | +# you can check the TODO comments in the source |
| 31 | +make CONFIG_FILE="$HOME/dotfiles.c" install |
| 32 | +``` |
38 | 33 |
|
39 | | -```ini |
40 | | -[vars] |
41 | | -cfg = ${XDG_CONFIG_HOME:-$HOME/.config} |
42 | | -data = ${XDG_DATA_HOME:-$HOME/.local/share} |
43 | | -state = ${XDG_DATA_HOME:-$HOME/.local/state} |
| 34 | +`CONFIG_FILE` should look something like: |
| 35 | + |
| 36 | +```c |
| 37 | +struct Entry { |
| 38 | + char const *category; |
| 39 | + char const *source; |
| 40 | + char const *destination; |
| 41 | +}; |
| 42 | +#define Done { \ |
| 43 | + .category = NULL, .source = NULL, .destination = NULL \ |
| 44 | +} |
| 45 | + |
| 46 | +static struct Entry bash[] = { |
| 47 | + { |
| 48 | + .category = "bash" |
| 49 | + .source = "/home/edwin/.dotfiles/.bashrc", |
| 50 | + .destination = "/home/edwin/.bashrc" |
| 51 | + }, |
| 52 | + Done |
| 53 | +}; |
| 54 | + |
| 55 | +struct Entry *configuration[] = { |
| 56 | + bash |
| 57 | +}; |
44 | 58 | ``` |
45 | 59 |
|
46 | | -Lastly, list your entries. There are two types: |
| 60 | +The really cool part about this, is that you can use macros. If you don't like macros, then maybe this software isn't for you. For an example, see my own [dotfiles.c](https://github.com/hyperupcall/dotfiles/blob/trunk/os-unix/data/dotfiles.c). Later I'll probably support some sort of `get_configuration()` to allow the use of runtime shenanigans. |
47 | 61 |
|
48 | | -Tags are TODO |
| 62 | +Whenever you edit, you must run `./d compile` to compile the C program into a shared object file. It'll be dynamically loaded on subsequent invocations. Maybe I'll add a file watcher sometime. |
49 | 63 |
|
50 | | -```ini |
51 | | -[entry] |
52 | | -path = .bashrc |
53 | | -what = file |
54 | | -tags = [Bash] |
| 64 | +Now, you can use `d` like any other dotfile manager: |
55 | 65 |
|
56 | | -[entry] |
57 | | -source = $cfg/X11/xinitrc |
58 | | -target = $home/.xinitrc |
59 | | -what = file |
60 | | -tags = [X11] |
| 66 | +```console |
| 67 | +$ d deploy |
| 68 | +$ d undeploy |
61 | 69 | ``` |
0 commit comments