You are not logged in.
Pages: 1
So I tried installing Gentoo not too long ago (to no avail, though, X didn't work), and while using it I noticed that if I typed "less some_directory", then it would output either the contents of the directory or the contents of the pwd, I forget which one. However, in Arch, typing "less some_directory" will output "some_directory is a directory", so I have to use "ls some_directory". Does anyone know how to change less to be able to work with directories as well?
Thanks in advance!
Offline
This is what I get when I 'vim menu_test'
" ============================================================================
" Netrw Directory Listing (netrw v132)
" /home/karol/menu_test
" Sorted by name
" Sort sequence: [\/]$,\.h$,\.c$,\.cpp$,*,\.o$,\.obj$,\.info$,\.swp$,\.bak$,\~$
" Quick Help: <F1>:help -:go up dir D:delete R:rename s:sort-by x:exec
" ============================================================================
../
pacpackgs.lst
t1*
.swp
pacpackgs.lst~
How to do it w/ less - idk.
Offline
Probably means they have a specialized version of less .... -or- there might be a a less option that does it and which is invoked by default (man less), (env.variable LESSOPEN?)
Offline
Install "lesspipe" from [community]. It comes with a profile.d entry that sets LESSOPEN for you so it's just plug-and-play.
Offline
Another Solution.
ls | less
Offline
... or *chuckles*
alias clueless="ls -al $* | less"
Offline
A more hands-on approach would be to start a command when less fails. Like less "$file" 2>/dev/null || ..... or see if it is a directory beforehand.
I thought it would be fun to write a small recursive file chooser:
function less() {
/bin/less "$1" 2>/dev/null || { IFS=$'\n';i=1;k=1;files=$(ls -1 "$1"); [ -z "$files" ] && { echo "Empty directory"; return; }; while [ $k != q -a $k != enter ]; do c=0; for file in $files; do ((i==++c)) && echo -e '\e[30;47m'"$file"'\e[m' || echo "$file"; done; read -n1 -s k; ! [ $k ] && { k=enter; echo; break; }; [ $k = A ] && ((i--)); [ $k = B ] && ((i++)); [ $k = q ] && break; echo -ne "\e[${c}A"; done; read -t 0.1; [ $k = enter ] && less "$1/$(echo "$files" | sed -n "$i"'{p;q}')"; }
}
Offline
Pages: 1