Improve cd function to run like ls -artlh but truncated
This commit is contained in:
parent
6d508d00ba
commit
1805475554
1 changed files with 14 additions and 2 deletions
|
|
@ -61,8 +61,20 @@
|
|||
}
|
||||
|
||||
cd () {
|
||||
: 'Run cd and if it succeeds, run ls'
|
||||
builtin cd "''$@" && command ls --color -Ah
|
||||
: 'Run cd; on success in a terminal, show the 4 newest entries (with a count of hidden ones)'
|
||||
|
||||
builtin cd "''$@" || return
|
||||
[[ -t 1 ]] || return 0
|
||||
command -v ls &>/dev/null || return 0
|
||||
|
||||
local -a lines
|
||||
mapfile -t lines < <(command ls --color=always --quoting-style=shell-escape -lArth)
|
||||
if (( ''${#lines[@]} > 5 )); then
|
||||
printf '\033[7m... %d more entries ...\033[27m\n' "$(( ''${#lines[@]} - 5 ))";
|
||||
printf '%s\n' "''${lines[@]: -4}"
|
||||
else
|
||||
printf '%s\n' "''${lines[@]}"
|
||||
fi
|
||||
}
|
||||
|
||||
drop_caches () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue