summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-06-13 02:33:35 +0200
committerhut <hut@lavabit.com>2009-06-13 02:33:35 +0200
commit46ad9bb591d057715fcd63376326336f3339fba7 (patch)
tree017800b49d26f5454a19469fbadd72f677883cb2
parent2887ca25fb58362d5d644ecda5f0bc51c80ec404 (diff)
downloadranger-46ad9bb591d057715fcd63376326336f3339fba7.tar.gz
cleaning up
-rw-r--r--code/runcontext.rb17
-rw-r--r--data/apps.rb8
-rw-r--r--data/types.rb1
3 files changed, 20 insertions, 6 deletions
diff --git a/code/runcontext.rb b/code/runcontext.rb
index 3d9ff457..1e10aa8d 100644
--- a/code/runcontext.rb
+++ b/code/runcontext.rb
@@ -114,13 +114,26 @@ class RunContext
 	##   rc.paths.map {|x| ~x}.join(' ')
 	## otherwise:
 	##   ~(rc.paths.first)
-	def ~() @paths.map {|x| ~x}.join(' ') end
+	def ~
+		if @multi
+			@paths.map {|x| ~x}.join(' ')
+		else
+			~@paths.first
+		end
+	end
+
+	## escape one (the first) file for direct use in the shell.
+	## this is a shortcut for:
+	##   ~(rc.paths.first)
+	def one
+		~@paths.first
+	end
 
 	## shortcut for _files.size_
 	def size() @files.size end
 
 	## shortcut for _files.first.path_
-	def first() @files.first.path end
+	def first() @files.first end
 
 	## shortcut for _files.first.name_
 	def name() @files.first.name end
diff --git a/data/apps.rb b/data/apps.rb
index 6ba7f44b..dc65d1a7 100644
--- a/data/apps.rb
+++ b/data/apps.rb
@@ -23,9 +23,9 @@ module Application
 	def feh(rc)
 		check rc
 		case rc.mode
-		when 4; "feh --bg-scale #{~rc.first}"
-		when 5; "feh --bg-tile #{~rc.first}"
-		when 6; "feh --bg-center #{~rc.first}"
+		when 4; "feh --bg-scale #{rc.one}"
+		when 5; "feh --bg-tile #{rc.one}"
+		when 6; "feh --bg-center #{rc.one}"
 		when 2; "gimp #{~rc}"
 		when 1; "feh -F #{~rc}"
 		else "feh #{~rc}"
@@ -35,7 +35,7 @@ module Application
 	def interpreted_language(rc)
 		check rc
 		case rc.mode
-		when 1; "./#{~rc.first}"
+		when 1; rc.first.executable? ? "#{rc.one}" : nil
 		when 0; vi(rc)
 		else nil end
 	end
diff --git a/data/types.rb b/data/types.rb
index 773df758..84f8295a 100644
--- a/data/types.rb
+++ b/data/types.rb
@@ -29,6 +29,7 @@ class Directory::Entry
 
 		end
 
+		## otherwise use vi
 		use.vi
 	end
 end