From 0a284d08bc680541497e07c425a5abc7781ab65a Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 3 Oct 2026 16:56:55 -0600 Subject: [PATCH] added modular bash command-picker --- local.yml | 1 + tasks/command-picker.yml | 43 ++++++++++++++++++++ tasks/files/command-picker/command-picker.sh | 16 ++++++++ tasks/files/command-picker/linux.txt | 27 ++++++++++++ tasks/users.yml | 8 ---- 5 files changed, 87 insertions(+), 8 deletions(-) create mode 100644 tasks/command-picker.yml create mode 100644 tasks/files/command-picker/command-picker.sh create mode 100644 tasks/files/command-picker/linux.txt diff --git a/local.yml b/local.yml index 5b217b5..7625a63 100644 --- a/local.yml +++ b/local.yml @@ -14,3 +14,4 @@ - include_tasks: tasks/packages.yml - include_tasks: tasks/remove.yml - include_tasks: tasks/starship.yml + - include_tasks: tasks/command-picker.yml diff --git a/tasks/command-picker.yml b/tasks/command-picker.yml new file mode 100644 index 0000000..edae745 --- /dev/null +++ b/tasks/command-picker.yml @@ -0,0 +1,43 @@ +- name: Create .bashrc.d directory + file: + path: /home/robert/.bashrc.d + state: directory + owner: robert + group: robert + mode: '0755' + +- name: Install command picker + copy: + src: files/command-picker/command-picker.sh + dest: /home/robert/.bashrc.d/command-picker.sh + owner: robert + group: robert + mode: '0644' + +- name: Create commands directory + file: + path: /home/robert/.config/commands + state: directory + owner: robert + group: robert + mode: '0755' + +- name: Install Linux command library + copy: + src: files/command-picker/linux.txt + dest: /home/robert/.config/commands/linux.txt + owner: robert + group: robert + mode: '0644' + +- name: Add .bashrc.d loader to .bashrc + blockinfile: + path: /home/robert/.bashrc + marker: "# {mark} ANSIBLE MANAGED COMMAND PICKER" + block: | + # Load Bash configuration snippets + if [ -d "$HOME/.bashrc.d" ]; then + for file in "$HOME/.bashrc.d/"*.sh; do + [ -r "$file" ] && . "$file" + done + fi diff --git a/tasks/files/command-picker/command-picker.sh b/tasks/files/command-picker/command-picker.sh new file mode 100644 index 0000000..4dd2b55 --- /dev/null +++ b/tasks/files/command-picker/command-picker.sh @@ -0,0 +1,16 @@ +# Command picker using fzf +commands() { + local cmd + cmd=$(grep -vE '^[[:space:]]*#|^[[:space:]]*$' ~/.config/commands/linux.txt | + fzf --height 50% --layout=reverse --border --prompt='Command: ') + + if [[ -n "$cmd" ]]; then + READLINE_LINE="$cmd" + READLINE_POINT=${#READLINE_LINE} + fi +} + +# Ctrl+G opens the command picker +if [[ $- == *i* ]]; then + bind -x '"\C-g": commands' +fi diff --git a/tasks/files/command-picker/linux.txt b/tasks/files/command-picker/linux.txt new file mode 100644 index 0000000..abffe6c --- /dev/null +++ b/tasks/files/command-picker/linux.txt @@ -0,0 +1,27 @@ +# ===== Proxmox ===== +pveversion -v +qm list +pct list +pvesm status + +# ===== Docker ===== +docker ps +docker compose ps +docker compose logs -f +docker stats + +# ===== Disk ===== +lsblk -f +df -h +du -sh * +sudo smartctl -a /dev/sda + +# ===== Network ===== +ip addr +ip route +ss -tulpn + +# ===== Files ===== +ls -lah +find . -maxdepth 2 -type f +rsync -avh --progress SOURCE/ DEST/ diff --git a/tasks/users.yml b/tasks/users.yml index 2ef25bf..78c8f06 100644 --- a/tasks/users.yml +++ b/tasks/users.yml @@ -18,11 +18,3 @@ owner: robert group: robert mode: 0600 - -- name: copy .bashrc to server - copy: - src: files/bashrc - dest: /home/robert/.bashrc - owner: robert - group: robert - mode: 0600