Settings

There is a global variable Settings under which all settings are contained. They are typically organized by package name, although there are a few root-level settings. Each package can define settings, and you can edit the settings of any package.

We have included a shorthand notation where Settings.somePackage = {...} will do a "deep merge", merging the new values with the existing values.

Editing settings

You can edit any package's settings from your own settings.coffee file or from any other user-code (.coffee or .js) file:

Settings.somePackage = {
  someSetting: ['arrays', 'will', 'merge'],
  otherSetting: {
    objects: {
      will: 'deep merge too'
    }
  },
  booleanSetting: false
}

If you want to delete a certain setting

delete Settings.somePackage.someSetting

Tip

If a package name has a space or dash in its name it needs to be accessed using bracket-notation instead of dot-notation, since javascript variable names can only contain alphanumeric characters and underscores:

Settings['some package with a space']

Using existing settings

If you need to access a setting in order for your code to make a decision, you can directly access any setting from any package using Settings.packageName.settingName such as:

if (Settings.dragon_darwin.version === 5) {
  // do something
} else {
  // do something else
}

Inspecting existing settings

If you want to poke around with your live instance of VoiceCode, and all its runtime settings:

  • start up the VoiceCode CLI
  • type Settings.somePackage
  • hit 'Return' and you will see the current values for that package's settings
  • If you want to drill down to a specific setting, type Settings.somePackage.someSetting
  • If you want to see the entire Settings object, just type Settings

Settings examples:

The main ~/voicecode/settings.coffee is where most basic settings should be placed:

# ~/voicecode/settings.coffee
_.extend Settings,
    license: ''
    email: ''
    core:
      slaves:
        development: ["localhost", 31337]
    darwin:
      applicationsThatNeedExplicitModifierPresses: [
        'Screen Sharing'
      ]
    os:
      applicationsThatCanNotHandleBlankSelections: [
        'Mancy'
        'LightTable'
      ]
    'strict-mode':
      modes:
        default: ['scrolling:up', 'scrolling:down']

VoiceCode lets you create any directory structure you want for your settings and commands. We recommend creating a directory at ~/voicecode/settings under which you could put all your different settings files.

For any specific package settings that might have a long list of options (i.e. websites, abbreviations, etc.) we recommend creating a file just for that package. This is so that your main settings file does not get really long and unwieldy, makes it easier to find the file/setting you are looking for. You can use JavaScript or CoffeeScript, Here's some examples:

// ~/voicecode/settings/vocabulary.js
Settings.vocabulary = {
  vocabulary: [ // teach dragon new words
    'redux',
    'node js',
    'node.js',
    'npm install',
    'npm',
    'coffeescript'
  ],
  vocabularyAlternate: { // text replacement on dragon side
    'a sink': 'async'
  },
  translations: { // text replacement on VoiceCode side
    'consul': 'console'
  },
  sequences: { // common sequences of commands (to boost accuracy)
    'symbols:slash': [
      'repetition:command-2', // reinforcing 🔉slash soup🔉  for javascript comments
      'bin', // reinforce the phrase 🔉slash bin🔉 => `/bin`
    ] 
  }
}
# ~/voicecode/settings/web.coffee
Settings.web =
  websites:
    "atom": "https://atom.io"
    "facebook": "https://www.facebook.com/"
    "digital ocean": "https://www.digitalocean.com"
# ~/voicecode/settings/insert.coffee
Settings.insert =
  emails:
    voicecode: "[email protected]"
    gmail: "[email protected]"
  usernames:
    instagram: "bcoolinsta"
  abbreviations:
    administrator: "admin"
    administrators: "admins"
    allocate: "alloc"
    alternate: "alt"
  passwords:
    gmail: "password123"
    microsoft: "123password"
    amazon: "pass123word"

Add some more applications, and some single word app shortcuts

# ~/voicecode/settings/application.coffee
Settings.application =
  applications:
    'vox': 'VOX'
    'table' : 'LightTable' ,
    'fusion' : 'VMware Fusion' ,
    'torrent' : 'Transmission',
    'spotify' : 'Spotify'
    'vlc' : 'VLC'
    'finder' : 'Path Finder'
    'notes' : 'Notes'
    'telegram': 'Telegram'
    'hub': 'MongoHub'
    'slack': 'Slack'
  firstNameBasis:
    chromie: "Google Chrome"
    termite: "iTerm"
    atom: "Atom"
    canary: 'Google Chrome Canary'
    telegram: 'Telegram'
    finder: 'Path Finder'
    vivi: 'Vivaldi'
    foxy: 'FirefoxDeveloperEdition'

Add some more directories

# ~/voicecode/settings/os.coffee
Settings.os =
  directories:
    code: "~/code"
    projects: "~/Documents/projects"
    voicecode: "~/voicecode"
    "voicecode settings": "~/voicecode/settings"

Add some more shell commands

# ~/voicecode/settings/command-line.coffee
Settings['command-line'] =
  shellCommands: 
    "atom publish": "apm publish minor"
    "push and deploy": "git push\n modulus deploy\n"
    "soft link": "ln -s "

Will boost recognition of certain words by creating a dragon command, but still process the word as plain dictation on VoiceCode side

# ~/voicecode/settings/words.coffee
Settings.words =
  words: [
    "meteor"
    "print"
    "yep"
    "hey"
    "gulp"
    "let"
  ]

Add some editor code snippet completions

# ~/voicecode/settings/editor.coffee
Settings.editor =
  codeSnippetTriggers: [
    if: "if"
    "if else": "ife"
  ]

results matching ""

    No results matching ""