From 50dd4b8f54c819c3adc037345c7c1077656eace6 Mon Sep 17 00:00:00 2001 From: Vladimir Iakovlev Date: Sat, 2 Sep 2017 17:35:08 +0200 Subject: [PATCH] #682: Use system temporary directory --- thefuck/shells/bash.py | 5 ++++- thefuck/shells/zsh.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/thefuck/shells/bash.py b/thefuck/shells/bash.py index 49fea454..6eeaccab 100644 --- a/thefuck/shells/bash.py +++ b/thefuck/shells/bash.py @@ -1,4 +1,5 @@ import os +from tempfile import gettempdir from uuid import uuid4 from ..conf import settings from ..const import ARGUMENT_PLACEHOLDER, USER_COMMAND_MARK @@ -38,13 +39,15 @@ class Bash(Generic): '''.format(user_command_mark=mark, app_alias=self.app_alias(alias_name)) else: + log_path = os.path.join( + gettempdir(), 'thefuck-script-log-{}'.format(uuid4().hex)) return ''' export THEFUCK_INSTANT_MODE=True; export THEFUCK_OUTPUT_LOG={log}; script -feq {log}; rm {log}; exit - '''.format(log='/tmp/thefuck-script-log-{}'.format(uuid4().hex)) + '''.format(log=log_path) def _parse_alias(self, alias): name, value = alias.replace('alias ', '', 1).split('=', 1) diff --git a/thefuck/shells/zsh.py b/thefuck/shells/zsh.py index 7f435565..6251076f 100644 --- a/thefuck/shells/zsh.py +++ b/thefuck/shells/zsh.py @@ -1,5 +1,6 @@ from time import time import os +from tempfile import gettempdir from uuid import uuid4 from ..conf import settings from ..const import ARGUMENT_PLACEHOLDER, USER_COMMAND_MARK @@ -36,13 +37,15 @@ class Zsh(Generic): '''.format(user_command_mark=USER_COMMAND_MARK, app_alias=self.app_alias(alias_name)) else: + log_path = os.path.join( + gettempdir(), 'thefuck-script-log-{}'.format(uuid4().hex)) return ''' export THEFUCK_INSTANT_MODE=True; export THEFUCK_OUTPUT_LOG={log}; script -feq {log}; rm {log}; exit - '''.format(log='/tmp/thefuck-script-log-{}'.format(uuid4().hex)) + '''.format(log=log_path) def _parse_alias(self, alias): name, value = alias.split('=', 1)