sinc

Crates.iosinc
lib.rssinc
version0.7.1
sourcesrc
created_at2023-02-23 21:11:28.125779
updated_at2023-04-01 21:05:53.672884
descriptionA cross-platform dotfiles manager written in Rust.
homepage
repositoryhttps://github.com/futsuuu/sinc
max_upload_size
id793054
size36,199
futsuuu (futsuuu)

documentation

README

Sinc

A cross-platform dotfiles manager

WIP

This repository is still development. Use at your own lisk.

Installation

$ cargo install sinc

Getting started

Config file

Sing looks for the config file in the following location:

  • $SINC_CONFIG_DIR/sinc/sinc.toml
  • $XDG_CONFIG_HOME/sinc/sinc.toml
  • $HOME/.config/sinc/sinc.toml

Minimal config

The following is the minimal config:

[default]
dir = "~/.dotfiles"
sync_type = "symlink"

[[dotfiles]]
path = "sinc"
target = "~/.config/sinc"

If you run the sinc command in this state, a symbolic link is created from ~/.dotfiles/sinc to ~/.config/sinc.
In other words, the config files mentioned earlier have been moved to ~/.dotfiles/sinc and a symbolic link has been created to the original location.

(dir + path)         (sync_type)            (target)
 │                    │                    │
 V                    V                    V
~/.dotfiles/sinc  <<== symbolic link ==>>  ~/.config/sinc

Now, this config does not support applications that have different location for their config file depending on the OS.

To solve this, you can use sys(os) instead of specifying the value directly.

[[dotfiles]]
path = "bat"
  [dotfiles.target."sys(os)"]
  default = "~/.config/bat"
  windows = "~/AppData/Roaming/bat"

Configration value

Config

Key Value type
default Table
dotfiles Array of Tables

Config.default

Key Value type
dir String
sync_type SyncType

Config.dotfiles

Key Value type Default value
dir String Config.default.dir
sync_type SyncType Config.default.sync_type
target String or Array<String>
path String
enable Boolean true
hook_add String ""

The value set in hook_* will be executed as a command at the specified timing.

flowchart LR
Start([start]) ===> enable
enable{enable} ===> |true| sync
enable ---> |false| End
sync[[sync]] ===> |success| hook_add
hook_add[[hook_add]] ===> End
sync ---> |fail| End([End])

SyncType

Value Description
"symlink" If you are using Windows, you need administrator rights
"junction" Windows only / used to link to folder
"hardlink" Behave like the original file / used to link to file
"copy" Just copy

Config.**.sys(...)

Name Key Key example
sys(os) os_info::Type (lower case) arch linux
sys(os_type) std::env::consts::OS linux
sys(os_family) std::env::consts::FAMILY unix
example
[default]
dir = "~/.dotfiles"
sync_type."sys(os)" = { default = "symlink", windows = "junction" }

[[dotfiles]]
path = "bat"
  [dotfiles.target."sys(os)"]
  default = "~/.config/bat"
  windows = "~/AppData/Roaming/bat"

[[dotfiles]]
path = ".gitconfig"
target = "~/.gitconfig"
  [dotfiles.sync_type."sys(os)"]
  default = "symlink"
  windows = "hardlink"

Config.**.which(...)

Name Key
which(COMMAND) path to COMMAND or "" to be selected if COMMAND does not exist
example
[[dotfiles]]
path = "neofetch"
target = "~/.config/neofetch"
  [dotfiles.enable."which(neofetch)"]
  # Enabled if the "neofetch" executable exists somewhere in $PATH.
  default = true
  "" = false

[[dotfiles]]
path = "hyprland"
target = "~/.config/hypr"
  [dotfiles.enable."which(wrappedhl)"]
  # Enabled if the "wrappedhl" executable exists in "~/bin/wrappedhl" in $PATH.
  default = false
  "~/bin/wrappedhl" = true

License

MIT

Commit count: 87

cargo fmt