Skip to content

Configuration

Snipkit requires a configuration file to be present. The configuration file resides in the snipkit home directory.

Home directory

The path to the home directory is assumed to be {$XDG_CONFIG_HOME}/snipkit. The value of XDG_CONFIG_HOME is specified by the XDG Base Directory Specification. If not set explicitly, a sensible default value for your operating system is assumed:

  • macOS: ~/Library/Application Support/snipkit
  • Linux: ~/.config/snipkit

You can specify another directory to be used by SnipKit be setting the environment variable SNIPKIT_HOME. E.g., you may want to put the following into your ~/.zshrc file:

export SNIPKIT_HOME=~/.snipkit

Initialization

In order to create a config file for SnipKit, execute:

snipkit config init

This command creates a config file in the SnipKit home directory. The initial config file looks similar to this:

config.yaml
version: 1.1.0
config:
  style:
    # The theme defines the terminal colors used by Snipkit.
    # Available themes:default,dracula.
    theme: default
  # Your preferred editor to open the config file when typing 'snipkit config edit'.
  editor: "" # Defaults to a reasonable value for your operation system when empty.
  # The command which should run if you don't provide any subcommand.
  defaultRootCommand: "" # If not set, the help text will be shown.

No snippet manager has been added at this time. In order to add a one execute:

snipkit manager add

For more information on the different managers supported, please see Managers.

Config options

Editor

When typing snipkit config edit the configuration file will be opened in an editor of your choice.

The default editor is defined by the $VISUAL or $EDITOR environment variables. This behavior can be overwritten by setting the editor field in the configuration file to a non-empty string, e.g.:

config.yaml
version: 1.1.0
config:
  editor: "code"

If no value is provided at all, SnipKit will try to use vim.

Default Root Command

Most of the time, you want to call the same subcommand, e.g. print or exec. You can configure snipkit so that this command gets executed by default:

config.yaml
version: 1.1.0
config:
  defaultRootCommand: "exec"

This way, calling snipkit will yield the same result as snipkit exec. If you want to call the print command instead, you can still call snipkit print.

Style

Theme

SnipKit supports multiple themes out of the box and also allows you to define your own themes:

config.yaml
version: 1.1.0
config:
  style:
    theme: "default"

If the theme is not shipped with snipkit, it will try to look up a custom theme. If the theme is named <xx>, the theme file must be located at <SNIPKIT_HOME>/<xxx>.yaml.

For a list of supported default themes, have a look at the Themes page.

Hide Keymap

By default, a help for the key mapping is displayed at the bottom of the screen. To save same screen space, this can be disabled:

config.yaml
version: 1.1.0
config:
  style:
    hideKeyMap: true

Script Options

Shell

The shell for script executions is defined by the $SHELL environment variable. This behavior can be overwritten by setting the shell option to a non-empty string, e.g.:

config.yaml
version: 1.1.0 
config:
  script:
    shell: "/bin/zsh"

If neither $SHELL nor the config option shell is defined, SnipKit will try to use /bin/bash as a fallback value.

Parameter mode

How values are injected into your snippet for the defined parameters is defined by the parameterMode option:

config.yaml
version: 1.1.0
config:
  script:
    parameterMode: SET

The default value is SET, defining that values should be set as variables. This means that the following script

Raw snippet before execution
# ${VAR} Description: What to print
echo ${VAR}

will be updated in the following way, e.g. for VAR = "Hello word":

Example for parameterMode SET
# ${VAR} Description: What to print
VAR="Hello world"
echo ${VAR}

Alternatively, all occurrences of a parameter can be replaced with the actual value when specifying REPLACE for parameterMode:

Example for parameterMode = REPLACE
echo "Hello world"

Remove Comments

SnipKit will remove all parameter comments from a snippet when specifying removeComments:

config.yaml
version: 1.1.0
config:
  script:
    removeComments: true

This means that the following script

Raw snippet before execution
# ${VAR} Description: What to print
echo ${VAR}

will be formatted in the following way:

Example for removeComments = true
echo ${VAR}

Info

Comments will always be removed if parameterMode is set to REPLACE.

Clean up

The config file as well as all custom themes can be deleted with:

snipkit config clean

The cleanup method is a way to remove all SnipKit artifacts from your hard drive. It only deletes contents of the SnipKit home directory. If this directory is empty at the end of the cleanup process, it will be deleted as well.