summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-27 00:53:38 +0100
committerhut <hut@lavabit.com>2009-12-27 00:53:38 +0100
commit2efce5400bed218ca603444d179bee503fa6d9f5 (patch)
treed4b01504b90620582676894b77ef49dca92c62ce /ranger
parent0da7b3961de437415753383a5c2b7efaafcc4586 (diff)
downloadranger-2efce5400bed218ca603444d179bee503fa6d9f5.tar.gz
added rename command
Diffstat (limited to 'ranger')
-rw-r--r--ranger/actions.py11
-rw-r--r--ranger/commands.py6
-rw-r--r--ranger/defaults/keys.py7
3 files changed, 24 insertions, 0 deletions
diff --git a/ranger/actions.py b/ranger/actions.py
index d500f18a..31f4cb41 100644
--- a/ranger/actions.py
+++ b/ranger/actions.py
@@ -283,6 +283,17 @@ class Actions(EnvironmentAware, SettingsAware):
 			os.mkdir(os.path.join(self.env.pwd.path, name))
 		except OSError as err:
 			self.notify(str(err), bad=True)
+
+	
+	def rename(self, src, dest):
+		if hasattr(src, 'path'):
+			src = src.path
+
+		try:
+			os.rename(src, dest)
+		except OSError as err:
+			self.notify(str(err), bad=True)
+
 	
 	def notify(self, text, duration=4, bad=False):
 		try:
diff --git a/ranger/commands.py b/ranger/commands.py
index a3cc131e..68b9c574 100644
--- a/ranger/commands.py
+++ b/ranger/commands.py
@@ -161,6 +161,12 @@ class mkdir(Command):
 			pass
 
 
+class rename(Command):
+	def execute(self):
+		line = parse(self.line)
+		self.fm.rename(self.fm.env.cf, line.rest(1))
+	
+
 # -------------------------------- rest
 
 by_name = {}
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 9837d2a2..88f570df 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -72,6 +72,13 @@ def initialize_commands(command_list):
 			fm.sort(reverse=not fm.settings.reverse))
 	command_list.hint(sort_hint, 'o', 'O')
 
+	def edit_name(fm, n):
+		cf = fm.env.cf
+		if cf:
+			fm.open_console(cmode.COMMAND, 'rename ' + cf.basename)
+
+	bind('A', edit_name)
+	bind('cw', do('open_console', cmode.COMMAND, 'rename '))
 	bind('cd', do('open_console', cmode.COMMAND, 'cd '))
 	bind('f', do('open_console', cmode.COMMAND_QUICK, 'find '))
 
pecs/ranger/blame/TODO?id=acd07c4abfbc15252d28c884c2bea6d67910a465'>^
277ecc9e ^
9983328c ^
33cb688a ^
a1274aba ^
b42eb058 ^
b13518af ^
316ff5a9 ^
fc486c60 ^
b4934e42 ^
2c1d2db0 ^
291ca616 ^
50845f37 ^
039c03ef ^
af6658b3 ^
efe2d7a3 ^
f0df3fa5 ^
a986e2bd ^

3fe38754 ^

6a8d5d23 ^
aad61455 ^
7a268c8b ^

efdc7b16 ^
636f69d3 ^
d3c262a9 ^
e02d47ed ^

4be8b401 ^



d955e3f0 ^
75013dc7 ^
67bb838c ^
a808a661 ^
bba8d293 ^
2a64495f ^
5e449699 ^
8895b130 ^

7b04e507 ^
87db0130 ^
dd4a4145 ^
8f2f1767 ^
db1721dd ^
aea5cf92 ^
b624bd94 ^
69d1220f ^
6099d9a3 ^
9207e83c ^
f7db061b ^
6099d9a3 ^
5a8b6059 ^
6f43de0a ^




fca1fc4f ^
f70ee6b2 ^
0db4c9b2 ^
b2d63ef5 ^
6908d0cc ^
d994d0d6 ^
01c89bb5 ^
c776804d ^
dab4db44 ^
cc4210ff ^
34c131ef ^
66c5bb93 ^
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