summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-14 05:35:46 +0100
committerhut <hut@lavabit.com>2010-01-14 05:35:46 +0100
commit01c8834f9ff1e6990b5720d7efd3f350110df735 (patch)
treee6519b845d5d8efc2e64a5f1691c737b9f1030be /ranger
parent832b516c52e74b7180c0e5fc5d5c2d995d1aacf6 (diff)
downloadranger-01c8834f9ff1e6990b5720d7efd3f350110df735.tar.gz
commands: added :edit command
Diffstat (limited to 'ranger')
-rw-r--r--ranger/actions.py11
-rw-r--r--ranger/commands.py13
2 files changed, 21 insertions, 3 deletions
diff --git a/ranger/actions.py b/ranger/actions.py
index a881f7c2..6aab4581 100644
--- a/ranger/actions.py
+++ b/ranger/actions.py
@@ -20,6 +20,7 @@ from ranger.shared import EnvironmentAware, SettingsAware
 from ranger import fsobject
 from ranger.gui.widgets import console_mode as cmode
 from ranger.applications import run
+from ranger.fsobject import File
 
 class Actions(EnvironmentAware, SettingsAware):
 	search_method = 'ctime'
@@ -242,11 +243,15 @@ class Actions(EnvironmentAware, SettingsAware):
 	def execute_command(self, cmd, **kw):
 		return run(fm=self, action=cmd, **kw)
 	
-	def edit_file(self):
+	def edit_file(self, file=None):
 		"""Calls execute_file with the current file and app='editor'"""
-		if self.env.cf is None:
+		if file is None:
+			file = self.env.cf
+		elif isinstance(file, str):
+			file = File(os.path.expanduser(file))
+		if file is None:
 			return
-		self.execute_file(self.env.cf, app = 'editor')
+		self.execute_file(file, app = 'editor')
 
 	def open_console(self, mode=':', string=''):
 		"""Open the console if the current UI supports that"""
diff --git a/ranger/commands.py b/ranger/commands.py
index a62caf60..411408eb 100644
--- a/ranger/commands.py
+++ b/ranger/commands.py
@@ -271,6 +271,18 @@ class mkdir(Command):
 			pass
 
 
+class edit(Command):
+	"""
+	:edit <filename>
+
+	Opens the specified file in vim
+	"""
+
+	def execute(self):
+		line = parse(self.line)
+		self.fm.edit_file(line.rest(1))
+
+
 class rename(Command):
 	"""
 	:rename <newname>
@@ -371,6 +383,7 @@ def alias(**kw):
 		by_name[key] = value
 
 alias(q=quit)
+alias(e=quit)
 
 def command_generator(start):
 	return (cmd + ' ' for cmd in by_name if cmd.startswith(start))
kview.html?h=v1.9.2&id=4c13e1f2d85483e026d79ab05da9f1e8e4b45293'>4c13e1f2 ^
62cd83ba ^

4c13e1f2 ^















4c13e1f2 ^

























34a60763 ^
4c13e1f2 ^
34a60763 ^
4c13e1f2 ^




62cd83ba ^
4c13e1f2 ^






c9383c72 ^
4c13e1f2 ^








1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152