Defined Type: ohmyzsh::plugins

Defined in:
manifests/plugins.pp

Overview

Define: ohmyzsh::plugins

This is the ohmyzsh module. It installs oh-my-zsh for a user and changes their shell to zsh. It has been tested under Ubuntu.

This module is called ohmyzsh as Puppet does not support hyphens in module names.

oh-my-zsh is a community-driven framework for managing your zsh configuration.

Parameters

plugins: (string) space separated list of tmux plugins

Authors

Leon Brocard <acme@astray.com> Zan Loy <zan.loy@gmail.com>

Copyright 2014

Parameters:

  • plugins (Array[String]) (defaults to: ['git'])
  • custom_plugins (Hash[String, Struct[ { source => Enum[git], url => Stdlib::Httpsurl, ensure => Enum[present, latest], revision => Optional[String], depth => Optional[Integer] } ] ]) (defaults to: {})


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'manifests/plugins.pp', line 24

define ohmyzsh::plugins (
  Array[String] $plugins        = ['git'],
  Hash[String,
    Struct[
      {
        source   => Enum[git],
        url      => Stdlib::Httpsurl,
        ensure   => Enum[present, latest],
        revision => Optional[String],
        depth    => Optional[Integer]
      }
    ]
  ]             $custom_plugins = {},
) {
  include ohmyzsh

  if $name == 'root' {
    $home = '/root'
    $group = fact('os.family') ? {
      /(Free|Open)BSD/ => 'wheel',
      default          => 'root',
    }
  } else {
    $home = "${ohmyzsh::home}/${name}"
    $group = $name
  }

  $custom_plugins_path = "${home}/.oh-my-zsh/custom/plugins"

  $custom_plugins.each |$key, $plugin| {
    vcsrepo { "${custom_plugins_path}/${key}":
      ensure   => $plugin[ensure],
      provider => $plugin[source],
      source   => $plugin[url],
      depth    => $plugin[depth],
      revision => $plugin[revision],
      require  => ::Ohmyzsh::Install[$name],
    }
  }

  $all_plugins = union($plugins, keys($custom_plugins))

  $plugins_real = join($all_plugins, ' ')

  file_line { "${name}-${plugins_real}-install":
    path    => "${home}/.zshrc",
    line    => "plugins=(${plugins_real})",
    match   => '^plugins=',
    require => Ohmyzsh::Install[$name],
  }
}