You are not logged in.

#1226 2012-02-03 02:09:56

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

Re: Ranger, a textbased filemanager

bencahill wrote:

Wow. Just wow! I just tried ranger, and it's awesome! I mainly love the preview of dirs and other things.

I have one feature request...

Can you make any preview scripts (e.g. highlight) be killed if the cursor moves off their item? Right now, if I hold j, and go over lots of CPU-intensive previewing files (like jpgs or huge sql files), the CPU will continue to be eaten up, even though I'm not on them currently. If that's possible, that is...

Thanks!

I can't work on ranger atm. Here are some workarounds though: You can kill them manually by typing "w", selecting the process and typing "dd". You can also avoid running them by typing "J" or "10j" instead of "j".

SquareRoot wrote:

Is there any way to toggle or configure or hack:

1) "user@host:" in the title bar off

2) the summary information on the right of the status bar off (... sum, ... free x/y Top)

3) more information into the main column in addition to size/count, such as any combo of type, permissions, links, user, group, inode, dates, times, ...
there is a lot of room here to provide some really useful information about the displayed files and directories - I really miss this info
then make what is shown in the left side of the status bar for the current file/directory configurable as well, probably a subset of what is not shown in the main column

4) I can toggle column 3 via zP and/or zp, additionally I want to toggle column 1 (all parent directories)

You're going to have to hack ranger for that. The files you're looking for are ranger/gui/widgets/titlebar.py, ranger/gui/widgets/statusbar.py, ranger/gui/widgets/browserview.py and ranger/gui/widgets/browsercolumn.py.

Dieter@be wrote:

thinking out loud... file previous being limited to text/curses is pretty frustrating. esp. for images and video.  In theory it should be perfectly possible to port ranger to something like Gtk.  the interface would look the same, all features (keybinds, python configuration etc) would be identical (or at least very similar as keybinding in X is a bit different).
Question is: how tightly coupled is ranger to ncurses?  Is the UI abstracted or tightly interweaved?

There is some UI abstraction: (most of) the UI code is in a separate module. But there is no defined interface/API and you'd probably have to make some adjustments in the non-ui code too if you replace the ncurses frontend with an entirely different one.

Falstaff wrote:

I have 3 questions:

1) How can I make the 'filter' function case insensitive?
2) Is there a way to make the filter update the result real-time as you type?
3) Is there a command to clear the filter?

My thanks in advance.

1. Override ranger.fsobject.directory.accept_file in your ~/.config/ranger/options.py file:

import ranger.fsobject.directory

# this was copy&pasted from ranger/fsobject/directory.py and modified
# to make filters case insensitive
def my_accept_file(fname, dirname, hidden_filter, name_filter):
    if hidden_filter:
        try:
            if hidden_filter.search(fname):
                return False
        except:
            if hidden_filter in fname:
                return False
    if name_filter and name_filter.lower() not in fname.lower():
        return False
    return True

# override the original function with the custom function
ranger.fsobject.directory.accept_file = my_accept_file

2. You would have to modify the "filter" command: replace "def execute(self):" with "def quick(self):" in the code of the command, so the function is executed each time you type a key. (Commands are in ranger/defaults/commands.py or ~/.config/ranger/commands.py)
3. zf<enter>


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

Offline

#1227 2012-02-03 02:40:14

eyolf
Member
From: Copenhagen
Registered: 2005-11-29
Posts: 339
Website

Re: Ranger, a textbased filemanager

So, still no branch view...?

Offline

#1228 2012-02-03 02:43:10

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

Re: Ranger, a textbased filemanager

Yeah. I have absolutely no time atm and I guess nobody else would look into it.


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

Offline

#1229 2012-02-03 02:53:31

eyolf
Member
From: Copenhagen
Registered: 2005-11-29
Posts: 339
Website

Re: Ranger, a textbased filemanager

Fair enough. It's a great file manager you've made in any case. Kudos and thanks!

Offline

#1230 2012-02-03 03:26:45

eyolf
Member
From: Copenhagen
Registered: 2005-11-29
Posts: 339
Website

Re: Ranger, a textbased filemanager

PS: I'd look into it if I knew where to look

Offline

#1231 2012-02-03 05:12:29

bencahill
Member
Registered: 2011-03-20
Posts: 40

Re: Ranger, a textbased filemanager

hut wrote:

I can't work on ranger atm. Here are some workarounds though: You can kill them manually by typing "w", selecting the process and typing "dd". You can also avoid running them by typing "J" or "10j" instead of "j".

Hey, thanks for taking the time to respond. The combination of these two tips work perfectly for what I need. 'w' is nice if it gets stuck on generating a preview for a 10MB sql file. ;-)

Thanks!

Offline

#1232 2012-02-10 14:49:24

#This is a comment.
Member
Registered: 2011-05-27
Posts: 1

Re: Ranger, a textbased filemanager

When I  place the cursor over a password protected RAR file (while, preview_files=True), ranger locks itself while the unrar waits for input but it does not promt me for a password.
I have to kill the subprocess to regain controll over the program every time that happens.
Is there any way to circumvent this?
I ask because I have no way of knowing in advance if the file is password protected or not before trying to inspect it's contents and then it's too late.

EDIT:
OK, so I made a quick'n'dirty fix by using this to preview RAR files:

     # RAR archive:
     rar)
         unrar l -p- "$path" | sed -e '1,5d' -e 's/^--*$/--------------------/' | column -t | head -n $maxln[/b]
         success && exit 0 || exit 1;;

but the problem still remains (i guess) for any other encrypted archive in the list (zip,7z...).

Last edited by #This is a comment. (2012-02-10 15:59:23)


My other os is a Gentoo.

Offline

#1233 2012-02-13 21:26:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,548
Website

Re: Ranger, a textbased filemanager

I haven't caught up on this whole thread, so maybe this is not needed, but I faced the same concern a previous user did with running ranger in tmux and getting a window name of "python".  Here is a only marginally less ugly hack than the answer right after that post.  This does require xdotool, but then just add these two lines to one of the .py files - mine is in options.py

from subprocess import call
call("xdotool key --delay 0 ctrl+a comma BackSpace BackSpace BackSpace BackSpace BackSpace BackSpace R a n g e r KP_Enter",     shell=True)

Or course change the ctrl+a to match your own tmux prefix.

This uses xdotool to simulate the keypressess necessary to rename a window within tmux.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#1234 2012-02-14 15:51:17

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

Re: Ranger, a textbased filemanager

Trilby wrote:

I haven't caught up on this whole thread, so maybe this is not needed, but I faced the same concern a previous user did with running ranger in tmux and getting a window name of "python".  Here is a only marginally less ugly hack than the answer right after that post.  This does require xdotool, but then just add these two lines to one of the .py files - mine is in options.py

from subprocess import call
call("xdotool key --delay 0 ctrl+a comma BackSpace BackSpace BackSpace BackSpace BackSpace BackSpace R a n g e r KP_Enter",     shell=True)

Or course change the ctrl+a to match your own tmux prefix.

This uses xdotool to simulate the keypressess necessary to rename a window within tmux.

Try this:

sudo ln -s /usr/bin/python /usr/bin/Ranger
alias ranger='Ranger /usr/bin/ranger'

Of course, replace /usr/bin/ranger with the path of ranger's executable, and /usr/bin/pytho with whatever python executable you use for ranger.

Edit: I like your avatar.

Last edited by hut (2012-02-14 15:51:43)


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

Offline

#1235 2012-02-14 17:45:31

Baabelfish
Member
From: Finland
Registered: 2012-02-14
Posts: 17

Re: Ranger, a textbased filemanager

Hi!

I would like to see two features currently missing(?) from ranger:

1) Progressbars in the task view.

2) Ability to automatically save ranger session and load it on startup. With 10 tabs open it would be nice not to open them again.

My first post to this forum and already demanding stuff... ;D
But anyways I can't think of anything it would be missing after those.


usability == arch + i3 + urxvt + vim + ranger + dwb + vlc + cmus + mutt + shitload of scripts

Offline

#1236 2012-02-14 19:54:55

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

Re: Ranger, a textbased filemanager

Falstaff wrote:

I have 3 questions:

1) How can I make the 'filter' function case insensitive?
2) Is there a way to make the filter update the result real-time as you type?
3) Is there a command to clear the filter?

My thanks in advance.

Btw. here's the full solution for 1.

# ~/.config/ranger/commands.py
from ranger.api.commands import *
import ranger.fsobject.directory

original_accept_file = ranger.fsobject.directory.accept_file

# this was copy&pasted from ranger/fsobject/directory.py and modified
# to make filters case insensitive
def insensitive_accept_file(fname, dirname, hidden_filter, name_filter):
	if hidden_filter:
		try:
			if hidden_filter.search(fname):
				return False
		except:
			if hidden_filter in fname:
				return False
	if name_filter and name_filter.lower() not in fname.lower():
		return False
	return True

class filter(Command):
	def execute(self):
		ranger.fsobject.directory.accept_file = original_accept_file
		self.fm.set_filter(self.rest(1))
		self.fm.reload_cwd()

class filter_i(Command):
	def execute(self):
		ranger.fsobject.directory.accept_file = insensitive_accept_file
		self.fm.set_filter(self.rest(1))
		self.fm.reload_cwd()

And as already said:
2. To make it filter as you type, replace "execute" with "quick"
3. type zf<enter>

Last edited by hut (2012-02-14 19:55:20)


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

Offline

#1237 2012-02-19 13:51:24

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,548
Website

Re: Ranger, a textbased filemanager

I'm not sure I understand the "update_title" setting.  What is it supposed to do?

Ranger creates it's own "title bar" as the first line in the terminal window, but this is different from the terminal title.  From reading the man page it seemed update_title would control whether information was put in the terminal's title.  In any case, setting update_title to True or False does not change any of ranger's behavior in urxvt.

Can anyone clarify how this option is used and/or describe how I can get ranger to set urxvt's title string?

Last edited by Trilby (2012-02-19 13:51:51)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#1238 2012-02-22 13:04:15

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

Re: Ranger, a textbased filemanager

It's about the window title. If update_title is on (and it is by default), ranger will change the terminal title to "ranger:<path>". It's up to your window manager to draw it.

Last edited by hut (2012-02-22 13:06:34)


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

Offline

#1239 2012-02-22 13:41:18

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,548
Website

Re: Ranger, a textbased filemanager

Thanks, that's what I thought it should do.  But I was not getting those results.  After some testing I see this does behave as expected in xterm and terminator, but not urxvt.  Other programs, however, (eg mutt) that set the terminal title work in urxvt.  This lead me to tinker with the TERM environment variable and found that setting TERM to any terminal other than an rvxt works (eg TERM=xterm-256color ranger).


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#1240 2012-02-22 15:49:44

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: Ranger, a textbased filemanager

Back in the day when you, hut, switched from python2 to python3 (or: made ranger also able to run with python3) this title thing worked with urxvt, if python2 was used, but it didn't if python3 was used. But now it doesn't work with both. Would be awesome if you could make it available with urxvt as well. Until then, Trilby's workaround works.

Offline

#1241 2012-02-23 22:35:06

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

Re: Ranger, a textbased filemanager

What is your $TERM? I just need to add it to ranger.gui.ui.TERMINALS_WITH_TITLE


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

Offline

#1242 2012-02-23 23:46:00

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,548
Website

Re: Ranger, a textbased filemanager

rxvt-unicode-256color

I'm pretty sure this is the default for urxvt.  Thanks for including it.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#1243 2012-03-01 11:29:42

kosmiciatakuja
Member
Registered: 2010-01-27
Posts: 46

Re: Ranger, a textbased filemanager

Is there any way I can do something with tagged files? I'm tagging some files I want to move or delete later, but I can't figure out how to either select them or use them somehow. I found out there's the %t macro which gives the list of all tagged files, and that's okay for simple * tags, but what if I want to use different tags? For example mark files that should be moved to one directory later with "a and mark some other files with "b and those need to be moved to a different dir.
A nice workaround would be if I could just select files tagged with a specific tag, but I can't figure out how.

Ranger is the best file manager I have ever seen, by the way smile

Offline

#1244 2012-03-02 01:20:41

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

Re: Ranger, a textbased filemanager

ranger --list-tagged-files=A | xargs -d "\n" mv -t /foo

moves files tagged with "A" to the directory /foo. Combine it with any command you want smile

Also, with "ct" you can jump to the next tagged file.


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

Offline

#1245 2012-03-02 01:54:36

antox
Member
Registered: 2012-03-01
Posts: 1

Re: Ranger, a textbased filemanager

The %\d[dfs] macros (like %7s = selection of the seventh tab) seem to not work now. As a solution one can put

class _MacroTemplate(string.Template):
    """A template for substituting macros in commands"""
    delimiter = ranger.MACRO_DELIMITER
+    idpattern = '[_a-z0-9]+'

in core/actions.py to allow placeholders starting with a digit.

Offline

#1246 2012-03-03 06:37:29

tweed
Member
Registered: 2011-03-18
Posts: 21

Re: Ranger, a textbased filemanager

RANGER on *BSD ?

tried much to find info. nothing anywhere I've looked.
how great it would be to have ranger running on openbsd server install.

I've only found a bit of info on page 42 here:
"And yes, ranger uses GNU cp/mv atm."


QUESTIONS:

1- is it easily possible/sensible?
2- what would be crippled if bash was openbsd shell?

ANY info would be incredibly appreciated.
Surprised there appear to be a total lack of any usage of ranger on freebsd and/or openbsd.


UPDATE: GNU coreutils. don't know what this all means. gnu coreutils very linux specific. sorry for lack of knowledge.
http://tomayko.com/writings/gnu-is-killing-solaris

Last edited by tweed (2012-03-03 06:54:46)

Offline

#1247 2012-03-03 12:50:34

PotatoesMaster
Member
From: France
Registered: 2010-08-26
Posts: 54

Re: Ranger, a textbased filemanager

tweed wrote:

1- is it easily possible/sensible?

GNU cp and mv do not accept the same command line arguments than their *BSD equivalents.

Man pages:

Options ranger uses:

  • mv:
    -f
    --backup=numbered ( /!\ GNU version only)
    -v (in :bulkrename command)
    -i (in :bulkrename command)

  • cp:
    -a ( /!\ not in OpenBSD)
    -f
    --backup=numbered ( /!\ GNU version only)

A bad solution: keep only the options present everywhere. It will change the default behaviour (to not overwrite files on copy). :-/
A better one: make ranger dependant on GNU coreutils on *BSD and replace cp and mv with gcp and gmv. Someone to make a package ? :-)
Other?

tweed wrote:

2- what would be crippled if bash was openbsd shell?

All should be fine. Ranger  use the shell defined by SHELL environment variable or bash when it is not defined.
The scope.sh file (a script used to generate file preview) have a bash shebang and may require some adjustements.

Last edited by PotatoesMaster (2012-03-03 12:51:55)

Offline

#1248 2012-03-19 00:24:48

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

Re: Ranger, a textbased filemanager

If you use ranger-git, you might notice that ranger has a new file executor/opener. It now leaves file launching to a module called "rifle" which is also a stand-alone executable file: rifle.py

This change makes the configuration file "apps.py" obsolete and introduces a new one: rifle.conf

Check this topic for a relevant discussion.

The new configuration file is much easier to read, write and parse than the previous apps.py (which was python code). This is also the most simple format I came up with that is as powerful as the apps.py, so we lose nothing. It is actually more powerful than apps.py, because now you can list all the ways to open a file by pressing r. If you still want to do some coding in python, there are hooks in rifle.py.

I hope this change removes the mental barriers that previously prevented you to customize the file launching rules. (Get a custom copy with ranger --copy-config=rifle). There are probably still some bugs which will be fixed as we go along.

EDIT: I forgot to mention:
- The "d" flag for "detach" was renamed to "f" for "fork"
- The part of the man page about file opening is currently outdated and does not reflect how ranger works.

Last edited by hut (2012-03-19 00:57:34)


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

Offline

#1249 2012-03-19 05:40:15

taylorchu
Member
Registered: 2010-08-09
Posts: 405

Re: Ranger, a textbased filemanager

trying this out.


"After you do enough distro research, you will choose Arch."

Offline

#1250 2012-03-19 09:34:15

Army
Member
Registered: 2007-12-07
Posts: 1,784

Re: Ranger, a textbased filemanager

Ok, I've spend quite some time to get an apps.py which fits my needs perfectly. Nevertheless, I'll check it out!

edit: Ok, does look very simple indeed. But I have one request: With the f flag, use setsid instead of nohup! Nohup doesn't work with mplayer. This was discussed here, I can search the posts if you don't remember. With setsid there's no problem at all, I have been using it for quite a while and it works perfectly.

edit2:

patch:

diff -paur ranger/ranger/ext/rifle.py ranger.new/ranger/ext/rifle.py
--- ranger/ranger/ext/rifle.py	2012-03-19 10:36:13.450733645 +0100
+++ ranger.new/ranger/ext/rifle.py	2012-03-19 20:21:07.364058741 +0100
@@ -189,7 +189,7 @@ class Rifle(object):
 				os.environ['TERMCMD'] = term
 			action = "$TERMCMD -e %s" % action
 		if 'f' in flags:
-			action = "nohup %s >& /dev/null &" % action
+			action = "setsid %s >& /dev/null &" % action
 		return action
 
 	def list_commands(self, files, mimetype=None):

Last edited by Army (2012-03-19 19:20:35)

Offline

Board footer

Powered by FluxBB