Add parted, safe_ls, and readline history-preserve-point

This commit is contained in:
cubernetes 2026-10-21 16:12:54 +02:00
parent 10c415c3e5
commit df102bce40
2 changed files with 21 additions and 2 deletions

View file

@ -481,6 +481,7 @@ with lib;
yt-dlp yt-dlp
yubioath-flutter yubioath-flutter
nautilus nautilus
parted
]; ];
programs.ydotool.enable = true; programs.ydotool.enable = true;

View file

@ -40,6 +40,7 @@ _have bash_abbr && shopt -u expand_aliases
#-############################### shell variables ################################ #-############################### shell variables ################################
FIGNORE='.o' FIGNORE='.o'
# Warning
HISTCONTROL=ignoreboth:erasedups HISTCONTROL=ignoreboth:erasedups
HISTTIMEFORMAT='%y-%m-%d %H:%M:%S ' HISTTIMEFORMAT='%y-%m-%d %H:%M:%S '
HISTSIZE=-1 HISTSIZE=-1
@ -64,6 +65,22 @@ take () {
CDPATH= cd "''${out:-''${@: -1}}" 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 () { cd () {
: 'Run cd; on success in a terminal, show the 4 newest entries (with a count of hidden ones)' : '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 command -v ls &>/dev/null || return 0
local -a lines local -a lines
mapfile -t lines < <(command ls --color=always --quoting-style=shell-escape -lArth) mapfile -t lines < <(safe_ls)
if (( ''${#lines[@]} > 10 )); then if (( ''${#lines[@]} > 10 )); then
printf '\033[7m... %d more entries ...\033[27m\n' "$(( ''${#lines[@]} - 10 ))"; printf '\033[7m... %d more entries ...\033[27m\n' "$(( ''${#lines[@]} - 10 ))";
printf '%s\n' "''${lines[@]: -9}" printf '%s\n' "''${lines[@]: -9}"
@ -244,7 +261,8 @@ bind '"\e\C-r": kill-region' \
'set completion-query-items 0' \ 'set completion-query-items 0' \
'set menu-complete-display-prefix on' \ 'set menu-complete-display-prefix on' \
'set colored-completion-prefix on' \ 'set colored-completion-prefix on' \
'set colored-stats on' 'set colored-stats on' \
'set history-preserve-point on'
#-################################## autoclear ################################### #-################################## autoclear ###################################
#-# TODO #-# TODO