summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-25 21:59:51 +0100
committerhut <hut@lavabit.com>2009-12-25 21:59:51 +0100
commit5c210a96a0e4bb74cd096edb045fc3814b78450c (patch)
tree511c54091badbc91c71a7d76759d642648c9ce82 /ranger
parente7f81766920a47bf4b126108a25ce92885682bc2 (diff)
downloadranger-5c210a96a0e4bb74cd096edb045fc3814b78450c.tar.gz
random updates
Diffstat (limited to 'ranger')
-rw-r--r--ranger/__init__.py6
-rw-r--r--ranger/actions.py4
-rw-r--r--ranger/applications.py18
-rw-r--r--ranger/defaults/keys.py2
-rw-r--r--ranger/fm.py1
5 files changed, 28 insertions, 3 deletions
diff --git a/ranger/__init__.py b/ranger/__init__.py
index b934d80c..5eaaee4f 100644
--- a/ranger/__init__.py
+++ b/ranger/__init__.py
@@ -56,10 +56,9 @@ def main():
 
 	args, rest = parser.parse_args()
 
+	log(sys.argv)
 	if args.cd_after_exit:
 		sys.stderr = sys.__stdout__
-		if rest[0] == sys.argv[0]:
-			del rest[0]
 	
 	# Initialize objects
 	target = ' '.join(rest)
@@ -81,7 +80,8 @@ def main():
 
 	try:
 		my_ui = UI()
-		my_fm = FM(ui = my_ui)
+		my_fm = FM(ui=my_ui)
+		my_fm.stderr_to_out = args.cd_after_exit
 
 		# Run the file manager
 		my_fm.initialize()
diff --git a/ranger/actions.py b/ranger/actions.py
index a43d366f..b9ec2204 100644
--- a/ranger/actions.py
+++ b/ranger/actions.py
@@ -164,6 +164,10 @@ class Actions(EnvironmentAware, SettingsAware):
 		if func is not None:
 			self.env.settings['sort'] = str(func)
 	
+	def spawn(self, command):
+		from ranger.applications import spawn
+		spawn(command, fm=self)
+	
 	def force_load_preview(self):
 		cf = self.env.cf
 		if cf is not None:
diff --git a/ranger/applications.py b/ranger/applications.py
index a046a839..c9f2ec18 100644
--- a/ranger/applications.py
+++ b/ranger/applications.py
@@ -60,3 +60,21 @@ def run(*args, **kw):
 		waitpid_no_intr(p.pid)
 		if fm.ui: fm.ui.initialize()
 		return p
+
+def spawn(command, fm=None, suspend=True, wait=True):
+	from subprocess import Popen, STDOUT
+	from ranger.ext.waitpid_no_intr import waitpid_no_intr
+
+	if suspend and fm and fm.ui:
+		fm.ui.suspend()
+
+	try:
+		if fm and fm.stderr_to_out:
+			process = Popen(command, shell=True, stderr=STDOUT)
+		else:
+			process = Popen(command, shell=True)
+		if wait:
+			waitpid_no_intr(process.pid)
+	finally:
+		if suspend and fm and fm.ui:
+			fm.ui.initialize()
diff --git a/ranger/defaults/keys.py b/ranger/defaults/keys.py
index 683214f7..9fbc5b96 100644
--- a/ranger/defaults/keys.py
+++ b/ranger/defaults/keys.py
@@ -42,6 +42,8 @@ def initialize_commands(command_list):
 	bind('cut', do('cut'))
 	bind('p', do('paste'))
 
+	bind('s', do('spawn', 'bash'))
+
 	t_hint = "show_//h//idden //p//review_files //d//irectories_first //a//uto_load_preview //c//ollapse_preview"
 	command_list.hint(t_hint, 't')
 	bind('th', do('toggle_boolean_option', 'show_hidden'))
diff --git a/ranger/fm.py b/ranger/fm.py
index a1b1339a..a68c0f15 100644
--- a/ranger/fm.py
+++ b/ranger/fm.py
@@ -12,6 +12,7 @@ TICKS_BEFORE_COLLECTING_GARBAGE = 100
 class FM(Actions):
 	input_blocked = False
 	input_blocked_until = 0
+	stderr_to_out = False
 	def __init__(self, ui = None, bookmarks = None):
 		"""Initialize FM."""
 		Actions.__init__(self)
id='n308' href='#n308'>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 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615