dotune-0.1.1 is not a library.
dotune
A dotfile manager for configs applied on different operating systems simultaneously. Write Lua scripts to decide where your stuff is being linked to
Example
Say I want to link Vieb configuration:
-- Check if Vieb is installed (if you want)
if not :
-- Use `Path` primitive instead of strings
local src = Path. / 'web/vieb'
Dot.
-- ^ symlink ~/Repos/dotfiles/web/vieb/colors -> ~/.vieb/colors
Dot.
-- ^ symlink ~/Repos/dotfiles/web/vieb/.viebrc -> ~/.viebrc
-- Use `include` to run configs in child folders (like require, but relative)
include -- https://github.com/qutebrowser/qutebrowser
# Execute the script
CLI
Lua API
Standard library
Lua scripts have access to very basic parts of standard library: print, string, table and utf8. More complicated stuff like file I/O and environment access are disabled
include
include -- Run shell/.dotune.lua relative to the current script
include -- Nested paths are allowed; absolute paths, . and .. are not
Dot
Dot.link
-- Create a symlink to a file or directory, creating missing parent directories.
-- Sources must be inside the repository; destinations must be outside it.
-- Replaces existing symlinks; errors if a regular file or directory exists.
Dot.
Dot.copy
-- Copy a file or directory, creating missing parent directories.
-- Sources must be inside the repository; destinations must be outside it.
-- Directories are merged, matching files are overwritten, extra files are kept.
Dot.
Path
local config = Path. / 'config.toml' -- Join; same as Path.here:join('config.toml')
Dot. -- Passes source and destination, keeping the filename
Dot. -- Choose a different destination name
local renamed = config % 'app.toml' -- Replace filename; :with_tail('app.toml')
local backup = config * 'bak' -- Replace extension; :with_extension('bak')
local parent = config. -- Parent path, or nil at the filesystem root
local exists = config: -- Whether the path exists
local resolved = config: -- Absolute path with symlinks resolved, or nil on failure
local text = tostring -- Convert a Path to a string
local binary = Path. -- Find an executable on PATH, or return nil
local home = Path. -- User's home directory
local here = Path. -- Current script's directory; alias of Path.script_dir
local script = Path. -- Current .dotune.lua file
local root = Path. -- Filesystem root (e.g. / or C:\)
XDG
-- Uses XDG environment variables, falling back to these paths under Path.home:
local config = XDG. -- XDG_CONFIG_HOME: ~/.config
local data = XDG. -- XDG_DATA_HOME: ~/.local/share
local state = XDG. -- XDG_STATE_HOME: ~/.local/state
local cache = XDG. -- XDG_CACHE_HOME: ~/.cache
OS
local config = OS.
-- Priority: exact OS, then unix, then _;
-- All keys are optional, but no match is an error
local is_windows = OS.
-- ^ Same thing just for boolean conditions
Platform paths
(Not all paths are defined yet, more like a proof of concept for now)
Windows
local roaming = Windows. -- APPDATA, or ~/AppData/Roaming
local local_data = Windows. -- LOCALAPPDATA, or ~/AppData/Local
local low = Windows. -- ~/AppData/LocalLow
local documents = Windows. -- ~/Documents
Mac
local applications = Mac. -- /Applications
Development