You are not logged in.

#1 2014-08-14 17:15:50

hut
Member
From: Hanover, Germany
Registered: 2010-03-12
Posts: 569
Website

lscd - simple ranger implementation in POSIX shell

I've been casually working on a file browser that has a similar interface like ranger, but takes a different approach, in that it is written in bash POSIX shell.

I wanted to combine the elegance, portability and simplicity of a short bash shell script with the ability to get me whereever I want ASAP without the "cd TAB TAB TAB" boilerplate.  Additionally, it can use ranger's file opener "rifle" to execute files just the way ranger does.

I'm not finished yet, but there is a working alpha version at github:

https://github.com/hut/lscd

It uses the basic h/j/k/l vim type movement control keys. Check the source for more key bindings, it makes no sense to write a complete list at this stage of development.

And the obligatory screen shot:
lscd_screenshot1.png

As you can see, there are no miller columns like in ranger. That may or may not change in the future. I suspect it would be too slow in shell script.

Pro tip: if you run lscd with the command ". lscd", it will run in the current bash environment, rather than in a new one. Only this way the directory will actually change after you close lscd.

Last edited by hut (2014-09-11 12:13:45)


"hut_" or "h00th00t" in irc.freenode.net #archlinux
Ranger Mailing List: https://lists.nongnu.org/mailman/listinfo/ranger-users

Offline

#2 2014-08-14 17:37:00

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: lscd - simple ranger implementation in POSIX shell

hut wrote:

written in bash.

I notice that you aren't actually writing this in bash, but posix shell.

hut wrote:

Additionally, it can use ranger's file opener "rifle" to execute files just the way ranger does.

Seems more like a hard dependency. Even drilling down into a directory fails without rifle installed.

hut wrote:

I'm not finished yet, but there is a working alpha version at github

Aliasing ls will break (e.g. alias ls='ls --color') this. You shouldn't be using ls at all, but rather glob expansion....

Last edited by falconindy (2014-08-14 17:39:24)

Offline

#3 2014-08-14 17:45:29

hut
Member
From: Hanover, Germany
Registered: 2010-03-12
Posts: 569
Website

Re: lscd - simple ranger implementation in POSIX shell

falconindy wrote:
hut wrote:

Additionally, it can use ranger's file opener "rifle" to execute files just the way ranger does.

Seems more like a hard dependency. Even drilling down into a directory fails without rifle installed.

Currently it thinks that symlinks are files and tries to open them. Maybe you tried entering a symlink to a directory?

falconindy wrote:

Aliasing ls will break (e.g. alias ls='ls --color') this. You probably shouldn't be using ls at all, but glob expansion....

Strange, I aliased ls to "ls --color" too and it works for me.


"hut_" or "h00th00t" in irc.freenode.net #archlinux
Ranger Mailing List: https://lists.nongnu.org/mailman/listinfo/ranger-users

Offline

#4 2014-08-14 19:17:19

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: lscd - simple ranger implementation in POSIX shell

Really cool.

falconindy wrote:

Aliasing ls will break (e.g. alias ls='ls --color') this. You shouldn't be using ls at all, but rather glob expansion....

In case you source it it will use the alias/function, so indeed, be careful with that.

Here's a template I always use for adding cursor movement:
(starting with line 147)
(adjust to posix shell yourself)
(the -t 0.01 newinput is "beatable" like if you hold the cursor newinput will get larger. That's why there's a "$newinput" =~ [~A-Da-d] for cursor keys and shift+cursor keys)

read -n 1 -s input

if [[ "$input" == $'\e' ]]; then
        input=ESC
        while true; do
                read -n 1 -s -t 0.01 newinput < /dev/tty
                [[ "$newinput" == $'\e' ]] && newinput=ESC
                input=${input}${newinput}
                [[ -z "$newinput" || "$newinput" =~ [~A-Da-d] ]] && break
        done
fi
case "$input" in
'ESC[A')         "code for up, etc"
;; #Up
'ESC[B')
;; #Down
'ESC[6~')
;; #Page Down
'ESC[5~')
;; #Page Up
'ESC[4~'|'ESC[F'|'ESC[8~'|'ESCOF')
;; #End
'ESC[1~'|'ESC[H'|'ESC[7~'|'ESCOH')
;; #Home
'ESC[D')
;; #Left
'ESC[C')
;; #Right
'ESC[3~')
;; #Delete

Offline

#5 2014-08-14 19:48:36

hut
Member
From: Hanover, Germany
Registered: 2010-03-12
Posts: 569
Website

Re: lscd - simple ranger implementation in POSIX shell

Procyon wrote:

Here's a template I always use for adding cursor movement:

Nice, I was already wondering how to do this. Thanks!


"hut_" or "h00th00t" in irc.freenode.net #archlinux
Ranger Mailing List: https://lists.nongnu.org/mailman/listinfo/ranger-users

Offline

#6 2014-09-11 12:11:03

hut
Member
From: Hanover, Germany
Registered: 2010-03-12
Posts: 569
Website

Re: lscd - simple ranger implementation in POSIX shell

There has been some progress with lscd. It's now fully POSIX-compatible and getting more and more stable and efficient.

In addition, somebody forked lscd in bash and actually implemented miller columns. His repository is here: https://github.com/D630/blscd

For the zsh folks there is also a zsh-reimplementation of ranger that arose independently of lscd, also with miller columns: https://github.com/Vifon/deer


"hut_" or "h00th00t" in irc.freenode.net #archlinux
Ranger Mailing List: https://lists.nongnu.org/mailman/listinfo/ranger-users

Offline

Board footer

Powered by FluxBB