Skip to content

Instantly share code, notes, and snippets.

View artem-bez's full-sized avatar

Artem Bezsmertnyi artem-bez

  • Stockholm, Sweden
View GitHub Profile
@artem-bez
artem-bez / zshrc function chpwd
Last active December 15, 2015 12:39
After changing working directory print directory listing if terminal is big enough to fit it, otherwise print $MOST_RECENT_LEN recently modified entries.
MOST_RECENT_LEN=20
function chpwd {
if [[ $(ls --format=vertical -w ${COLUMNS} | wc -l) -lt $((LINES - 1)) ]] {
ls
} else {
echo $(find . -maxdepth 1 | wc -l) entries. \
Showing $MOST_RECENT_LEN most recent \(ctime\)
ls -c | head -n$MOST_RECENT_LEN
}
}