From a822fe091535fe57a69ff3ea70ecfb9c0b53cf53 Mon Sep 17 00:00:00 2001 From: Ethan Paul Date: Fri, 20 May 2022 16:55:44 -0400 Subject: [PATCH] Add completions integration to workstation env --- skylab/core/roles/workstation/files/bashrc.sh | 5 +++-- .../roles/workstation/tasks/environment.yml | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/skylab/core/roles/workstation/files/bashrc.sh b/skylab/core/roles/workstation/files/bashrc.sh index 75ecc00..1282866 100644 --- a/skylab/core/roles/workstation/files/bashrc.sh +++ b/skylab/core/roles/workstation/files/bashrc.sh @@ -6,10 +6,11 @@ if [ -f `which powerline-daemon` ]; then fi export NVM_DIR="$HOME/.nvm" +export PROJECTS_DIR="$HOME/Documents/projects" function gg() { - cd ~/Git/$1; - if [ -f ~/Git/$1/pyproject.toml ]; then + cd "$PROJECTS_DIR/$1"; + if [ -f "$PROJECTS_DIR/$1/pyproject.toml" ]; then poetry shell; fi } diff --git a/skylab/core/roles/workstation/tasks/environment.yml b/skylab/core/roles/workstation/tasks/environment.yml index d7afd3d..4459b01 100644 --- a/skylab/core/roles/workstation/tasks/environment.yml +++ b/skylab/core/roles/workstation/tasks/environment.yml @@ -17,6 +17,23 @@ state: present loop: "{{ _local_human_users }}" +- name: Configure bash completions + become: true + ansible.builtin.blockinfile: + path: ~{{ item.0 }}/.config/bash_completions + create: true + block: >- + function _gg_completion() { + local cur=${COMP_WORDS[COMP_CWORD]}; + COMPREPLY=( $(compgen -W "$(command ls $PROJECT_DIR)" -- $cur) ); + } + + complete -F _gg_completion gg + owner: "{{ ansible_user }}" + group: "{{ item.0 }}" + mode: 0664 + loop: "{{ _local_human_users }}" + - name: Enforce ownership of the SSH keys become: true ansible.builtin.file: