Skip to content

Defaulting to xdg directory for history files #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

1.5.0
-----

- If `XDG_DATA_HOME` is defined, it is now used as location where to store the history.
If you have set `XDG_DATA_HOME` to something else than `HOME`, you can preserve your phpcr-shell history by moving the directory `~/.history_PHPCRSH` to `$XDB_DATA_HOME/.history_PHPCRSH`.

1.4.0
-----

Expand Down Expand Up @@ -44,7 +50,7 @@ beta4
- [node:property:show] Text fields are truncated
- [profile] Workspace given from CLI does not override profile workspace
- [command] Removed node:definition command: Jackalope now supports this, and
this command would never have worked, see:
this command would never have worked, see:

beta2
-----
Expand Down
12 changes: 11 additions & 1 deletion src/PHPCR/Shell/Console/Application/Shell.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,21 @@ public function __construct(Application $application)
{
$this->hasReadline = function_exists('readline');
$this->application = $application;
$this->history = getenv('HOME').'/.history_'.$application->getName();
$this->history = $this->getHistoryDirectory();
$this->output = new ConsoleOutput();
$this->prompt = $application->getName().' > ';
}

public function getHistoryDirectory(): string
{
$dataDirectory = getenv('XDG_DATA_HOME');
if ($dataDirectory !== '') {
return $dataDirectory.'/'.$this->application->getName();
}

return getenv('HOME').'/.history_'.$this->application->getName();
}

/**
* Runs the shell.
*/
Expand Down