Code Monkey home page Code Monkey logo

chezmoi's Introduction

Project Description
Tools
chezmoi Manage your dotfiles across multiple diverse machines, securely.
find-duplicates Find duplicate files quickly.
find-typos Find typos.
flatjson Convert JSON files to a "flat" representation with one value per line.
Go tools
go-jsonstruct Generate Go structs from multiple JSON objects.
go-xmlstruct Generate Go structs from multiple XML documents.
Geospatial tools
osm-extract Extract features from OpenStreetMap PBF files as GeoJSON.
igc2kmz IGC to Google Earth converter.
Geospatial libraries
go-geobabel Package geobabel converts geometry types between popular geometry libraries.
go-geom Package geom implements efficient geometry types for geospatial applications.
go-geos Package geos provides an interface to GEOS.
go-gpx Package gpx provides convenience types for reading and writing GPX files.
go-kml Package kml provides convenience methods for creating and writing KML documents.
go-mbtiles Package mbtiles reads and writes files in the MBTiles format.
go-openaip Package openaip decodes OpenAIP airspace files.
go-polyline Package polyline implements a Google Maps Encoding Polyline encoder and decoder.
go-proj Package proj provides an interface to proj.org.
go-shapefile Package shapefile provides a native Go reader for ESRI Shapefiles.
go-waypoint Package waypoint reads and writes waypoints in formats used by the free flying community.
go-xctrack Package xctrack implements XCTrack's task format.
pgx-geom Package pgx-geom provides PostGIS support for github.com/jackc/pgx/v5 via go-geom.
pgx-geos Package pgx-geos provides PostGIS and GEOS support for github.com/jackc/pgx/v5 via go-geos.
Go libraries
go-nmea Package nmea parses NMEA sentences.
go-pinentry Package pinentry provides a client to GnuPG's pinentry.
go-shell Package shell returns the user's shell across multiple platforms.
go-vfs Package vfs provides an abstraction of the os and io packages that is easy to test.
go-xdg Package xdg provides support for the XDG Base Directory Specification.
Editor plugins
vim-igc VIM syntax highlighting for IGC files.
vim-testscript VIM syntax highlighting for testscript.
vscode-testcript testscript support for Visual Studio Code.

chezmoi's People

Contributors

alerque avatar alexandear avatar arran4 avatar benmezger avatar bradenhilton avatar catay avatar davewongillies avatar dependabot[bot] avatar dpprdan avatar eugenesvk avatar felipecrs avatar fgrosse avatar garyng avatar grimler91 avatar halostatue avatar justingrote avatar kkirsche avatar ktetzlaff avatar mirzazulfan avatar muxiu1997 avatar pdemonaco avatar ptxmac avatar pvinis avatar ruijieyu avatar schrej avatar sitiom avatar stephengroat avatar thelocehiliosan avatar twpayne avatar zb140 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chezmoi's Issues

Cannot add file from subdirectory

I am getting outside target directory error. I tried different formats:

  • ./chezmoi add .config/micro/settings.json
  • ./chezmoi add pwd/.config/micro/settings.json
  • ./chezmoi add /home/jenkins/.config/micro/settings.json
  • ./chezmoi add ~/.config/micro/settings.json
./chezmoi add  /home/jenkins/.config/micro/settings.json
Error: .config/micro: outside target directory
Usage:
  chezmoi add [flags]

Flags:
  -h, --help        help for add
  -r, --recursive   recurse in to subdirectories
  -T, --template    add files as templates

Global Flags:
  -c, --config string       config file (default "/home/jenkins/.chezmoi.yaml")
  -n, --dry-run             dry run
  -s, --source string       source directory (default "/home/jenkins/.chezmoi")
      --source-vcs string   source version control system command (default "git")
  -t, --target string       target directory (default "/home/jenkins")
  -u, --umask int           umask (default 18)
  -v, --verbose             verbose

Extend the verify command to take a list of targets

Currently the verify command verifies all targets. It would be nice if the verify command could take a list of targets to verify for example:

$ chezmoi verify ~/.bashrc

If the list of targets is empty, it should default to all targets.

Add way of ignoring files in source directory

People who publish their dotfiles (e.g. github.com/twpayne/dotfiles) might want to add a README.md or LICENCE or similar to their repo, without wanting these files copied into their home directory.

Suggestion: support .chezmoiignore file that works similarly to .gitignore: any files listed should be ignored by chezmoi.

Hide / display commands based on availability

Today, with the introduction of support for Hashicorp Vault, it is possible for a command to not necessarily exist. Instead of relying on an error scenario when executing the command to try to locate it, for example:

 ~ $ chezmoi vault
chezmoi: exec: "vault": executable file not found in $PATH

Instead of relying solely on this, what's your opinion of instead looking to see if the command is a known command in the path and displaying or not including the command based on that, using exec.LookPath like so:

func init() {
	config.Vault.Vault = "vault"
	config.addFunc("vault", config.vaultFunc)
        
        _, err := exec.LookPath(config.Vault.Vault); if err == nil {
	    rootCommand.AddCommand(vaultCommand)
         }
}

An example application to demonstrate this:

package main

import (
        "fmt"
        "os/exec"
)

func main() {
        p, err := exec.LookPath("ls")
        if err == nil {
                fmt.Printf("ls is installed at %s\n", p)
        } else {
                fmt.Println("ls is not installed")
        }

        p, err = exec.LookPath("vault")
        if err == nil {
                fmt.Printf("vault is installed at %s\n", p)
        } else {
                fmt.Println("vault is not installed")
        }
}

and the output on a machine with ls but not vault is:

$ go run example.go
ls is installed at /bin/ls
vault is not installed

KeePassX integration

KeePassX is a popular password manager. chezmoi could use this to store secrets, instead of storing them in ~/.chezmoi.yaml.

This could possibly be exposed through a template function.

Linux: distribution detection

My example use case is I have bash functions that manipulate the distro package manager and it would be nice if chezmoi could ifdef them by distro. Something like:

{{- if eq .chezmoi.distribution "ubuntu" }}
function install-package { apt install $1 ; }
{{- end }}

{{- if eq .chezmoi.distribution "arch" }}
function install-package { pacman -S $1 ; }
{{- end }}

{{- if eq .chezmoi.distribution "fedora" }}
function install-package { dnf install $1 ; }
{{- end }}

distribution would be automagically determined by the ID field in /etc/os-release, which is standard and present on all Linux distributions.

“chezmoi add” should create ~/.chezmoi

 % chezmoi add ~/.zshrc
Error: rename /tmp/.dot_zshrc208154389 /home/michael/.chezmoi/dot_zshrc: no such file or directory
Usage:
  chezmoi add [flags]

Flags:
  -e, --empty       add empty files
  -h, --help        help for add
  -r, --recursive   recurse in to subdirectories
  -T, --template    add files as templates

Global Flags:
  -c, --config string       config file (default "/home/michael/.chezmoi.yaml")
  -n, --dry-run             dry run
  -s, --source string       source directory (default "/home/michael/.chezmoi")
      --source-vcs string   source version control system command (default "git")
  -t, --target string       target directory (default "/home/michael")
  -u, --umask int           umask (default 2)
  -v, --verbose             verbose

2018/11/22 16:29:15 rename /tmp/.dot_zshrc208154389 /home/michael/.chezmoi/dot_zshrc: no such file or directory

After creating the directory with install -d -m 0700 .chezmoi, the command works as expected. But, to make setup easier, I think the command should create the directory for me :)

Handle directory symlinks

I was impressed that chezmoi handled symlinked files placed by my previous dotfile manager. But it seems to have trouble with directory symlinks:

$ ls -l ~/.config/omf
lrwxrwxrwx 1 james users 25 Nov 10 16:16 /home/james/.config/omf -> /home/james/.dotfiles/omf

$ ls -ld ~/.dotfiles/omf
drwxr-xr-x 3 james users 4096 Nov 12 22:27 /home/james/.dotfiles/omf

$ chezmoi add -r ~/.config/omf
Error: .config/omf: not a regular file or directory
Usage:
...
2018/11/24 11:28:51 .config/omf: not a regular file or directory

$ chezmoi add -r ~/.config/omf/
Error: .config/omf: not a regular file or directory
Usage:
...
2018/11/24 11:28:53 .config/omf: not a regular file or directory

Extend apply command to take a list of targets

Currently the apply command updates all targets. It would be nice if the apply command could take a list of targets to update, for example:

$ chezmoi apply ~/.bashrc

If the list of targets is empty, it should default to all targets.

Remove backwards compatibility code

chezmoi checks for config files in pre-XDG locations, notably ~/.chezmoi.{toml,yaml,..} and ~/.chezmoi. This backwards compatibility code should be removed for the v1.0.0 release.

Activate shell autocompletion

chezmoi uses Cobra for command line parsing, which can also generate autocompletion code. We should use this to generate bash and zsh autocompletion code.

Allow immediate application of edits

It would be nice to optionally have edits applied immediately.

Not sure what the best implementation would be, but some ideas:

  • chezmoi edit --apply
  • a franken-command like chezmoi eda (edit->diff->apply) that potentially prompts "Apply Y/n?" after printing the diff?

Handle "exact" directories

Currently chezmoi will only add or replace files in the target directory. It will never remove them. This can lead to the accumulation of stale files.

chezmoi should add support for "exact" directories where the directory contents should match exactly what is specified in ~/.chezmoi. Specifically, any files or directories that exist in the target but not in the source should be removed.

This is broadly equivalent to Puppet's file's purge attribute.

Add long help for each command

Currently commands a loosely documented in README.md, or not at all. Each command should have long documentation as well.

toml support?

Cool project, may try it out this weekend.

Any thoughts on supporting toml for the data file? It's already an indirect import. YAML is pretty terrible, and considered harmful by many.

Keychain integration on macOS

Keychain on macOS is used to store secrets. chezmoi could use this, instead of storing secrets in ~/.chezmoi.yaml.

This could possibly be exposed through a template function.

Improve autotemplate algorithm

chezmoi uses text/template as its templating language. For an example of text/template in action, see https://play.golang.org/p/lzBUhUAEWXk.

text/template.Template.Execute takes as input a template and some data and outputs the template with data substituted. For chezmoi's autotemplate function, we want to reverse this process. Specifically:

Given some output string and some data map[string]string, determine the optimal templateStr string such that executing the template returned by template.New("").Parse(templateStr) with data results in output.

Requirements:

  • Direct substitution should work, e.g. given [email protected] and data := map[string]string{"email": "[email protected]"} the resulting template should be output={{ .email }}.
  • Longest matches should win, e.g. given name=John Smith and data := map[string]string{"firstName":"John", "fullName":"John Smith"} the output should be name={{ .fullName }}, not name={{ .firstName}} Smith.
  • If multiple template variables have the same value, then the alphabetically first should win, e.g. given name=foo and data := map[string]string{"a": "foo", "b": "foo"} the output should be name={{ .a }}, not name={{ .b }}.
  • Substitution should not occur within words, e.g. given os=darwinian evolution and input "data := map[string]string{"os": "darwin"} the output should be os=darwinian evolution, not os={{ .os }}ian evolution.
  • Substitution should be flexible on word boundaries, e.g. given output /home/user and data := map[string]string{"h": "/home/user", "u": "user"} the output should be {{ .h }} and not /home/{{ .u }}.

There's an existing algorithm and existing tests, but the algorithm is slow (maybe O(N^2) at best) and the tests are incomplete.

Points for:

  • Adding tests that demonstrate where the current algorithm fails.
  • Writing code that passes these tests.
  • Achieving better time and space complexity.
  • Achieving better runtime.
  • Supporting Unicode ([]rune), not strings ([]byte).

Add a mechanism for adding host-specific files

Currently chezmoi will populate all files. It is likely that some files will only be required on certain machines. For example, you may need ~/company.conf on your work machine, but this file should not exist on your home machine. At the moment, you can make ~/company.conf empty on your home machine using a template:

{{- if .chezmoi.hostname eq "work-laptop" }}
# contents of company.conf
{{- end -}}

but this will still result in an empty file on other machines. We need a mechanism to only populate files that should be present.

For config files. an empty file is more-or-less equivalent to an absent file. Perhaps we can use this.

Improve Windows support

chezmoi is currently targeted at macOS/Linux, but there is no reason why it shouldn't also run on Windows. Contributions improving Windows support are very welcome.

chezmoi cd fails without config file

chezmoi cd fails without config file:

> chezmoi cd
open /usr/local/google/home/jhillyerd/.config/chezmoi/chezmoi.yaml: no such file or directory

chezmoi version fails with same error

version bdecf50 (HEAD -> master, tag: v0.0.8, origin/master, origin/HEAD)

chattr rename fails when file is in private directory

$ chezmoi chattr +template ~/.ssh/authorized_keys
chezmoi: rename /home/twp/.local/share/chezmoi/private_dot_ssh/authorized_keys /home/twp/.local/share/chezmoi/dot_ssh/authorized_keys.tmpl: no such file or directory

Add a command to change the private and executable attributes of existing sources

Currently the "private" and "executable" attributes can only be changed by manually renaming the files in the source directory. For example, to make .netrc private, you have to do:

$ mv ~/.chezmoi/dot_netrc ~/.chezmoi/private_dot_netrc

It would be a nice to have a chezmoi command that updates the source file name appropriately. For example:

$ chezmoi chmod 0600 ~/.netrc

should do the rename above. Similarly for the executable bit.

Extend diff command to take a list of targets

Currently the diff command diffs all targets. It would be nice if the diff command could take a list of targets to diff, for example:

$ chezmoi diff ~/.bashrc

If the list of targets is empty, it should default to all targets.

unknown groupid

Hi,
I just tried your program to synchronize my configuration files, however on my linux desktop I get the following error for any command:

Error: group: unknown groupid 210

How can I fix this?

Template homedir recognition fails

running chezmoi add -T file, where file contains /Users/name/... results in /Users/{{ .chezmoi.username }}/... instead of {{ .chezmoi.homedir }}/....

Unknown groupid issue on OS X

I'm running chezmoi 1.0.0 (via homebrew) on MacOS X 10.14.2. When I try to add a file, I get this error:

chezmoi: group: unknown groupid 1493692218

Our machines are joined to an AD domain. I looked at issue #65 and #72, however it looks like this may only resolve the issue on Linux.

Anything I can do to assist, please let me know. Thanks!

diff should output to stdout

chezmoi diff |less doesn't work, as the diffs are output to stderr

I'd also argue the log date stamps are not helpful, and make the diff harder to read.

Add version check

As chezmoi gathers features, source directories might depend on features that are not present in older versions of chezmoi. chezmoi should include a way to specify the minimum version of chezmoi for the source directory to apply correctly, and issue an error or warning when the current version of chezmoi is too old.

Document template functions

As the number of supported password managers increases, the tutorial documentation in README.md is becoming increasingly repetitive and verbose.

There should be a reference document of all the template functions for password managers, i,e. bitwarden, lastpass, pass, vault, and (soon) onepassword.

Make targets on the command line absolute paths

Currently all target names are assumed relative to the target directory.

It would be nice if targets could be absolute or relative paths so that the user can use their shell autocompletion. For example,

$ chezmoi add ~/.bashrc

should work. In the case that the user is already in their home directory then relative paths should work, e.g.

$ chezmoi add .bashrc

Add plugin mechanism

chezmoi currently has support for storing secrets in LastPass, macOS Keychain, GNOME Keyring, and Windows Credential Manager. It is likely that individual companies will have their own mechanisms for storing secrets, and will not want to contribute code upstream to chezmoi to support them.

To make chezmoi useful in these environments, chezmoi should have a plugin mechanism, likely using Go Plugins.

As a rough initial sketch, it should be something like:

Config file includes a list of full paths to plugins:

plugins:
  - /usr/local/lib/chezmoi-initech.so

/usr/local/lib/chezmoi-initech.so is a Go Plugin that exports two functions:

Name() string returns the name of the plugin, e.g. "initech".

FuncMap() template.FuncMap returns a map of template functions which are added to the global namespace. An example function might be initechGetUserToken which takes a username and returns some user-specific token.

chezmoi should add a template function "plugin " which returns true if the plugin with the name <name> is loaded.

With this, internal, company-specific configuration code would look something like:

{{ if (plugin "initech.com") }}
initechToken = {{ initechGetUserToken .chezmoi.username }}
{{ end }}

On startup, chezmoi should load all plugins and add their functions to the global list of template functions.

Add import command

It's occasionally useful to unpack a tarball in to your home directory, for example to add a vim or zsh plugin.

chezmoi should have an import command that takes a tarball and unpacks it into the source directory, doing any necessary renames.

Example usage:

$ wget https://github.com/robbyrussell/oh-my-zsh/archive/master.tar.gz
$ chezmoi import --strip-components=1 master.tar.gz ~/.oh-my-zsh

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.