summaryrefslogtreecommitdiff
path: root/scripts/utils.py
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2014-10-26 19:42:01 +0100
committerFlorian Bruhin <git@the-compiler.org>2014-10-26 19:42:01 +0100
commitbb031b51f798e9ca343ed8de5d2213577df6dd50 (patch)
treec841df0a45d8bb685c92650e8cd0e1fb6a1f940c /scripts/utils.py
parentd3b1a5efb4528ec3d7f93d76428cea2c77efa746 (diff)
downloadqutebrowser-bb031b51f798e9ca343ed8de5d2213577df6dd50.tar.gz
qutebrowser-bb031b51f798e9ca343ed8de5d2213577df6dd50.zip
Make most scripts work if we're in scripts/ directory.
See #213.
Diffstat (limited to 'scripts/utils.py')
-rw-r--r--scripts/utils.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/scripts/utils.py b/scripts/utils.py
index daa3a7dcc..5b0c7dc72 100644
--- a/scripts/utils.py
+++ b/scripts/utils.py
@@ -20,6 +20,7 @@
"""Utility functions for scripts."""
import os
+import os.path
use_color = True
@@ -82,3 +83,10 @@ def print_bold(text):
print(''.join([bold, text, reset]))
else:
print(text)
+
+
+def change_cwd():
+ """Change the scripts cwd if it was started inside the script folder."""
+ cwd = os.getcwd()
+ if os.path.split(cwd)[1] == 'scripts':
+ os.chdir(os.path.join(cwd, os.pardir))