My dotfile manager
git clone git://
Log | Files | Refs | Atom | README | LICENSE

commit d1af30dc84b9b5d5021bb7c8c42bc29351be70a7
parent b1ade1d6935a2b2ef92346d41bed3cb5f200c6e9
Author: GeaRSiX <>
Date:   Sat,  1 Feb 2020 17:33:25 +0000

added check in case DOTFILE isn's recognised
cleanup in Makefile

MMakefile | 1- | 97+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/ | 7++++++-
3 files changed, 103 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile @@ -8,7 +8,6 @@ none: install: install -vpDm755 src/${NAME}.py ${DESTDIR}/${NAME} - uninstall: rm -f ${DESTDIR}/${NAME} diff --git a/ b/ @@ -0,0 +1,97 @@ +# dotfm - dot file manager +a **really** simple dot file manager. + +## contents +1. [overview](#overview) +2. [usage](#usage) + 1. [cheatsheet](#cheatsheet) + 2. [details](#details) +3. [install](#install) +2. [uninstall](#uninstall) +4. [authors](#authors) + +## overview +This is a really simple python script I wrote to manage dotfiles. I had a brief look at a few and decided I'd just make my own. + +It doesn't do anything complicated, but there's an array near the top of the file (_DOTFILE_LOCATIONS_) that informs _dotfm_ where to install recognised files to. The downside to this tool is that dot files I don't use will need to be manually added to this array by yourself. I'll be adding to it overtime, but feel free to modify it yourself. + +--- + +## usage + +### cheatsheet +Keep all your dotfiles in one directory (replace $DOTFILES with this directory name): +- Install a dot file: `dotfm install $DOTFILES/.bashrc` (will **ln -s** _$DOTFILES/.bashrc_ -> _~/.bashrc_) +- Uninstall a dot file: `dotfm remove .bashrc` (will **rm**_~/.bashrc_) +- Edit a dot file: `dotfm edit .bashrc` (will open _.bashrc_ in _$EDITOR_ or _nano_) +- Install all your dotfiles: `dotfm install-all $DOTFILES` (runs **dotfm install** on all files in _$DOTFILES_) + +### details +#### _dotfm install DOTFILE_ +_DOTFILE_ should be a **path** to the **dotfile to install**. + +If the file name of _DOTFILE_ is recognised, it will make sure the directory to install the dotfile to exists and then create a symbolic link at that location to _DOTFILE_. + +If a file already exists at the install location, you'll get a prompt asking whether you want to: +- _\[o\]verwrite_ = move the existing file to __(existing file location).bak_ and continue with creating the symbolic link +- _\[c\]ompare_ = print out a _diff_ of the two files +- _\[a\]bort_ = abort the installation + +If _DOTFILE_ isn't found in _DOTFILE\_LOCATIONS_, then you'll have to manually add it. This is simple though, just go modify _src/dotfm.py_ and add an element to the array. Make sure to re-install too. + +#### _dotfm remove DOTFILE_ +_DOTFILE_ should be the **name** of the **dotfile to remove**. + +**WARNING!** This will _rm_ the file named _DOTFILE_ from it's install location (found in _DOTFILE\_LOCATIONS_). + +#### _dotfm edit DOTFILE_ +_DOTFILE_ should be the **name** of the **dotfile to edit**. + +This will open the _DOTFILE_ in the editor named in your environment variables as _EDITOR_. If _EDITOR_ is not available as an environment varialbe, then it will open it in _nano_. + +The file opened is located at the matching install location found in _DOTFILE\_LOCATIONS_. + +#### _dotfm install-all DOTFILE_ +_DOTFILE_ should be a **directory path** containing all the **dotfiles to install** + +This will recursively run _dotfm install DOTFILE_ on each file found in the specified directory. + +### help + +``` +usage: dotfm [-h] [-d] [-v] COMMAND DOTFILE + +a simple tool to help you manage your dot files, see "man dotfm" for more + +positional arguments: + COMMAND the dotfm COMMAND to execute: ['install', 'remove', 'edit', + 'install-all'] + DOTFILE name of the dotfile dotfm will execute COMMAND on, for + "install" this must be a path to the dotfile to install + +optional arguments: + -h, --help show this help message and exit + -d, --debug display debug logs + -v, --version show program's version number and exit +``` + +--- + +## installing dotfm +Just run `sudo make install` + +### install location +By default this will install the python script to _/usr/bin/dotfm_. +To change this, just modify _Makefile_ and change the value of _DESTDIR_ to your preferred install location. + +--- + +## uninstall dotfm +Just run `sudo make uninstall` + +--- + +## authors +- GeaRSiX <> + +--- diff --git a/src/ b/src/ @@ -45,7 +45,6 @@ SOURCE_DOTFILES = [ # dotfiles that need to be "source"-ed a #----------- def error_exit(message): LOGGER.error(message) - print('ERROR!\t| {}'.format(message)) sys.exit() def parse_arguments(): @@ -74,9 +73,11 @@ def validate_dotfiledir_path(dirname, dotfiledir_path): def dotfm_install(dotfile):'installing {}...'.format(dotfile)) + found = False for dfl in DOTFILE_LOCATIONS: name = dfl[0] if os.path.basename(dotfile) == name: + found = True dest = os.path.abspath(os.path.dirname(dfl[1])) # make sure path exists if not os.path.exists(dest): @@ -110,6 +111,10 @@ def dotfm_install(dotfile): if name in SOURCE_DOTFILES: os.system('source {}/{}'.format(dest, name)) + # check for unrecognised dotfile + if found == False: + error_exit('dotfile basename not recognised ({})!\nmake sure that the dotfile name and location to install to exist in \"DOTFILE_LOCATIONS\" (see src/'.format(os.path.basename(dotfile))) + def dotfm_installall(dotfile_dir):'installing all dotfiles in {}'.format(dotfile))