You are not logged in.

#776 2011-01-08 03:36:49

zeltak
Member
From: New England
Registered: 2010-08-07
Posts: 168

Re: Ranger, a textbased filemanager

hya hut

im working on creating another ranger color scheme to share with the community. is there a way that the current line (the line in the current position you are) will not change colors by file type but always stay a user defined color?

Also is there any documentation regarding the color schemes (preferably one that understandable for non programmers) smile?


thx

zeltak

Last edited by zeltak (2011-01-08 03:38:37)

Offline

#777 2011-01-08 04:29:00

yvonney
Member
Registered: 2008-06-11
Posts: 671

Re: Ranger, a textbased filemanager

UPDATE: appears that xcode has the gnu compiler built in... i think.

looking for tips on installing ranger for someone on a Mac.
Xcode on Mac is installed and so is python 2.6.x
Done a bit of searching though asking here.
1- download stable ranger  tar.gz
2- extract on mac system
3- xcode requires just, "make" i read about.

YET, thinking that installing GNU compiler so I can do the ./configure, make thing is required/best.
SO, use mac ports to install GNU compiler? Which compiler package? (can likely figure that out though)
OR, can i take my prebuild (via AUR) ranger-git package, move it to Mac and install somehow? (no likely I bet)

Thanks for help, sorry i haven't figured it out. crazy busy.

Last edited by yvonney (2011-01-08 05:51:24)

Offline

#778 2011-01-08 07:30:28

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

Re: Ranger, a textbased filemanager

zeltak wrote:

hya hut

im working on creating another ranger color scheme to share with the community. is there a way that the current line (the line in the current position you are) will not change colors by file type but always stay a user defined color?

Also is there any documentation regarding the color schemes (preferably one that understandable for non programmers) smile?


thx

zeltak

like

if context.in_browser and context.main_column and context.selected:
  fg = red
  bg = blue

somewhere at the end of the function?
It's all python code so it has to fit into the flow of the function but if you just want to override something its safest to put it at the end. (before the return statement!)

There is documentation at doc/colorschemes.txt
You could have also browsed rangers pydoc pages, e.g.:
http://ranger.nongnu.org/pydoc/ranger.g … cheme.html
And I suppose you've already looked at the default colorscheme.

Basically It's a function which has to return 3 values, foreground color, background color and attribute (like bold, etc). And you have this context object with tons of attributes which are either true or false depending on the place you're currently at in the code.
If ranger requests the color of the current line, it sets context.in_browser and context.main_column and context.selected (and others) to True. You can check for these attributes and set the color accordingly.

yvonney wrote:

UPDATE: appears that xcode has the gnu compiler built in... i think.

looking for tips on installing ranger for someone on a Mac.
Xcode on Mac is installed and so is python 2.6.x
Done a bit of searching though asking here.
1- download stable ranger  tar.gz
2- extract on mac system
3- xcode requires just, "make" i read about.

YET, thinking that installing GNU compiler so I can do the ./configure, make thing is required/best.
SO, use mac ports to install GNU compiler? Which compiler package? (can likely figure that out though)
OR, can i take my prebuild (via AUR) ranger-git package, move it to Mac and install somehow? (no likely I bet)

Thanks for help, sorry i haven't figured it out. crazy busy.

In fact you can skip step 3. Just extract and run ranger, for example with "python /path/to/ranger.py". You can make a bash alias for that. Ranger needs no GNU compiler, just python.
If you want to install it, "make install" should work, with root privileges.


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

Offline

#779 2011-01-08 15:26:27

zeltak
Member
From: New England
Registered: 2010-08-07
Posts: 168

Re: Ranger, a textbased filemanager

Hi Hut

Thanks for the answer, i really appreciate the detailed answer but as i said i am no programmer (far from it....) and have zero python understanding. if thats a requirement to create a color-scheme i guess ill just raise the white flag smile
i did try what you suggested:

if context.in_browser and context.main_column and context.selected:
  fg = red
  bg = blue

and put it at the end (before the return) but always get a error messages. i tried it in different configurations (deleting the original if context browser etc) and different themes but always with no success...

thanks again

Zeltak

Last edited by zeltak (2011-01-08 15:27:35)

Offline

#780 2011-01-09 21:05:36

essence-of-foo
Member
Registered: 2008-07-12
Posts: 84

Re: Ranger, a textbased filemanager

When I use the :shell command, I immediately get back to ranger once the command is executed. If there is any error with the program I executed I won't see the error message because it's gone by too fast.
It's probably not a big deal to make a "press any key to continue"-patch for myself but maybe I'm just not using the most elegant approach for executing external commands and I'd like to hear from others how they execute external commands.

And is there a way to mark files with wildcards or regular expressions?

Offline

#781 2011-01-09 22:23:53

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

Re: Ranger, a textbased filemanager

essence-of-foo wrote:

When I use the :shell command, I immediately get back to ranger once the command is executed. If there is any error with the program I executed I won't see the error message because it's gone by too fast.
It's probably not a big deal to make a "press any key to continue"-patch for myself but maybe I'm just not using the most elegant approach for executing external commands and I'd like to hear from others how they execute external commands.

And is there a way to mark files with wildcards or regular expressions?

Hi, let me refer you to chapter 3.2 of the manual, type 32? to get there. It's a list of all commands, including one to mark files by regular expressions. It also explains that the shell-command takes additional arguments, called flags. Flags are explained in chapter 2.5 (25?). Flags modify the behaviour of programs and the "w" flag is probably the one you're looking for. Try :shell -w ls


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

Offline

#782 2011-01-10 20:07:37

essence-of-foo
Member
Registered: 2008-07-12
Posts: 84

Re: Ranger, a textbased filemanager

Wow. Nice. Thank you very much smile

Offline

#783 2011-01-10 23:01:42

caminoix
Member
From: cracow, poland
Registered: 2005-07-12
Posts: 162
Website

Re: Ranger, a textbased filemanager

I made a qad colorscheme to match my Vim colours. You can take a look at it here. [edit] A screenshot is here. [/edit] Any comments appreciated.

Last edited by caminoix (2012-10-07 17:30:59)

Offline

#784 2011-01-11 17:48:12

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

Re: Ranger, a textbased filemanager

Can you make a screenshot? I got no 256color terminal^^

Also consider adding it to the wiki: http://ourproject.org/moin/projects/ranger


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

Offline

#785 2011-01-12 00:16:20

caminoix
Member
From: cracow, poland
Registered: 2005-07-12
Posts: 162
Website

Re: Ranger, a textbased filemanager

hut wrote:

Can you make a screenshot? I got no 256color terminal^^
Also consider adding it to the wiki: http://ourproject.org/moin/projects/ranger

Done.

Btw, is it possible to integrate ranger with autojump?

At any rate, a great piece of software it is! Keep it up smile

Offline

#786 2011-01-23 10:20:20

archman-cro
Member
From: Croatia
Registered: 2010-04-04
Posts: 943
Website

Re: Ranger, a textbased filemanager

Can I use "map('ć', fm.move(down=1)" and other letters like ščž for a browser direction keys? In example, for javascript "\u0107" corresponds to "ć".

Offline

#787 2011-01-23 14:14:43

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

Re: Ranger, a textbased filemanager

archman-cro wrote:

Can I use "map('ć', fm.move(down=1)" and other letters like ščž for a browser direction keys? In example, for javascript "\u0107" corresponds to "ć".

You should be able to. Have you tried?
Make sure to write this at the top of the file:

# -*- coding: utf-8 -*-


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

Offline

#788 2011-01-23 18:39:11

archman-cro
Member
From: Croatia
Registered: 2010-04-04
Posts: 943
Website

Re: Ranger, a textbased filemanager

I added 'map('ć', fm.move(down=1))' in 'keys.py' under the "browser context" part.
I also have the '# -*- coding: utf-8 -*-' in the first line.
It won't work that way. Do I need to use an escape sequence?

Last edited by archman-cro (2011-01-23 21:53:16)

Offline

#789 2011-01-24 12:17:08

botzoboy
Member
From: Romania/Deutschland
Registered: 2010-02-03
Posts: 90

Re: Ranger, a textbased filemanager

The new Thunar has some problems and I want to switch to Ranger as my default FM. So I have some questions if Ranger can:
1. to manage Trash (delete into, recover from or empty Trash) ?
2. to manage removable devices (mount, unmount) ?

Offline

#790 2011-01-25 17:40:23

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

Re: Ranger, a textbased filemanager

archman-cro wrote:

I added 'map('ć', fm.move(down=1))' in 'keys.py' under the "browser context" part.
I also have the '# -*- coding: utf-8 -*-' in the first line.
It won't work that way. Do I need to use an escape sequence?

I think it's most likely because of python3.
Sorry folks, if you want international hotkeys with ranger, it seems like you need to run it with python2. I really have no time to fix this atm.

botzoboy wrote:

The new Thunar has some problems and I want to switch to Ranger as my default FM. So I have some questions if Ranger can:
1. to manage Trash (delete into, recover from or empty Trash) ?
2. to manage removable devices (mount, unmount) ?

Hi botzoboy. Ranger has no such features built in by default but you can add them yourself.
Maybe take some hints from here: https://wiki.archlinux.org/index.php/Ranger


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

Offline

#791 2011-01-25 20:59:52

botzoboy
Member
From: Romania/Deutschland
Registered: 2010-02-03
Posts: 90

Re: Ranger, a textbased filemanager

Thanks hut!!!
Solved now with Trash, remain to figure out how to manage removable devices.

Offline

#792 2011-01-25 21:05:57

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

Re: Ranger, a textbased filemanager

botzoboy wrote:

Thanks hut!!!
Solved now with Trash, remain to figure out how to manage removable devices.

I do this with /etc/fstab and bindings for "shell mount %f" and "shell umount %f".


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

Offline

#793 2011-01-25 22:21:45

hellnest
Member
From: $ dmesg | grep ATA
Registered: 2010-11-11
Posts: 194
Website

Re: Ranger, a textbased filemanager

Can't find Ranger inside python2.6, the folder from wiki isn't exist and replaced to python2.7. So where can i found a 'template'?


roll Snapping my own life roll
hmmgithubhmm
coolMyBlogcool

Offline

#794 2011-01-26 07:50:32

botzoboy
Member
From: Romania/Deutschland
Registered: 2010-02-03
Posts: 90

Re: Ranger, a textbased filemanager

hellnest wrote:

Can't find Ranger inside python2.6, the folder from wiki isn't exist and replaced to python2.7. So where can i found a 'template'?

You can find it inside python3.1/site-packages/

Offline

#795 2011-01-26 13:36:52

hellnest
Member
From: $ dmesg | grep ATA
Registered: 2010-11-11
Posts: 194
Website

Re: Ranger, a textbased filemanager

^
Thanks for the info smile


roll Snapping my own life roll
hmmgithubhmm
coolMyBlogcool

Offline

#796 2011-01-28 20:46:51

botzoboy
Member
From: Romania/Deutschland
Registered: 2010-02-03
Posts: 90

Re: Ranger, a textbased filemanager

aunpack is not working. when i open an archive it show me the unpacking process in the pager and stay like this until I press q key but the archive is not unpacked.

:shell aunpack f% is working

Offline

#797 2011-01-28 21:35:52

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

Re: Ranger, a textbased filemanager

botzoboy wrote:

aunpack is not working. when i open an archive it show me the unpacking process in the pager and stay like this until I press q key but the archive is not unpacked.

:shell aunpack f% is working

it only lists the content.
try 1<enter> to unpack and type 24? to learn what this means


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

Offline

#798 2011-01-28 23:18:14

botzoboy
Member
From: Romania/Deutschland
Registered: 2010-02-03
Posts: 90

Re: Ranger, a textbased filemanager

Thank you hut!!
Regarding (un)mount removable devices I use udisks with this script. I think it will be a nice feature to include this in Ranger.
All the best an thanks again.

Last edited by botzoboy (2011-01-29 17:05:15)

Offline

#799 2011-02-07 13:47:12

sighter
Member
Registered: 2008-11-23
Posts: 13

Re: Ranger, a textbased filemanager

Hello,

Thank you for this massive filemanager, it is the first fm which fits to my needs.
What is better as a complete python api to customize the ranger :-)

So i have no questions. Only a code snippet for the people who wants.

It adds music files to mpc if they are in the library

import statements

import os.path

body

# non trivial adding to mpc
def app_ncmpcpp(self, c):
    mpc_args = []
    mpd_root = "/media/win3/soundconsum/"
    # strip mpd_root from filepaths
    for f in c.files:
        real_path = os.path.realpath(str(f))
        if real_path.startswith(mpd_root) == True:
            mpc_args.append(real_path.replace(mpd_root, ''))

    if len(mpc_args) == 0:
        return tup('mpc')

    return tup('mpc', 'add') + tuple(mpc_args)

later in the app_default function you have to add

if f.audio:
    return self.app_ncmpcpp(c)

Be sure to reindent the code after pasting and change mpd_root to your needs!!

Last edited by sighter (2011-02-07 13:53:13)

Offline

#800 2011-02-07 15:18:19

FarmerF
Member
From: Netherlands
Registered: 2009-06-08
Posts: 76

Re: Ranger, a textbased filemanager

botzoboy wrote:

Thanks hut!!!
Solved now with Trash, remain to figure out how to manage removable devices.

Though the solution on the wiki page works as a trash for ranger the files won't show up in Thunar's trash. I solved this as follows but have not tested it with exotic filenames:

# move to trash
@map('DD')
def movetotrash(arg):
   trash_dir = "/home/fdeboer/.local/share/Trash"
   selection = arg.fm.env.get_selection()
   import datetime
   for item in selection:
      file = os.path.split(str(item))[1]
      with open(os.path.join(trash_dir,"info",file +".trashinfo"),'w') as info:
              info.write("[Trash Info]\n")
              info.write("Path="+str(item)+"\n")
              dTime = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
              info.write("DeletionDate="+dTime+"\n")
   arg.fm.run(['mv', '-t', os.path.join(trash_dir,"files")] + [str(f) for f in selection])

This creates a file.trashinfo file which Thunar uses to show the original location and deletion time and allows Thunar to undelete.

Offline

Board footer

Powered by FluxBB