Skip to content

Commit

Permalink
Use new directory format in bash_it, and use bash-it enable command. …
Browse files Browse the repository at this point in the history
…Does not support disabling if missing from list.
  • Loading branch information
mmannerm committed Jun 7, 2019
1 parent 4cc1c43 commit 26ba267
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 56 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ Usage
Include the role, and specify the user you want to install the bash-it for.
Note: The role will change the default shell for the user to be `/bin/bash`.

| Variable | Default value | Description |
|-------------|---------------------------------------|----------------------------------|
| user | {{ ansible_user_id }} | User to install bash-it for |
| theme | pure | Bash-it Theme to install |
| aliases | [] | A list of aliases to install |
| plugins | [] | A list of plugins to install |
| completions | [] | A list of completions to install |
| repository | https://github.com/revans/bash-it.git | Git repository for the bash-it |
| version | master | Git version tag to retrieve |
| Variable | Default value | Description |
|-------------|----------------------------------------|----------------------------------|
| user | {{ ansible_user_id }} | User to install bash-it for |
| theme | pure | Bash-it Theme to install |
| aliases | [] | A list of aliases to install |
| plugins | [] | A list of plugins to install |
| completions | [] | A list of completions to install |
| repository | https://github.com/bash-it/bash-it.git | Git repository for the bash-it |
| version | master | Git version tag to retrieve |

Example Playbook
----------------
Expand Down
13 changes: 9 additions & 4 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
---
repository: https://github.com/revans/bash-it.git
repository: https://github.com/bash-it/bash-it.git
version: master
theme: pure
aliases: []
plugins: []
completions: []
aliases:
- general
plugins:
- base
- alias-completion
completions:
- bash-it
- system
user: "{{ ansible_user_id }}"
1 change: 1 addition & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ galaxy_info:
- bash
- osx
- shell
- macos

dependencies: []
43 changes: 15 additions & 28 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,39 +49,26 @@
- { regexp: '^export BASH_IT_THEME=', line: 'export BASH_IT_THEME={{ theme }}' }
- { regexp: '^source \$BASH_IT', line: 'source $BASH_IT/bash_it.sh' }

- name: initialize bash_it directories for {{ user }}
file:
path: "{{ user_home }}/.bash_it/{{ item }}/enabled"
state: directory
owner: "{{ user }}"
with_items:
- "plugins"
- "aliases"
- "completion"

- name: install bash_it plugins for {{ user }}
file:
src: "{{ user_home }}/.bash_it/plugins/available/{{ item }}.plugin.bash"
dest: "{{ user_home }}/.bash_it/plugins/enabled/{{ item }}.plugin.bash"
state: link
owner: "{{ user }}"
with_items: "{{ plugins }}"
command: "/bin/bash -i -l -c \"bash-it enable plugin {{ plugins|join(' ') }}\""
become: yes
become_user: "{{ user }}"
when: plugins is defined
register: plugins_result
changed_when: "plugins_result.stdout_lines | reject('match', '.* is already enabled.') | list | length > 0"

- name: install bash_it aliases for {{ user }}
file:
src: "{{ user_home }}/.bash_it/aliases/available/{{ item }}.aliases.bash"
dest: "{{ user_home }}/.bash_it/aliases/enabled/{{ item }}.aliases.bash"
state: link
owner: "{{ user }}"
with_items: "{{ aliases }}"
command: "/bin/bash -i -l -c \"bash-it enable alias {{ aliases|join(' ') }}\""
become: yes
become_user: "{{ user }}"
when: aliases is defined
register: aliases_result
changed_when: "aliases_result.stdout_lines | reject('match', '.* is already enabled.') | list | length > 0"

- name: install bash_it completions for {{ user }}
file:
src: "{{ user_home }}/.bash_it/completion/available/{{ item }}.completion.bash"
dest: "{{ user_home }}/.bash_it/completion/enabled/{{ item }}.completion.bash"
state: link
owner: "{{ user }}"
with_items: "{{ completions }}"
command: "/bin/bash -i -l -c \"bash-it enable completion {{ completions|join(' ') }}\""
become: yes
become_user: "{{ user }}"
when: completions is defined
register: completions_result
changed_when: "completions_result.stdout_lines | reject('match', '.* is already enabled.') | list | length > 0"
15 changes: 0 additions & 15 deletions test/integration/default/bash_it.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,6 @@
it { should be_directory }
end

describe file(".bash_it/completion/enabled") do
it { should exist }
it { should be_directory }
end

describe file(".bash_it/aliases/enabled") do
it { should exist }
it { should be_directory }
end

describe file(".bash_it/plugins/enabled") do
it { should exist }
it { should be_directory }
end

describe file(".bashrc") do
it { should be_file }
its(:content) { should include "export BASH_IT=" }
Expand Down

0 comments on commit 26ba267

Please sign in to comment.