So picture this, you have just bought a brand new MacBook Pro with Retina Display. You boot that baby up, and proceed to set it up to just the way you like it.
Finally, you have acquired all your apps and media but what about your dotfiles? Don’t worry, it’s easy with pydfmt!
This is very easy
$ pip install pydfmt
That’s it. pydfmt is now installed on your system! providing there were no errors.
Now you need some dotfiles to sync. They may already be on your system, but if you are setting up a new system then you will have to get them in your £HOME directory. I keep all my dotfiles as a git repository so I will show you how I setup my dotfiles on new systems.
To install your dotfiles on a new system:
$ git clone https://github.com/samjones/dotfiles .files
You are more than welcome to use my dotfiles if you like but I recommend
cloning your own dotfiles repo.
This will create a folder in the $PWD named .files/. This folder will contain many files for example
$ ls -a .files
. .dfmtrc .gitconfig .global_ignore
.. .git .gitignore .vimrc
Those files are what allow the user to customise their shell environment. Now that you have a .files/ folder with dotfiles in it, you will want pydfmt to link those to your $HOME directory in order for them to work.
To do this, simply run:
$ pydfmt --sync
Congrats!
This now means that all the dotfiles contained in the .files/ folder, have been symlinked to the $HOME directory allowing them to work.
Sometimes you may acquire a dotfile. You can then add it to your .files folder to continue to keep all of your dotfiles organised.
To add ~/.zshrc to your .files folder:
$ pydfmt -a .zshrc
or
$ pydfmt --add .zshrc
Once you have added a file, it is good practise to sync your .files folder just to make sure nothing is conflicting or damaged
$ pydfmt -s
The remove command of pydfmt is a bit ambiguous. It does not remove a file from your .files folder. It removes the symlink. This means that ~/.files.zshrc will no longer point to $HOME.
Maybe I should change the command to unsync. What do you think? Let me know!
Anyway, to remove a file:
$ pydfmt -r .vimrc
or
$ pydfmt --remove .vimrc
Removing several files:
$ pydfmt -r .zshrc .vimrc
By default pydfmt will look for ~/.files. If that file is there and it contains dotfiles, you can sync them. If that folder is not there, pydfmt will shout at you with instructions.
pydfmt accepts configuration from a file in your $HOME directory called .dfmtrc. This is not automatically created so if you want or need to configure anything you need to create it:
$ touch .dfmtrc
Then edit it, using your $EDITOR!:
$ vim .dfmtrc
[dfmt]
repository = ~/dev/dotfiles
ignore = [
'.git',
'.gitignore',
'.swp']
externals = {
'.pip': '/dev/null'}
Now that you have a .dfmtrc whenever you sync or add files, your options will be taken into accout, ignoring to add any files or folders that you have specified.
Meh ok. You don’t have to use .dfmtrc. It can be named anything. I would recommend using the default .dfmtrc but if you must you can use
dfmt.conf
If you choose not to name your config file .dfmtrc then you will need to point pydfmt to your config file in order for it to work. This is done with the -C flag.
$ pydfmt -a .zshrc -C ~/bin/dfmt.conf
As the code example above also shows, the config file does not have to be in the $HOME directory but you will have to use the -C flag to point to it. (Just making myself clear)
note the contents of your config file must conform to pydfmt standards. See example .dftmrc above. If in doubt, get in touch!
By default, pydfmt will keep the prepended . on all dotfiles when they are added to your .files folder. However, I have seen that some users like to prepend their dotfiles with _.. This can be done by using the -p flag
$ pydfmt -a .zshalias -p _.
This will appear as _.zshalias in the .files/ directory.
You can also add:
prefix = _.
To your .dfmtrc which means that you do not have to use the -p flag to specify the prefix. All you have to do is add the files and they will automatically be prepended with whatever you have put in your .dfmtrc.
Use pydfmt --help to see all available options.