DEV Community

Alexey Melezhik
Alexey Melezhik

Posted on

Sparrow as a reasonable alternative to dotfiles

Almost every month or oftener I can see posts on dev.to and other sites on how people manage their bashrc/dot files using git and bash.

It's ok to use those tools to manage your servers configuration, but let me show your more flexible and powerful way.

Sparrow is a tool to effectively manage and port servers configurations.

The approach consists of following steps:

  • Define pieces of configurations as sparrow tasks

  • Save tasks as plain old files in local directory

  • Push files to remote git repository

  • On target server clone tasks through git clone from remote git repository

  • Finally run tasks to apply desired configurations

It might seem extra steps here in comparison with git push / git pull approach but gives your flexibility and power.

  • Complex configurations get split to tiny bits which are easier to manage.

  • Because sparrow tasks are not just configuration, it's possible to run extra steps required to configure your server ( install packages and so on )

Let's see this in action

For simplicity I confine my post to 2 simple use cases.

  • Configuring nano editor ( some basic settings )
  • Configuring git global settings ( name and email )

Sparrow comes with a lot of plugins, so you don't need to code anything, just use existed ones:

$ sparrow index update # get the latest updates of sparrow repository
$ sparrow plg install nano-rc
$ sparrow plg install git-base

Enter fullscreen mode Exit fullscreen mode

Now having installed plugins let's create a couple of tasks to reflect desired settings.

For git setup:

$ sparrow project create git
$ sparrow task add git setup git-base
$ sparrow task ini git/setup


install_git: on 
email: melezhik@gmail.com
name: Alexey Melezhik

Enter fullscreen mode Exit fullscreen mode

For nano configuration file:

$ sparrow plg install nano-setup
$ sparrow task add nano rc nano-setup
$ sparrow task ini nano/rc

tabsize: 2
speller: hunspell -x -c

Enter fullscreen mode Exit fullscreen mode

If we list our current task now we could see them here:

sparrow root: [/home/suslik/sparrow]
[sparrow task list]
 [utils]
  git/setup
  nano/rc

Enter fullscreen mode Exit fullscreen mode

Save tasks to the git repository

The rest of workflow is similar to saving dotfile to GitHub repository. We will use sparrow task save command to save tasks to directory and then push files to git:

$ mkdir tasks

$ git init .

$ git remote add origin https://github.com/user/tasks.git

$ sparrow task save $PWD

$ git add . && git commit -a -m "my sparrow tasks" && git push

Enter fullscreen mode Exit fullscreen mode

Restore tasks from git repository

Once tasks are saved to git repository we can install them on any server:

$ git clone https://github.com/user/tasks.git my-tasks

$ sparrow task restore my-tasks

Enter fullscreen mode Exit fullscreen mode

We are all set. To start using our task just run:

$ sparrow task run git/setup # set up my git client
$ sparrow task run nano/rc # configure nano editor
Enter fullscreen mode Exit fullscreen mode

Finally here is my tasks repository - take a look at it as an example.


Thank you for reading.

Top comments (0)