summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/defaults/options.py5
-rw-r--r--ranger/gui/ui.py20
2 files changed, 13 insertions, 12 deletions
diff --git a/ranger/defaults/options.py b/ranger/defaults/options.py
index df755b51..00be15d1 100644
--- a/ranger/defaults/options.py
+++ b/ranger/defaults/options.py
@@ -49,9 +49,8 @@ preview_files = True
 max_filesize_for_preview = 300 * 1024  # 300kb
 collapse_preview = True
 
-# Specify a title for the window? Some terminals don't support this,
-# so it's turned off by default.
-update_title = False
+# Set a title for the window?
+update_title = True
 
 # How many directory-changes or console-commands should be kept in history?
 max_history_size = 20
diff --git a/ranger/gui/ui.py b/ranger/gui/ui.py
index 77cde51d..b073c2e0 100644
--- a/ranger/gui/ui.py
+++ b/ranger/gui/ui.py
@@ -22,19 +22,25 @@ from .displayable import DisplayableContainer
 from .mouse_event import MouseEvent
 from ranger.container import CommandList
 
+TERMINALS_WITH_TITLE = ("xterm", "xterm-256color", "rxvt",
+		"rxvt-256color", "rxvt-unicode", "aterm", "Eterm",
+		"screen", "screen-256color")
+
 class UI(DisplayableContainer):
 	is_set_up = False
 	mousemask = curses.ALL_MOUSE_EVENTS | curses.REPORT_MOUSE_POSITION
 	load_mode = False
 	def __init__(self, commandlist=None, env=None, fm=None):
-		import os
-		os.environ['ESCDELAY'] = '25'   # don't know a cleaner way
+		from os import environ
+		self._draw_title = environ["TERM"] in TERMINALS_WITH_TITLE
+		environ['ESCDELAY'] = '25'   # don't know a cleaner way
 
 		if env is not None:
 			self.env = env
 		if fm is not None:
 			self.fm = fm
 
+
 		if commandlist is None:
 			self.commandlist = CommandList()
 			self.settings.keys.initialize_commands(self.commandlist)
@@ -194,13 +200,9 @@ class UI(DisplayableContainer):
 		"""Erase the window, then draw all objects in the container"""
 		self.win.touchwin()
 		DisplayableContainer.draw(self)
-		if self.settings.update_title:
-			hostname = str(socket.gethostname())
-			try:
-				cwd = self.fm.env.cwd.path
-			except:
-				cwd = ' - ranger'
-			sys.stdout.write("\033]2;" + hostname + cwd + "\007")
+		if self._draw_title and self.settings.update_title:
+			cwd = self.fm.env.cwd.path
+			sys.stdout.write("\033]2;ranger:" + cwd + "\007")
 		self.win.refresh()
 
 	def finalize(self):