Bladeren bron

~/.bin/l: Allow viewing http(s) urls

Lu Stadler 6 jaren geleden
bovenliggende
commit
797275ee3d
1 gewijzigde bestanden met toevoegingen van 5 en 1 verwijderingen
  1. 5 1
      .bin/l

+ 5 - 1
.bin/l

1
#!/usr/bin/env bash
1
#!/usr/bin/env bash
2
2
3
# ls or less anything in your filesystem (depending on what it is).
3
# ls or less anything in your filesystem or on the web (depending on what it is).
4
5
url_pattern="https?://.*"
4
6
5
if [ -d "$1" ]; then
7
if [ -d "$1" ]; then
6
	ls --group-directories-first --color=auto "$1"
8
	ls --group-directories-first --color=auto "$1"
8
	less "$1"
10
	less "$1"
9
elif which "$1" &> /dev/null; then
11
elif which "$1" &> /dev/null; then
10
	less `which $1`
12
	less `which $1`
13
elif [[ "$1" =~ $url_pattern ]]; then
14
	curl --silent --fail "$1" | less
11
else
15
else
12
	ls --group-directories-first --color=auto $*
16
	ls --group-directories-first --color=auto $*
13
fi
17
fi