commit 452923751e1b6546764cf8225821caa3885dc126 Author: Markus Katharina Brechtel Date: Sat Oct 28 03:05:36 2017 +0000 fish role diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..181dbe8 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,25 @@ +--- + +- name: fish package + package: + name: fish + +- name: fish config directory + file: + path: /etc/fish/conf.d + state: directory + +- name: fish config files + template: + src: "{{ item }}.fish.j2" + dest: /etc/fish/conf.d/{{ item }}.fish + with_items: + - fish_title + - fish_prompt + +- file: + path: /etc/fish/conf.d/title.fish + state: absent +- file: + path: /etc/fish/conf.d/prompt.fish + state: absent diff --git a/templates/fish_prompt.fish.j2 b/templates/fish_prompt.fish.j2 new file mode 100644 index 0000000..515af0d --- /dev/null +++ b/templates/fish_prompt.fish.j2 @@ -0,0 +1,26 @@ +# target format: user@host:~$ +function fish_prompt --description 'prompt' + # Just calculate this once, to save a few cycles when displaying the prompt + if not set -q __fish_prompt_hostname + set -g __fish_prompt_hostname (hostname|cut -d . -f 1) + end + + set -l color_cwd + set -l suffix + switch $USER + case root toor + if set -q fish_color_cwd_root + set color_cwd $fish_color_cwd_root + else + set color_cwd $fish_color_cwd + end + set suffix '#' + case '*' + set color_cwd $fish_color_cwd + set suffix '>' + end + + set -g fish_prompt_pwd_dir_length 0 + + echo -n -s "$USER" @ "$__fish_prompt_hostname" : (set_color $color_cwd) (prompt_pwd) (set_color normal) " $suffix " +end diff --git a/templates/fish_title.fish.j2 b/templates/fish_title.fish.j2 new file mode 100644 index 0000000..3859bbf --- /dev/null +++ b/templates/fish_title.fish.j2 @@ -0,0 +1,16 @@ +function fish_title + # Just calculate this once, to save a few cycles when displaying the prompt + if not set -q __fish_prompt_hostname + set -g __fish_prompt_hostname (hostname|cut -d . -f 1) + end + + set -l suffix + switch $USER + case root toor + set suffix '#' + case '*' + set suffix '>' + end + + echo -n -s "$USER" @ "$__fish_prompt_hostname" : (prompt_pwd) " $suffix $_" +end