diff --git a/openbb_terminal/core/config/paths.py b/openbb_terminal/core/config/paths.py index 0ee760a4ae6..0eee6312585 100644 --- a/openbb_terminal/core/config/paths.py +++ b/openbb_terminal/core/config/paths.py @@ -35,6 +35,7 @@ REPOSITORY_ENV_FILE = REPOSITORY_DIRECTORY / ".env" PACKAGE_ENV_FILE = PACKAGE_DIRECTORY / ".env" SETTINGS_DIRECTORY = HOME_DIRECTORY / ".openbb_terminal" +HIST_FILE_PATH = os.path.join(os.path.expanduser("~"), ".openbb_terminal.his") USER_ENV_FILE = SETTINGS_DIRECTORY / ".env" USER_DATA_DIRECTORY = get_user_data_directory() USER_EXPORTS_DIRECTORY = USER_DATA_DIRECTORY / "exports" diff --git a/openbb_terminal/session/local_model.py b/openbb_terminal/session/local_model.py index 1c8270c2526..e6582051c80 100644 --- a/openbb_terminal/session/local_model.py +++ b/openbb_terminal/session/local_model.py @@ -3,6 +3,7 @@ from pathlib import Path import json from typing import Optional from openbb_terminal.core.config.paths import ( + HIST_FILE_PATH, SETTINGS_DIRECTORY, USER_ROUTINES_DIRECTORY, ) @@ -79,6 +80,30 @@ def remove_session_file(file_path: Path = SESSION_FILE_PATH) -> bool: return False +def remove_cli_history_file(file_path: Path = Path(HIST_FILE_PATH)) -> bool: + """Remove the cli history file. + + Parameters + ---------- + file_path : Path + The file path. + + Returns + ------- + bool + The status of the removal. + """ + + try: + if os.path.isfile(file_path): + os.remove(file_path) + return True + return True + except Exception: + console.print("[red]\nFailed to remove terminal history file.[/red]") + return False + + def apply_configs(configs: dict): """Apply configurations. diff --git a/openbb_terminal/session/session_model.py b/openbb_terminal/session/session_model.py index dc1eaeb3db9..fe82b99fa72 100644 --- a/openbb_terminal/session/session_model.py +++ b/openbb_terminal/session/session_model.py @@ -86,5 +86,6 @@ def logout(cls: bool = False): Hub.delete_session() Local.remove_session_file() + Local.remove_cli_history_file() plt.close("all") console.print("[green]\nLogout successful.[/green]")