You are not logged in.

#1476 2012-10-06 19:13:35

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

Re: Ranger, a textbased filemanager

@jk121960:
I cannot reproduce the issue here.
Have you tried to run ranger with the --clean option? It permits to ignore your configuration, to see if you have this problem with the default config too.

Offline

#1477 2012-10-06 22:13:16

jk121960
Member
From: Palos Hills, Illinois
Registered: 2011-12-09
Posts: 254

Re: Ranger, a textbased filemanager

Hi and thanks, I will give that a try, I didn't know of this option. I will post back what I find

--jerry


Arch Awesome, Ranger & Vim the coding triple threat.

Offline

#1478 2012-10-06 22:19:53

jk121960
Member
From: Palos Hills, Illinois
Registered: 2011-12-09
Posts: 254

Re: Ranger, a textbased filemanager

@PotatoesMaster I did the --clean option and weirdly the native OO applications like '.ods' and '.odt' started working but not the MS extensions like doc and docx etc. Hopefully this gives a clue, cause I got nothing, Still if I use the 'r' command and type libreoffice they all work.

thanks for anything that comes to mind.

--jerry

Last edited by jk121960 (2012-10-07 08:23:26)


Arch Awesome, Ranger & Vim the coding triple threat.

Offline

#1479 2012-10-07 08:57:21

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

Re: Ranger, a textbased filemanager

@jk121960, @hut:
There is a problem in the default rifle.conf.

The line

ext docx?, has libreoffice, X, flag f = libreoffice -- "$@"

should be

ext docx?, has libreoffice, X, flag f = libreoffice "$@"

Offline

#1480 2012-10-07 13:40:59

jk121960
Member
From: Palos Hills, Illinois
Registered: 2011-12-09
Posts: 254

Re: Ranger, a textbased filemanager

PotatoesMaster wrote:

@jk121960, @hut:
There is a problem in the default rifle.conf.

The line

ext docx?, has libreoffice, X, flag f = libreoffice -- "$@"

should be

ext docx?, has libreoffice, X, flag f = libreoffice "$@"

OK thanks that worked, it has always been that syntax in this version, I thought that was for parsing of arguments and others are still done that way. Anyway that worked and that is whats important.

thanks again I appreciate it.

--jerry


Arch Awesome, Ranger & Vim the coding triple threat.

Offline

#1481 2012-10-09 10:25:14

ryzion
Member
Registered: 2012-03-20
Posts: 95

Re: Ranger, a textbased filemanager

loop wrote:
ryzion wrote:

Is there a way to quickly remove all filters from a list?

Could you explain, what exactly do you want to do?

Well lets say I've filtered my folder for "foo". What is the fastest way to get back to my unfiltered folder?

E: zf<enter> should be the quickest way, right?

Last edited by ryzion (2012-10-09 10:41:34)

Offline

#1482 2012-10-09 10:30:33

jk121960
Member
From: Palos Hills, Illinois
Registered: 2011-12-09
Posts: 254

Re: Ranger, a textbased filemanager

ryzion wrote:
loop wrote:
ryzion wrote:

Is there a way to quickly remove all filters from a list?

Could you explain, what exactly do you want to do?

Well lets say I've filtered my folder for "foo". What is the fastest way to get back to my unfiltered folder?

Use empty filter command

:filter<enter>

--jerry


Arch Awesome, Ranger & Vim the coding triple threat.

Offline

#1483 2012-10-09 10:43:53

ryzion
Member
Registered: 2012-03-20
Posts: 95

Re: Ranger, a textbased filemanager

Thanks, I've just discovered zf<enter>

Offline

#1484 2012-10-09 15:02:06

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: Ranger, a textbased filemanager

One less keystroke: <ctrl>-r   smile

Scott

Offline

#1485 2012-10-10 09:38:35

loop
Member
Registered: 2011-05-06
Posts: 58

Re: Ranger, a textbased filemanager

Hello!
I rename some files with the "rrname" command from my commands.py:

class rrname(Command):
	def execute(self):
		filenames = [f.basename for f in self.fm.thistab.get_selection()]
		for f in filenames:
			new_name = '-' + f
			self.fm.rename(f, new_name)

		# attempt to do something with renamed files
                self.fm.reload_cwd()
		with open('out', 'w') as log:
			cwd = self.fm.thisdir
			for fileobj in cwd.files:
				filename = fileobj.basename
				log.write(str(filename))

But after renaming, I can`t do something with renamed files, because cwd.files keeps old filenames (I can see it in "log" file). Is there any command instead of self.fm.reload_cwd(), to reload current directory, or it`s not so simple?

Actually, I want renamed files to stay marked after renaming. The whole code:

class rrname(Command):
	"""
	:rrname <file(s)>

	Prepends filename(s) of the selected file(s) with '-'
	"""
	do_mark = True

	def execute(self):
		filenames = [f.basename for f in self.fm.thistab.get_selection()]
		for f in filenames:
			new_name = '-' + f
			self.fm.rename(f, new_name)

		cwd = self.fm.thisdir
		for fileobj in cwd.files:
			filename = fileobj.basename
			if filename[0] == '-' and filename[1:] in filenames:
				cwd.mark_item(fileobj, val=self.do_mark)

		self.fm.ui.need_redraw = True

Offline

#1486 2012-10-12 04:11:15

darkfeline
Member
Registered: 2012-02-14
Posts: 94

Re: Ranger, a textbased filemanager

Hi,

I use the following in my rc.conf:

map S shell -d terminal --working-directory="%d" &

It's very convenient, but recently it's stopped working.  It opens the terminal in my home directory, not the current directory.  I've tried

map S console shell -d terminal --working-directory="%d" &

and I can see %d being expanded properly and hitting enter confirms that it works, but I can't get the original working again.  Any ideas where the problem may be?

EDIT:  Never mind, I've fixed the problem. 

map S shell -d terminal

works now (i.e., it opens the terminal in the current directory, even though it didn't work before, which is why I added the --working-directory in the first place.  Weird.  So probably something changed in the implementation somewhere, but I've solved my problem so I'm happy.

Last edited by darkfeline (2012-10-12 04:21:28)

Offline

#1487 2012-10-12 16:25:41

Veedrac
Member
Registered: 2011-07-19
Posts: 81

Re: Ranger, a textbased filemanager

loop wrote:

Hello!
I rename some files with the "rrname" command from my commands.py:

class rrname(Command):
	def execute(self):
		filenames = [f.basename for f in self.fm.thistab.get_selection()]
		for f in filenames:
			new_name = '-' + f
			self.fm.rename(f, new_name)

		# attempt to do something with renamed files
                self.fm.reload_cwd()
		with open('out', 'w') as log:
			cwd = self.fm.thisdir
			for fileobj in cwd.files:
				filename = fileobj.basename
				log.write(str(filename))

But after renaming, I can`t do something with renamed files, because cwd.files keeps old filenames (I can see it in "log" file). Is there any command instead of self.fm.reload_cwd(), to reload current directory, or it`s not so simple?

Actually, I want renamed files to stay marked after renaming. The whole code:

class rrname(Command):
	"""
	:rrname <file(s)>

	Prepends filename(s) of the selected file(s) with '-'
	"""
	do_mark = True

	def execute(self):
		filenames = [f.basename for f in self.fm.thistab.get_selection()]
		for f in filenames:
			new_name = '-' + f
			self.fm.rename(f, new_name)

		cwd = self.fm.thisdir
		for fileobj in cwd.files:
			filename = fileobj.basename
			if filename[0] == '-' and filename[1:] in filenames:
				cwd.mark_item(fileobj, val=self.do_mark)

		self.fm.ui.need_redraw = True

Well,  the command you wanted was:

self.fm.thisdir.load_content(schedule=False)

The full code should look something like this:

class rrname(Command):
	"""
	:rrname <file(s)>

	Prepends filename(s) of the selected file(s) with '-'
	"""
	do_mark = True

	def execute(self):
		filenames = [f.basename for f in self.fm.thistab.get_selection()]
		for f in filenames:
			new_name = '-' + f
			self.fm.rename(f, new_name)	

		if self.fm.thisdir.marked_items:
			self.fm.thisdir.load_content(schedule=False)

			for f in filenames:
				self.fm.execute_console("mark -"+f)

Let me do a quick analysis:

		if self.fm.thisdir.marked_items:

Only re-mark if the items were already marked.

			self.fm.thisdir.load_content(schedule=False)

Force a reload. In the last few versions (I don't know the exact number), Ranger has had a scheduler for these things. Because we need to run it now, we have to disable that.

			for f in filenames:
				self.fm.execute_console("mark -"+f)

I find using these style of commands handles the exceptions a lot more reliably than other methods, so this is my preference. It also means you don't have to look for file objects or do any searching manually, and you don't have to find out any API you aren't already familiar with. Additionally, it saves you looping through the whole directory.

Finally, "rrname" is a terrible name. "prepend_dash" would be much nicer (you have auto-complete anyway).

Offline

#1488 2012-10-12 17:11:22

loop
Member
Registered: 2011-05-06
Posts: 58

Re: Ranger, a textbased filemanager

@Vee, I love you!

Offline

#1489 2012-10-15 11:12:44

loop
Member
Registered: 2011-05-06
Posts: 58

Re: Ranger, a textbased filemanager

Hello everyone! Several times got the problem. The steps are:

1. Run ranger.
2. Work for a while.
3. Close one of opened tabs with 'q' keypress (mapped for tab_close command).
4. Got "'dict' object has no attribute 'append'" error message at the bottom of ranger`s window.
5. 'uq' keypress does not work.
6. Open new tab with 'gn' keypress, then close it. Got the same error message.
7. Open new tab with 'gn' keypress, then close it. Got the same error message.
...
8. Restart ranger and have all things working for a while.

ranger-master 1.5.5

Python 2.7.3rc2 (default, Apr 22 2012, 22:35:38)
[GCC 4.6.3]

Offline

#1490 2012-10-15 16:49:31

loop
Member
Registered: 2011-05-06
Posts: 58

Re: Ranger, a textbased filemanager

I`ve noticed a strange thing:

1. Open a directory with some stuff.
2. Press '/ <something>' for search something.
3. Press 'cm' to find the most recently modicated file/dir.
4. Press 'n', implying to find next modificated file/dir, but actually we make search for stuff from step 2.
... Huh, OK.
5. Press 'cs' to find the biggest file.
6. Next 'n' pressings acts to search for next biggest files, not fo stuff from step 2.
7. 'ca', 'cc', 'ci' work the same way as 'cs', only 'cm' acts strange.

So, if you searched some stuff and want to look through most recently modificated files, it`s not enough to press 'cm', first you need to enable any other search method ('ca', 'cc', 'ci', 'cs') and toggle 'cm' back. Now 'n' looks through the most recently modificated files.
Is it by design?

Last edited by loop (2012-10-15 16:50:03)

Offline

#1491 2012-10-16 13:45:44

jostber
Member
Registered: 2010-05-18
Posts: 15

Re: Ranger, a textbased filemanager

hut wrote:

About the progressbar:
The problem is that nobody is willing to write progressbar support for ranger. If I had a program that works like cp and periodically prints the status to the stdout, that would be great.

But honestly, I wouldn't copy large amounts of data with ranger because I want to see the logs.

Would it be possible to integrate ranger with program like pv to get this?

http://www.dlaube.com/2010/05/linux-com … ress-bars/

Offline

#1492 2012-10-18 00:36:00

jk121960
Member
From: Palos Hills, Illinois
Registered: 2011-12-09
Posts: 254

Re: Ranger, a textbased filemanager

Hi, Hut the paste (pp) started a while back to rename the incoming file when one exists rather than rename the current file. Where can I modify this to bring it back to when you paste files to replace the new for the old where the old file is the one that gets renamed?

thanks

-jerry

Last edited by jk121960 (2012-10-21 00:13:04)


Arch Awesome, Ranger & Vim the coding triple threat.

Offline

#1493 2012-10-21 00:07:02

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

Re: Ranger, a textbased filemanager

Is it possible to get files sorted by filetype and the subgroups by name?


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

Offline

#1494 2012-10-21 01:17:26

Veedrac
Member
Registered: 2011-07-19
Posts: 81

Re: Ranger, a textbased filemanager

Baabelfish wrote:

Is it possible to get files sorted by filetype and the subgroups by name?

Yes.

I have been (and still am) a fair bit short on time recently, so the others will have to wait for my reply as no-one else seems to be going to.

The answer you want is to press "o" and then "t".

But that is never good enough.

Alternatively, put this in your ~/.config/options.py.

from ranger.fsobject.directory import Directory

def sort_by_extension(path):
	extension = path.extension
	if extension is None:
		extension = ""
	return extension

def join_sorts(*sort_functions):
	def new_sort_func(p):
		return tuple(f(p) for f in sort_functions)
	return new_sort_func

Directory.sort_dict["extension_then_basename"] = join_sorts(sort_by_extension, Directory.sort_dict["basename"])

and then run ":sort extension_then_basename" from inside Ranger [this can be bound to a key].

Lets run through the code:



from ranger.fsobject.directory import Directory

This is where Ranger stores the sorting algorithms, specifically inside "Directory.sort_dict".



def sort_by_extension(path):

The sort function receives "path" objects, which are really "File" instances (but the other functions accept them as path). It needs to return something that Python can order, keeping in mind that Python can order strings ("b" > "aa" > "a" and "ba" > "ab").



	extension = path.extension
	if extension is None:
		extension = ""
	return extension

Get the extension from the path object, and make sure we have a string. Then return it. This will let Python sort by extension.



def join_sorts(*sort_functions):

We, however, want to sort by name in the ambiguous case. This is where Python's tuples come in.
A tuple looks like this:

(10, "hello", 54, x, [sda], "sort-of like a list of things")

and Python knows how to sort these.
First it sorts by the first value, and then by the second when the first are equal, and then the third, and so on.
So if we want to sort by extension and then basename we want to sort by (extension, basename). This function will take in many (as many as you want) functions and then make a new function that returns a tuple of that form.



	def new_sort_func(p):
		return tuple(f(p) for f in sort_functions)
	return new_sort_func

What we've got here is we make a new function (new_sort_func) and return it (return new_sort_func).
The new function returns a tuple which has the values "f(p)" for each "f" in our list of functions, so (extension(p), basename(p)) if our functions are (extension, basename).



Directory.sort_dict["extension_then_basename"] = join_sorts(sort_by_extension, Directory.sort_dict["basename"])

Let us look at this in two parts.

join_sorts(sort_by_extension, Directory.sort_dict["basename"])

This makes a new function using "join_sorts", which is our "sort_by_extension" plus "Directory.sort_dict['basename']". "Directory.sort_dict['basename']" is just where Ranger puts its "basename" sort - other choices are "natural", "size", "mtime", "atime", "ctime" and "type".

Directory.sort_dict["extension_then_basename"] =

Now we can sort how we want, give it to Ranger.


Now realise that "type" is a sort method already built-in, which uses mimetypes rather than extensions, a better approach. So the above may be rather written as:

from ranger.fsobject.directory import Directory

def join_sorts(*sort_functions):
	def new_sort_func(p):
		return tuple(f(p) for f in sort_functions)
	return new_sort_func

Directory.sort_dict["extension_then_basename"] = join_sorts(
	Directory.sort_dict["type"],
	Directory.sort_dict["basename"]
)

Please enjoy.

Offline

#1495 2012-10-21 03:22:37

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

Re: Ranger, a textbased filemanager

@Veedrac
Hehe thanks for an awesome reply! I did not know ranger can be extended that easily <3

I still wonder why this type of a sort is not in ranger by default...

Last edited by Baabelfish (2012-10-21 03:24:32)


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

Offline

#1496 2012-10-22 15:44:16

Pranavg1890
Member
From: Nagpur,India
Registered: 2012-09-07
Posts: 114

Re: Ranger, a textbased filemanager

Lfm(last file manager) has a functionality to view compressed files like .tar etc like ordinary folders. Can this functionality be implemented in Ranger ?


Using Openbox + Tint2 + Idesk

Offline

#1497 2012-10-22 15:47:55

jk121960
Member
From: Palos Hills, Illinois
Registered: 2011-12-09
Posts: 254

Re: Ranger, a textbased filemanager

Hi Ranger already does this, just hit enter when the file is highlighted.

--jerry


Arch Awesome, Ranger & Vim the coding triple threat.

Offline

#1498 2012-10-22 15:57:05

Pranavg1890
Member
From: Nagpur,India
Registered: 2012-09-07
Posts: 114

Re: Ranger, a textbased filemanager

Ranger only lists the files inside the archive. We cannot edit or read the files like we can in lfm. If you want to see what i'm telling , just install lfm and try opening an archive(compressed files like .tar,.rar etc) in it. Also, I'm using the latest git version of ranger.


Using Openbox + Tint2 + Idesk

Offline

#1499 2012-10-22 20:57:38

Veedrac
Member
Registered: 2011-07-19
Posts: 81

Re: Ranger, a textbased filemanager

Pranavg1890 wrote:

Ranger only lists the files inside the archive. We cannot edit or read the files like we can in lfm. If you want to see what i'm telling , just install lfm and try opening an archive(compressed files like .tar,.rar etc) in it. Also, I'm using the latest git version of ranger.

This has been discussed very seriously before. Until someone (me included*, Hut excluded) gets off their backside and implements it, its not going to happen. I'm pretty sure Hut likes the idea, but it's not trivial to implement.

By the way, I tried lfm just now and managed to crash it with this functionality in the first 60 seconds. That's the kind of thing to avoid ;-).

* I have even yet to implement my own simple suggestion I proposed to Hut, so you can assume it will be a while...

Offline

#1500 2012-10-23 15:16:37

Pranavg1890
Member
From: Nagpur,India
Registered: 2012-09-07
Posts: 114

Re: Ranger, a textbased filemanager

lfm didn't crash on my system. It was pretty stable and opened ( and opens) several compressed files for me without error. I believe this is the only option missing in ranger, otherwise it's complete in all aspects. Atleast an option should be given to enable or disable this functionality, so that who want to use it will use it and those who don't want it, they disable it. I only want to see this option added to ranger otherwise it covers all the functionality needed by me. And, also, i think, many would welcome this functionality if I'm not wrong.


Using Openbox + Tint2 + Idesk

Offline

Board footer

Powered by FluxBB