Modern tools (rg, fd...)

This commit is contained in:
2026-09-08 18:26:53 +02:00
parent f043606466
commit c49e4db304
7 changed files with 114 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
# pi_modern_shell_env
Installs modern CLI tooling (fish, ripgrep, fd, bat, fzf, zoxide, lsd,
tmux) plus a starship prompt for the login user on `iot` Pi hosts, and
makes fish the default login shell. Purely a convenience layer for
interactive SSH sessions into otherwise single-purpose appliance boxes —
does not affect any of the audio/sensor services these hosts run.
**Key vars:**
- `pi_modern_shell_env_target_user` — user to configure (defaults to
`main_user`, falling back to `root`).
- `pi_modern_shell_env_set_default_shell` — whether to `chsh` the target
user to fish (default `true`).

View File

@@ -0,0 +1,23 @@
---
# Debian names these bat/fd-find, and ships the binaries as batcat/fdfind
# to avoid clashing with other packages — symlinked to bat/fd below.
pi_modern_shell_env_packages:
- fish
- ripgrep
- fd-find
- bat
- fzf
- zoxide
- lsd
- tmux
- curl
# Bookworm's apt coverage for starship is inconsistent across releases/
# arches, so it's installed via the official install script instead.
pi_modern_shell_env_starship_install_url: https://starship.rs/install.sh
pi_modern_shell_env_target_user: "{{ main_user | default('root') }}"
# Off switch for anyone who wants the tools installed without disrupting
# their existing login shell.
pi_modern_shell_env_set_default_shell: true

View File

@@ -0,0 +1,59 @@
---
- name: Install modern CLI packages
ansible.builtin.apt:
name: "{{ pi_modern_shell_env_packages }}"
state: present
update_cache: true
- name: Symlink fdfind to fd
ansible.builtin.file:
src: /usr/bin/fdfind
dest: /usr/local/bin/fd
state: link
- name: Symlink batcat to bat
ansible.builtin.file:
src: /usr/bin/batcat
dest: /usr/local/bin/bat
state: link
- name: Download starship install script
ansible.builtin.get_url:
url: "{{ pi_modern_shell_env_starship_install_url }}"
dest: /tmp/starship-install.sh
mode: "0755"
- name: Run starship install script
ansible.builtin.command:
cmd: /tmp/starship-install.sh --yes
creates: /usr/local/bin/starship
- name: Determine target user's home directory
ansible.builtin.set_fact:
pi_modern_shell_env_target_home: "{{ '/root' if pi_modern_shell_env_target_user == 'root' else '/home/' + pi_modern_shell_env_target_user }}"
- name: Ensure fish config directory exists
ansible.builtin.file:
path: "{{ pi_modern_shell_env_target_home }}/.config/fish"
state: directory
owner: "{{ pi_modern_shell_env_target_user }}"
mode: "0700"
- name: Deploy fish config
ansible.builtin.template:
src: config.fish.j2
dest: "{{ pi_modern_shell_env_target_home }}/.config/fish/config.fish"
owner: "{{ pi_modern_shell_env_target_user }}"
mode: "0644"
- name: Ensure fish is a known login shell
ansible.builtin.lineinfile:
path: /etc/shells
line: /usr/bin/fish
state: present
- name: Set fish as the default login shell
ansible.builtin.user:
name: "{{ pi_modern_shell_env_target_user }}"
shell: /usr/bin/fish
when: pi_modern_shell_env_set_default_shell

View File

@@ -0,0 +1,7 @@
{{ ansible_managed | comment }}
starship init fish | source
abbr --add ls lsd
abbr --add ll 'lsd -l'
abbr --add la 'lsd -la'

View File

@@ -27,6 +27,11 @@
regexp: "^#?AcceptEnv LANG LC_*"
line: "#AcceptEnv LANG LC_*"
notify: Restart sshd
- name: Remove first-run "SSH may not work until a valid user has been set up" banner
ansible.builtin.file:
path: /etc/ssh/sshd_config.d/rename_user.conf
state: absent
notify: Restart sshd
- name: Get hostname
ansible.builtin.command: "raspi-config nonint get_hostname"
register: pi_standard_setup_pi_hostname