You are not logged in.

#876 2011-03-12 12:04:13

Revolt
Member
From: Portugal
Registered: 2009-06-11
Posts: 71
Website

Re: Ranger, a textbased filemanager

Oh ok got it.

Edit: Since no one seems to have had a problem with me adding some useful commands to the wiki, I've added another one related to image mounting with cdemu which also serves as an example of a custom loader object that waits for a directory to be mounted.

To use it you simply navigate to an image file like image.iso, write :mount on the command line and then ranger calls cdemu to load that image file (unloading the previous one too) and waits until the directory is mounted to open it on tab 9 (in the background).

Hope someone might find it as useful as I have

https://wiki.archlinux.org/index.php/Ra … e_Mounting

Last edited by Revolt (2011-03-13 03:03:55)

Offline

#877 2011-03-13 15:07:10

galymzhan
Member
Registered: 2010-12-25
Posts: 7

Re: Ranger, a textbased filemanager

Is there a way to move entire directory with it's contents? Suppose you have:

/home/abc/test/1.txt
/home/test/1.txt

Now if you dd (cut) the directory /home/abc/test and try to paste it in /home with po (paste overwriting) ranger says:

mv: Cannot move '/home/abc/test' to '/home/test' : directory not empty

Did I miss something?

Offline

#878 2011-03-16 23:47:13

Arthenik
Member
Registered: 2010-02-13
Posts: 44

Re: Ranger, a textbased filemanager

There seems to be a problem when opening a file that has a blank space in its name. Starting a video in my "Star Trek" folder works with the preset mplayer option, but when I modify apps.py to fire my custom vlc-launching script, vlc complains:

File reading failed:
VLC could not open the file "/media/server/video/Star".
Your input can't be opened:
VLC is unable to open the MRL 'file:///media/server/video/Star'. Check the log for details.
File reading failed:
VLC could not open the file "/media/server/video/Star Trek The Next Generation/TNG S3/Trek".
Your input can't be opened:
VLC is unable to open the MRL 'file:///media/server/video/Star%20Trek%20The%20Next%20Generation/TNG%20S3/Trek'. Check the log for details.
File reading failed:
VLC could not open the file "/media/server/video/Star Trek The Next Generation/TNG S3/The".
Your input can't be opened:
VLC is unable to open the MRL 'file:///media/server/video/Star%20Trek%20The%20Next%20Generation/TNG%20S3/The'. Check the log for details.
File reading failed:
VLC could not open the file "/media/server/video/Star Trek The Next Generation/TNG S3/Next".
Your input can't be opened:
VLC is unable to open the MRL 'file:///media/server/video/Star%20Trek%20The%20Next%20Generation/TNG%20S3/Next'. Check the log for details.
File reading failed:
VLC could not open the file "/media/server/video/Star Trek The Next Generation/TNG S3/Generation/TNG".
Your input can't be opened:
VLC is unable to open the MRL 'file:///media/server/video/Star%20Trek%20The%20Next%20Generation/TNG%20S3/Generation/TNG'. Check the log for details.
File reading failed:
VLC could not open the file "/media/server/video/Star Trek The Next Generation/TNG S3/S3/Star".
Your input can't be opened:
VLC is unable to open the MRL 'file:///media/server/video/Star%20Trek%20The%20Next%20Generation/TNG%20S3/S3/Star'. Check the log for details.
File reading failed:
VLC could not open the file "/media/server/video/Star Trek The Next Generation/TNG S3/Trek".
Your input can't be opened:
VLC is unable to open the MRL 'file:///media/server/video/Star%20Trek%20The%20Next%20Generation/TNG%20S3/Trek'. Check the log for details.
File reading failed:
VLC could not open the file "/media/server/video/Star Trek The Next Generation/TNG S3/TNG".
Your input can't be opened:
VLC is unable to open the MRL 'file:///media/server/video/Star%20Trek%20The%20Next%20Generation/TNG%20S3/TNG'. Check the log for details.
File reading failed:
VLC could not open the file "/media/server/video/Star Trek The Next Generation/TNG S3/3x03".
Your input can't be opened:
VLC is unable to open the MRL 'file:///media/server/video/Star%20Trek%20The%20Next%20Generation/TNG%20S3/3x03'. Check the log for details.
File reading failed:
VLC could not open the file "/media/server/video/Star Trek The Next Generation/TNG S3/The".
Your input can't be opened:
VLC is unable to open the MRL 'file:///media/server/video/Star%20Trek%20The%20Next%20Generation/TNG%20S3/The'. Check the log for details.
File reading failed:
VLC could not open the file "/media/server/video/Star Trek The Next Generation/TNG S3/Survivors.avi".
Your input can't be opened:
VLC is unable to open the MRL 'file:///media/server/video/Star%20Trek%20The%20Next%20Generation/TNG%20S3/Survivors.avi'. Check the log for details.

Offline

#879 2011-03-17 05:11:24

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,358

Re: Ranger, a textbased filemanager

Not sure if its a known issue, but when opening a file using xdg-open (calling okular), a lot of warning messages cover the screen and I have to refresh it to see ranger's output again. Any way to send those warning messages to /dev/null or something?


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#880 2011-03-17 08:57:22

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

Re: Ranger, a textbased filemanager

ngoonee wrote:

Not sure if its a known issue, but when opening a file using xdg-open (calling okular), a lot of warning messages cover the screen and I have to refresh it to see ranger's output again. Any way to send those warning messages to /dev/null or something?

You can use c.flags += 's' to send it to /dev/null

Offline

#881 2011-03-18 12:33:57

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

Re: Ranger, a textbased filemanager

Revolt wrote:

Oh ok got it.

Edit: Since no one seems to have had a problem with me adding some useful commands to the wiki, I've added another one related to image mounting with cdemu which also serves as an example of a custom loader object that waits for a directory to be mounted.

To use it you simply navigate to an image file like image.iso, write :mount on the command line and then ranger calls cdemu to load that image file (unloading the previous one too) and waits until the directory is mounted to open it on tab 9 (in the background).

Hope someone might find it as useful as I have

https://wiki.archlinux.org/index.php/Ra … e_Mounting

Thanks for sharing your stuff. Btw ranger also has its own wiki. Click on wiki on its homepage



galymzhan wrote:

Is there a way to move entire directory with it's contents? Suppose you have:

/home/abc/test/1.txt
/home/test/1.txt

Now if you dd (cut) the directory /home/abc/test and try to paste it in /home with po (paste overwriting) ranger says:

mv: Cannot move '/home/abc/test' to '/home/test' : directory not empty

Did I miss something?

Atm there is one mv/cp command for every situation. The problem with mv/cp is that they don't read your mind. Perhaps I need more intelligent handling of copying/moving within ranger. For now, you can always try your custom command with !mv -f %c . or whatever and map it to a key.



Arthenik wrote:

There seems to be a problem when opening a file that has a blank space in its name. Starting a video in my "Star Trek" folder works with the preset mplayer option, but when I modify apps.py to fire my custom vlc-launching script, vlc complains:

I don't know what your script looks like, but you seem to need to escape spaces in your command.
Does your script end like this?

return "vlc -option1 -blabla " + c.file

Then try changing to this, as this will avoid the shell and the need to escape spaces altogether.

return tup("vlc", "-option1", "-blabla", *c.files)

Or this:

from ranger.ext.shell_escape import shell_quote
return "vlc -option1 -blabla " + shell_quote(c.file)

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

Offline

#882 2011-03-19 13:05:56

galymzhan
Member
Registered: 2010-12-25
Posts: 7

Re: Ranger, a textbased filemanager

mv can't move entire directories. If you want to move dir you can 'dd' (cut) it, cd to directory where you want to paste and execute:

:shell cp -R %c . && rm -R %c

Offline

#883 2011-03-19 19:44:25

Arthenik
Member
Registered: 2010-02-13
Posts: 44

Re: Ranger, a textbased filemanager

Hut, my vlc-launching script is here. It's an external bash script that circumvents a few issues that video playback has on my machine. I also included where I have defined vlcx in .config/ranger/apps.py.

EDIT: Solved, turns out I was a victim of my own horrible scripting. Sorry for taking your time.

Last edited by Arthenik (2011-03-19 19:59:15)

Offline

#884 2011-03-21 20:41:14

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

Re: Ranger, a textbased filemanager

galymzhan wrote:

mv can't move entire directories. If you want to move dir you can 'dd' (cut) it, cd to directory where you want to paste and execute:

:shell cp -R %c . && rm -R %c

An alternative is mv %c/* -t %f but it omits hidden files iirc and conserves the original directory


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

Offline

#885 2011-03-21 21:24:21

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

Re: Ranger, a textbased filemanager

hut wrote:

Because :delete is dangerous, there is no shorter command

"If you stop users from doing dumb things, you also stop them from doing clever things".

I want to delete files with minimal keystrokes.  If i destroy my data, it's own fault.
I saw the 'DD' bind on https://wiki.archlinux.org/index.php/Ra … nding_keys but that means you still need to select files first.  Can I create a shortcut for "delete the file under the cursorline" ?

Why not handle deletions like how vim handles deletions of text?
that is: when users hits 'd' on a selection (or 'dd' on a line), remove the inode from the filesystem (but keep a reference in ranger, so the filesystem doesn't actually remove the data), then the user can do 'p' to paste it again.
if the user quits ranger, the references disappear, so that when the refcount becomes 0 the filesystem will delete the data (just like text you cut in vim can be pasted again as long as you don't close vim); if the user deletes new files in ranger, it can forget about the previous references and keep references for the new files (again, just like if you would do the same in vim, you can only paste the most recently cut text)

maybe it's just me, but I find deleting files in ranger quite a stumbling block and it hinders my workflow.

Last edited by Dieter@be (2011-03-22 10:09:24)


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#886 2011-03-21 22:37:16

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

Re: Ranger, a textbased filemanager

Dieter@be wrote:
hut wrote:

Because :delete is dangerous, there is no shorter command

"If you stop users from doing dumb things, you also stop them from doing clever things".

I want to delete files with minimal keystrokes.  If i destroy my data, it's own fault.
I saw the 'DD' bind on https://wiki.archlinux.org/index.php/Ra … nding_keys but that means you still need to select files first.  Can I create a shortcut for "delete the file under the cursorline" ?

The selection is defined as:
if you marked anything (with space, etc) then it's the marked files
otherwise its the file under the cursor, as long as there's any file in the directory.

The shortcut for deleting the selection is:

map('DD', fm.console_execute("delete yes"))
Dieter@be wrote:

Why not handle deletions like how vim handles deletions of text?
that is: when users hits 'd' on a selection (or 'dd' on a line), remove the inode from the filesystem (but keep a reference in ranger, so it doesn't actually get unlinked by the filesystem), then the user can do 'p' to paste it again.
if the user quits ranger, the references disappear, so the file gets unlinked (just like text you cut in vim can be pasted again as long as you don't close vim); if the user deletes new files in ranger, it can forget about the previous references and keep references for the new files (again, just like if you would do the same in vim, you can only paste the most recently cut text)

maybe it's just me, but I find deleting files in ranger quite a stumbling block and it hinders my workflow.

I thought about this, but I have two problems with it:
1. I think that files are no text and shouln't be handled exactly like text, since files are generally much more difficult to reproduce after a mistake. Allowing a simple copy move-operation ("dd" -> move around -> "p") to destroy data (e.g. in case of a ranger crash) is unacceptable
2. I doubt that it's FS- and OS-independent

Youre of course free to implement your idea and share it with us.

I've been thinking of this instead: There is one key combination which yanks files, namely "yy" (plus yj, yk, ygg and so on) and multiple key combinations which let you run shell commands on this set of yanked files. You would then be able to decide whether you want to move or copy this file by pressing the appropriate keys. For example pp for ":shell cp -v %c ." and PP for ":shell mv -v %c .". By using some specific key as a prefix, ranger will open the console with this shell command and let you modify it to your specific needs. For example ",pp" would open the console with the text ":shell cp -v %c ." for you to edit.
The implementation would be trivial but it would diverge even more from vims keybindings so I'm hesitating.

Last edited by hut (2011-03-21 22:45:22)


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

Offline

#887 2011-03-22 10:40:54

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

Re: Ranger, a textbased filemanager

hut wrote:

1. I think that files are no text and shouln't be handled exactly like text, since files are generally much more difficult to reproduce after a mistake. Allowing a simple copy move-operation ("dd" -> move around -> "p") to destroy data (e.g. in case of a ranger crash) is unacceptable

right, I wouldn't want a ranger crash to cause deletions of my files.
a slight alteration of my approach: when user hits dd, just move the file to a tmp directory, for example ~/.local/share/ranger/files-in-movement, but keep this this transparent for the user.  this way you have a directory entry with the same basename pointing to an inode with the same permissions and what not, on disk, in case ranger crashes. whatever happens, if the user panics or ranger crashes, he can always easily get his files back from there.
this allows a quicker and more vim-like workflow.  only downside is: this only works fast if ~/.local/share/ranger/ is on the same file system as the user is 'dd'ing files on. (for other filesystems we could maybe prompt for a different directory to use, and store it in the config)

hut wrote:

2. I doubt that it's FS- and OS-independent

Which OS'es do you target?
AFAIK it goes for all Linux filesystems (and hence probably for other unices as well) that a filesystem keeps the file data as long as there is at least 1 reference to it (be it a hardlink/inode or a file descriptor from a running program)

hut wrote:

Youre of course free to implement your idea and share it with us.

sorry, I wish I had time to contribute code, but I don't. I can only contribute thoughts and ideas.

hut wrote:

I've been thinking of this instead: There is one key combination which yanks files, namely "yy" (plus yj, yk, ygg and so on) and multiple key combinations which let you run shell commands on this set of yanked files. You would then be able to decide whether you want to move or copy this file by pressing the appropriate keys. For example pp for ":shell cp -v %c ." and PP for ":shell mv -v %c .". By using some specific key as a prefix, ranger will open the console with this shell command and let you modify it to your specific needs. For example ",pp" would open the console with the text ":shell cp -v %c ." for you to edit.
The implementation would be trivial but it would diverge even more from vims keybindings so I'm hesitating.

err. I don't quite follow, but then again, I haven't figured the exact behavior of the binds out.
FWIW maybe it's just me, but I find the descriptions in the manpage quite unclear, and some bindings seem counterintuitive.
for example:

yy     Yank the selection.  (mark the files as copied)
dd     Cut the selection

yy: "mark the files as copied"? mark them how? where? what's the point, if they are not even copied at this point?
dd: how do you mean, "cut" ? they are still visible on my display, from a vim point of view I would expect the lines to be gone from my display.  So what does this bind really *do* ?


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#888 2011-03-22 11:28:47

Revolt
Member
From: Portugal
Registered: 2009-06-11
Posts: 71
Website

Re: Ranger, a textbased filemanager

It adds the file paths to an array of copied files. When you press dd it also sets a move flag to true.

Then the paste action (called by yy) parses the aforementioned array and depending on the value of the flag either moves or copies them.

Last edited by Revolt (2011-03-22 11:29:35)

Offline

#889 2011-03-22 16:04:39

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

Re: Ranger, a textbased filemanager

Dieter@be wrote:
hut wrote:

1. I think that files are no text and shouln't be handled exactly like text, since files are generally much more difficult to reproduce after a mistake. Allowing a simple copy move-operation ("dd" -> move around -> "p") to destroy data (e.g. in case of a ranger crash) is unacceptable

right, I wouldn't want a ranger crash to cause deletions of my files.
a slight alteration of my approach: when user hits dd, just move the file to a tmp directory, for example ~/.local/share/ranger/files-in-movement, but keep this this transparent for the user.  this way you have a directory entry with the same basename pointing to an inode with the same permissions and what not, on disk, in case ranger crashes. whatever happens, if the user panics or ranger crashes, he can always easily get his files back from there.
this allows a quicker and more vim-like workflow.  only downside is: this only works fast if ~/.local/share/ranger/ is on the same file system as the user is 'dd'ing files on. (for other filesystems we could maybe prompt for a different directory to use, and store it in the config)

That's the thing that vifm does if i recall correctly, and even an early version of ranger. You named the problem already. I don't know, maybe I can add this as an alternative method for copying + pasting.

Dieter@be wrote:
hut wrote:

I've been thinking of this instead: There is one key combination which yanks files, namely "yy" (plus yj, yk, ygg and so on) and multiple key combinations which let you run shell commands on this set of yanked files. You would then be able to decide whether you want to move or copy this file by pressing the appropriate keys. For example pp for ":shell cp -v %c ." and PP for ":shell mv -v %c .". By using some specific key as a prefix, ranger will open the console with this shell command and let you modify it to your specific needs. For example ",pp" would open the console with the text ":shell cp -v %c ." for you to edit.
The implementation would be trivial but it would diverge even more from vims keybindings so I'm hesitating.

err. I don't quite follow, but then again, I haven't figured the exact behavior of the binds out.
FWIW maybe it's just me, but I find the descriptions in the manpage quite unclear, and some bindings seem counterintuitive.
for example:

yy     Yank the selection.  (mark the files as copied)
dd     Cut the selection

yy: "mark the files as copied"? mark them how? where? what's the point, if they are not even copied at this point?
dd: how do you mean, "cut" ? they are still visible on my display, from a vim point of view I would expect the lines to be gone from my display.  So what does this bind really *do* ?

Yeah, as Revolt said. To copy a file from here to ~/, you can use yyghpp. To move it instead, use ddghpp. You can fine-tune this with different paste commands, e.g. yyghpo (po for paste + overwrite everything) or yyghpl (for paste a symlink).

And my thought was to make the choice whether to copy or move at the time of pasting. Basically replacing "dd" with just another paste command, e.g. pd for paste + delete, or perhaps PP. Copying to ~/ would still be yyghpp and moving to ~/ would be yyghpd or yyghPP.

The good thing about this is it would be more consistent and cleaner in the code. Since "dd" doesn't work quite like in vim anyway, maybe we should scrap that key altogether and use variations of p... keys since they make more sense when dealing with files.
Anyway, I'll test it myself for a while and see how it goes.


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

Offline

#890 2011-03-22 20:52:49

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

Re: Ranger, a textbased filemanager

Revolt wrote:

It adds the file paths to an array of copied files. When you press dd it also sets a move flag to true.

What is "It" ? "yy" ?

Revolt wrote:

Then the paste action (called by yy) parses the aforementioned array and depending on the value of the flag either moves or copies them.

didn't you mean "called by pp" ?


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#891 2011-03-22 21:34:54

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

Re: Ranger, a textbased filemanager

Dieter@be wrote:
Revolt wrote:

It adds the file paths to an array of copied files. When you press dd it also sets a move flag to true.

What is "It" ? "yy" ?

Revolt wrote:

Then the paste action (called by yy) parses the aforementioned array and depending on the value of the flag either moves or copies them.

didn't you mean "called by pp" ?

Let me say it in code:

yy: copied = get_selection(); cut = False
dd: copied = get_selection(); cut = True
pp: subprocess.call(["mv" if cut else "cp", "-t", "."] + list(copied))  # very simplified

and yeah he probably meant "called by pp"

Last edited by hut (2011-03-22 21:36:44)


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

Offline

#892 2011-03-22 23:37:58

Revolt
Member
From: Portugal
Registered: 2009-06-11
Posts: 71
Website

Re: Ranger, a textbased filemanager

Indeed I did. Sorry for the confusion Dieter.

Offline

#893 2011-03-23 12:35:48

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

Re: Ranger, a textbased filemanager

1) So I would propose to change the man documentation, instead of:

yy     Yank the selection.  (mark the files as copied)

       dd     Cut the selection

       pp     Paste the copied/cut files.  By default, this will not overwrite existing files.  To overwrite them, use po.

how about:

yy     Yank the selected filenames to "copy" buffer and mark the files as to be copied.

       dd     Cut the selected filenames to "copy" buffer and mark the files as to be moved.

       pp     Paste the files in "copy" buffer (by moving or copying depending on how they are marked).  By default, this will not overwrite existing files.  To overwrite them, use po.

imho this is a lot clearer.  just need to think of a better name then "copy buffer".

2)
Btw the

map('DD', fm.execute_console("delete yes"))

bind works great! (just note: execute_console, not console_execute)

3) how does the automatic "knowing what to open a file with" work? is it a component that can also be used outside of ranger?

4) Revolt: that's an awesome avatar, what's the story behind it?

5) Feature request:
if the current directory (or any anchestor) contains .git or .svn, mark files in ranger if they appear in `svn status` or `git status`; I especially want to see files which are "new" (untracked in the repo) and those who have any modifications to them. if there are new/modified files in a subdir, mark the subdir (but make in clear somehow we don't talk about the subdir itself, but rather one of the files in it)

Last edited by Dieter@be (2011-03-23 15:13:42)


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#894 2011-03-23 19:44:45

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

Re: Ranger, a textbased filemanager

Dieter@be wrote:

1) So I would propose to change the man documentation, instead of:

yy     Yank the selection.  (mark the files as copied)

       dd     Cut the selection

       pp     Paste the copied/cut files.  By default, this will not overwrite existing files.  To overwrite them, use po.

how about:

yy     Yank the selected filenames to "copy" buffer and mark the files as to be copied.

       dd     Cut the selected filenames to "copy" buffer and mark the files as to be moved.

       pp     Paste the files in "copy" buffer (by moving or copying depending on how they are marked).  By default, this will not overwrite existing files.  To overwrite them, use po.

imho this is a lot clearer.  just need to think of a better name then "copy buffer".

i'll do that.

Dieter@be wrote:

3) how does the automatic "knowing what to open a file with" work? is it a component that can also be used outside of ranger?

It's somewhat complicated. Basically there's ranger.core.runner which is an abstraction layer to subprocess.Popen and which allows you to specify parameters such as "fork the program to background!", "pipe its output to a pager!", etc. and another class at ranger.api.apps which determines a default application and ways of running them.
On the user side, there's the configuration file apps.py (get it with `ranger --copy-config=apps`) where you can program/tweak this application detection mechanism.
For more information, look around in the docstrings and type 2? in ranger.

It's available outside of ranger, yeah. You can just type ranger <filename>. ;D

Dieter@be wrote:

5) Feature request:
if the current directory (or any anchestor) contains .git or .svn, mark files in ranger if they appear in `svn status` or `git status`; I especially want to see files which are "new" (untracked in the repo) and those who have any modifications to them. if there are new/modified files in a subdir, mark the subdir (but make in clear somehow we don't talk about the subdir itself, but rather one of the files in it)

Thanks for the suggestion. Can't tell you when/if it's gonna get implemented, I have hardly any time to code atm.


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

Offline

#895 2011-03-23 20:18:22

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

Re: Ranger, a textbased filemanager

hut wrote:
Dieter@be wrote:

3) how does the automatic "knowing what to open a file with" work? is it a component that can also be used outside of ranger?

It's somewhat complicated. Basically there's ranger.core.runner which is an abstraction layer to subprocess.Popen and which allows you to specify parameters such as "fork the program to background!", "pipe its output to a pager!", etc. and another class at ranger.api.apps which determines a default application and ways of running them.
On the user side, there's the configuration file apps.py (get it with `ranger --copy-config=apps`) where you can program/tweak this application detection mechanism.
For more information, look around in the docstrings and type 2? in ranger.

It's available outside of ranger, yeah. You can just type ranger <filename>. ;D

interesting.  I see mimeopen is in there.  I was wondering which I should use (mimeopen or ranger) for automatic "open with" settings. I plan to open files from inside ranger, from the shell, and from a variety of other apps (browser, mail client, etc).

Last edited by Dieter@be (2011-03-23 20:19:20)


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#896 2011-04-03 14:04:17

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

Re: Ranger, a textbased filemanager

hut wrote:
Dieter@be wrote:

5) Feature request:
if the current directory (or any anchestor) contains .git or .svn, mark files in ranger if they appear in `svn status` or `git status`; I especially want to see files which are "new" (untracked in the repo) and those who have any modifications to them. if there are new/modified files in a subdir, mark the subdir (but make in clear somehow we don't talk about the subdir itself, but rather one of the files in it)

Thanks for the suggestion. Can't tell you when/if it's gonna get implemented, I have hardly any time to code atm.

anyone who has time to give this a shot?
I tried looking at the ranger code but it's a bit too complicated for me.

Btw, I found a bug:

$ ranger apps.py
Traceback (most recent call last):
  File "/usr/lib/python3.2/site-packages/ranger/fsobject/fsobject.py", line 148, in mimetype
    return self._mimetype
AttributeError: 'File' object has no attribute '_mimetype'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/ranger", line 51, in <module>
    sys.exit(ranger.main())
  File "/usr/lib/python3.2/site-packages/ranger/core/main.py", line 62, in main
    runner(files=[File(target)], mode=arg.mode, flags=arg.flags)
  File "/usr/lib/python3.2/site-packages/ranger/core/runner.py", line 143, in __call__
    action = self.apps.apply(app, context)
  File "/usr/lib/python3.2/site-packages/ranger/api/apps.py", line 104, in apply
    return handler(context)
  File "/home/dieter/.config/ranger/apps.py", line 86, in app_default
    if f.mimetype is not None:
  File "/usr/lib/python3.2/site-packages/ranger/fsobject/fsobject.py", line 150, in mimetype
    self.set_mimetype()
  File "/usr/lib/python3.2/site-packages/ranger/fsobject/fsobject.py", line 128, in set_mimetype
    self._mimetype = self.fm.mimetypes.guess_type(basename, False)[0]
AttributeError: 'FM' object has no attribute 'mimetypes'

Same problem with a .sh file, for .html files it works.


< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#897 2011-04-03 14:16:53

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

Re: Ranger, a textbased filemanager

Fixed.
Also I recommend you to wait if anyone plans to do major changes to rangers code, since I'm currently rewiring the whole thing and your stuff might not be compatible in the end.


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

Offline

#898 2011-04-08 21:54:02

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

Re: Ranger, a textbased filemanager

hut wrote:
konlaasz wrote:

Thanks for this very fine file manager!

Here's a tiny patch for apps.py ('flags='d'' is set again further down for evince; evince also supports djvu (and ps/ps.gz, too)):

--- /usr/lib/python3.2/site-packages/ranger/defaults/apps.py    2011-03-06 21:11:09.000000000 +0200
+++ /tmp/apps.py    2011-03-06 21:20:48.156668915 +0200
@@ -65,8 +65,9 @@
 
         if f.extension is not None:
             if f.extension in ('pdf', ):
-                c.flags += 'd'
                 return self.either(c, 'evince', 'zathura', 'apvlv')
+            if f.extension in ('djvu', ):
+                return self.either(c, 'evince')
             if f.extension in ('xml', ):
                 return self.either(c, 'editor')
             if f.extension in ('html', 'htm', 'xhtml'):

when running 'source ranger ranger', I get 'bash: $'\177:': command not found'. I'm not entirely sure that this is caused by something in ranger, but perhaps it is?

Thanks for the patch. Guys, give me more of these! smile

I have no idea about the bug though... makes no sense to me sad
Check the readme for an alternative to "source ranger ranger"

Turns out this is a problem with newer versions of bash. /usr/bin/ranger contains the line

"""":

which generates this error. To avoid it, cat /usr/bin/ranger and put the code between """": and """ into a bash function, like this:

function ranger {
    /usr/bin/ranger --fail-unless-cd &&
    if [ -z "$XDG_CONFIG_HOME" ]; then
        cd "$(grep \^\' ~/.config/ranger/bookmarks | cut -b3-)"
    else
        cd "$(grep \^\' "$XDG_CONFIG_HOME"/ranger/bookmarks | cut -b3-)"
    fi
}

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

Offline

#899 2011-04-11 23:53:16

anon27
Member
Registered: 2010-11-10
Posts: 18

Re: Ranger, a textbased filemanager

Outstanding file manager. Thank you very much.

Couple of questions:

1) Some programs that have been opened through Ranger will close if Ranger is closed. Is it possible to separate the processes so that it works like if I was using nohup?

2) For opening images I’m trying to use a script that lets me cycle through all the pics in a directory using feh. It works fine by itself  but if I add arguments I get the error “first argument is not a file”. This is what I have in apps.py:

class CustomApplications(Applications):
    def feh_cycle(self, c):
        return tup(‘feh-cycle’, ‘-FY’, *c)

    def app_default(self, c):
        f = c.file
        if f.image:
            return self.feh_cycle(c)

And this is the script in question just in case it has nothing to do with me sucking at python:

#!/bin/bash

shopt -s nullglob

if [[ ! -f $1 ]]; then
    echo “$0: first argument is not a file” >&2
    exit 1
fi

file=$(basename -- “$1”)
dir=$(dirname -- “$1”)
arr=()
shift

cd -- “$dir”

for i in *; do
    [[ -f $i ]] || continue
    arr+=(“$i”)
    [[ $i == $file ]] && c=$((${#arr[@]} - 1))
done

exec feh “$@” -- “${arr[@]:c}” “${arr[@]:0:c}”                 

Offline

#900 2011-04-12 00:02:55

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

Re: Ranger, a textbased filemanager

anon27 wrote:

Outstanding file manager. Thank you very much.

Couple of questions:

1) Some programs that have been opened through Ranger will close if Ranger is closed. Is it possible to separate the processes so that it works like if I was using nohup?

2) For opening images I’m trying to use a script that lets me cycle through all the pics in a directory using feh. It works fine by itself  but if I add arguments I get the error “first argument is not a file”. This is what I have in apps.py:

class CustomApplications(Applications):
    def feh_cycle(self, c):
        return tup(‘feh-cycle’, ‘-FY’, *c)

    def app_default(self, c):
        f = c.file
        if f.image:
            return self.feh_cycle(c)

And this is the script in question just in case it has nothing to do with me sucking at python:

#!/bin/bash

shopt -s nullglob

if [[ ! -f $1 ]]; then
    echo “$0: first argument is not a file” >&2
    exit 1
fi

file=$(basename -- “$1”)
dir=$(dirname -- “$1”)
arr=()
shift

cd -- “$dir”

for i in *; do
    [[ -f $i ]] || continue
    arr+=(“$i”)
    [[ $i == $file ]] && c=$((${#arr[@]} - 1))
done

exec feh “$@” -- “${arr[@]:c}” “${arr[@]:0:c}”                 

1. Army did that already, see here: (the entry of mupdf)
https://bbs.archlinux.org/viewtopic.php … 62#p869262
and don't forget to add the fix in the following post.

2. Well, the first argument is -FY, not a file


"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