From df102bce40ecd77851acdac3930b5019f9383ab9 Mon Sep 17 00:00:00 2001 From: cubernetes Date: Wed, 21 Oct 2026 16:12:54 +0200 Subject: [PATCH] Add parted, safe_ls, and readline history-preserve-point --- hosts/fw/configuration.nix | 1 + modules/home-manager/bash.nix | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/hosts/fw/configuration.nix b/hosts/fw/configuration.nix index c49107c..56d6ff1 100644 --- a/hosts/fw/configuration.nix +++ b/hosts/fw/configuration.nix @@ -481,6 +481,7 @@ with lib; yt-dlp yubioath-flutter nautilus + parted ]; programs.ydotool.enable = true; diff --git a/modules/home-manager/bash.nix b/modules/home-manager/bash.nix index 8a1f2a9..0443b88 100644 --- a/modules/home-manager/bash.nix +++ b/modules/home-manager/bash.nix @@ -40,6 +40,7 @@ _have bash_abbr && shopt -u expand_aliases #-############################### shell variables ################################ FIGNORE='.o' +# Warning HISTCONTROL=ignoreboth:erasedups HISTTIMEFORMAT='%y-%m-%d %H:%M:%S ' HISTSIZE=-1 @@ -64,6 +65,22 @@ take () { CDPATH= cd "''${out:-''${@: -1}}" } +safe_ls () { + command ls --color=always --quoting-style=shell-escape -lArth 2>/dev/null || \ + command ls --color=always -q -lArth 2>/dev/null || \ + command ls --color=always -lArth 2>/dev/null || \ + command ls --color -lArth 2>/dev/null || \ + command ls -lArth 2>/dev/null || \ + command ls -lArt 2>/dev/null || \ + command ls -lAr 2>/dev/null || \ + command ls -lar 2>/dev/null || \ + command ls -la 2>/dev/null || \ + command ls -l 2>/dev/null || \ + command ls -1 2>/dev/null || \ + command printf '%q\n' * 2>/dev/null || \ + command printf '%s\n' * 2>/dev/null +} + cd () { : 'Run cd; on success in a terminal, show the 4 newest entries (with a count of hidden ones)' @@ -72,7 +89,7 @@ cd () { command -v ls &>/dev/null || return 0 local -a lines - mapfile -t lines < <(command ls --color=always --quoting-style=shell-escape -lArth) + mapfile -t lines < <(safe_ls) if (( ''${#lines[@]} > 10 )); then printf '\033[7m... %d more entries ...\033[27m\n' "$(( ''${#lines[@]} - 10 ))"; printf '%s\n' "''${lines[@]: -9}" @@ -244,7 +261,8 @@ bind '"\e\C-r": kill-region' \ 'set completion-query-items 0' \ 'set menu-complete-display-prefix on' \ 'set colored-completion-prefix on' \ - 'set colored-stats on' + 'set colored-stats on' \ + 'set history-preserve-point on' #-################################## autoclear ################################### #-# TODO