aboutsummaryrefslogtreecommitdiff
path: root/bin/sl
blob: 233346263ebcec809e0617869fd6e6209b0e5d67 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env bash

# Taken from:
# https://gir.st/blog/sl-alt.htm

# sl - prints a mirror image of ls. (C) 2017 Tobias Girstmair, https://gir.st/, GPLv3

LEN=$(ls "$@" |wc -L) # get the length of the longest line

ls "$@" | rev | while read -r line
do
	printf "%${LEN}.${LEN}s\\n" "$line" | sed 's/^\(\s\+\)\(\S\+\)/\2\1/'
done