aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Kasak <dkasak@users.noreply.github.com>2019-02-13 16:31:08 +0100
committerKeith Smiley <keithbsmiley@gmail.com>2019-02-13 07:31:08 -0800
commitd9cd83f6ca08e9ed91ca0cdafd23a5ecd671bae9 (patch)
treeffd881b603a9b816f540e7ee7f73fae84e1f490c
parent6aface48202f6027f3800e2bd8330ca626fdcbee (diff)
downloadedit-d9cd83f6ca08e9ed91ca0cdafd23a5ecd671bae9.tar.gz
edit-d9cd83f6ca08e9ed91ca0cdafd23a5ecd671bae9.zip
Respect WEECHAT_HOME. (#6)
-rw-r--r--edit.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/edit.py b/edit.py
index 65fcf42..71333dc 100644
--- a/edit.py
+++ b/edit.py
@@ -18,10 +18,15 @@ import subprocess
import weechat
+def weechat_config_dir():
+ return os.path.expanduser(os.environ.get("WEECHAT_HOME", "~/.weechat/"))
+
+
def edit(data, buf, args):
editor = (weechat.config_get_plugin("editor") or
os.environ.get("EDITOR", "vim -f"))
- path = os.path.expanduser("~/.weechat/message.txt")
+ config_dir = weechat_config_dir()
+ path = os.path.join(config_dir, "message.txt")
with open(path, "w+") as f:
f.write(weechat.buffer_get_string(buf, "input"))