Skip to content

Commit 8131524

Browse files
authored
Defaulting to xdg directory for history files (#217)
1 parent bb08ee6 commit 8131524

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
1.5.0
5+
-----
6+
7+
- If `XDG_DATA_HOME` is defined, it is now used as location where to store the history.
8+
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`.
9+
410
1.4.0
511
-----
612

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

4955
beta2
5056
-----

src/PHPCR/Shell/Console/Application/Shell.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,21 @@ public function __construct(Application $application)
4141
{
4242
$this->hasReadline = function_exists('readline');
4343
$this->application = $application;
44-
$this->history = getenv('HOME').'/.history_'.$application->getName();
44+
$this->history = $this->getHistoryDirectory();
4545
$this->output = new ConsoleOutput();
4646
$this->prompt = $application->getName().' > ';
4747
}
4848

49+
public function getHistoryDirectory(): string
50+
{
51+
$dataDirectory = getenv('XDG_DATA_HOME');
52+
if ($dataDirectory !== '') {
53+
return $dataDirectory.'/'.$this->application->getName();
54+
}
55+
56+
return getenv('HOME').'/.history_'.$this->application->getName();
57+
}
58+
4959
/**
5060
* Runs the shell.
5161
*/

0 commit comments

Comments
 (0)