From 3947460779ce6361a1c86858c3767e58a5592059 Mon Sep 17 00:00:00 2001 From: moculus Date: Sat, 29 Nov 2008 19:52:03 +0000 Subject: [PATCH] pwd command --HG-- branch : pmacs2 --- method/buffers.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/method/buffers.py b/method/buffers.py index 0ef67f0..335c2f5 100644 --- a/method/buffers.py +++ b/method/buffers.py @@ -131,7 +131,11 @@ class ToggleTabs(Method): class Pwd(Method): '''Print the buffer's current working directory''' def _execute(self, w, **vargs): - cwd = os.path.dirname(w.buffer.path) + '/' - if cwd.startswith(os.getenv('HOME')): - cwd = cwd.replace(os.getenv('HOME'), '~') - w.set_error("Directory %s" % cwd) + home = os.getenv('HOME') + if hasattr(w.buffer, 'path'): + cwd = os.path.dirname(w.buffer.path) + '/' + if cwd.startswith(home): + cwd = cwd.replace(home, '~') + w.set_error("Directory %s" % cwd) + else: + w.set_error("Directory %s/" % os.getcwd())