summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-01-11 00:10:40 +0100
committerhut <hut@lavabit.com>2010-01-11 00:10:40 +0100
commit9983328cebc02a0e01038880405d061448abcac7 (patch)
treec737d7660251a497eac2134c78fd85e416fc9446
parentbe868b98c41dac9e588944ece0d8c70e3eee534a (diff)
downloadranger-9983328cebc02a0e01038880405d061448abcac7.tar.gz
added a way to create symlinks
-rw-r--r--TODO2
-rw-r--r--ranger/actions.py15
-rw-r--r--ranger/defaults/keys.py4
3 files changed, 19 insertions, 2 deletions
diff --git a/TODO b/TODO
index 95bf2984..52812959 100644
--- a/TODO
+++ b/TODO
@@ -23,7 +23,7 @@ General
    (X) #21  10/01/01  write help!
    ( ) #22  10/01/03  add getopt options to change flags/mode
    (X) #29  10/01/06  add chmod command
-   ( ) #30  10/01/06  add a way to create symlinks
+   (X) #30  10/01/06  add a way to create symlinks
    ( ) #32  10/01/08  place the (hidden) cursor to a meaningful position
    ( ) #34  10/01/09  display free disk space
    ( ) #35  10/01/09  display disk usage of files in current directory
diff --git a/ranger/actions.py b/ranger/actions.py
index 48db860c..33952c19 100644
--- a/ranger/actions.py
+++ b/ranger/actions.py
@@ -399,6 +399,21 @@ class Actions(EnvironmentAware, SettingsAware):
 	def cut(self):
 		self.copy()
 		self.env.cut = True
+	
+	def paste_symlink(self):
+		from os import symlink, getcwd
+		from os.path import join
+
+		copied_files = self.env.copy
+
+		if not copied_files:
+			return
+
+		for f in copied_files:
+			try:
+				symlink(f.path, join(getcwd(), f.basename))
+			except Exception as x:
+				self.notify(x)
 
 	def paste(self):
 		"""Paste the selected items into the current directory"""
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 14548076..c08f8ba2 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -77,7 +77,9 @@ def initialize_commands(command_list):
 	bind('yy', fm.copy())
 	bind('dd', fm.cut())
 	bind('pp', fm.paste())
-	hint('p', 'press //p// once again to confirm pasting')
+	bind('pl', fm.paste_symlink())
+	hint('p', 'press //p// once again to confirm pasting' \
+			', or //l// to create symlinks')
 
 	bind('s', fm.execute_command('bash'))
 
20' href='#n220'>220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424