Skip to content

Commit 6d7a3b6

Browse files
committed
Merge branch 'main' into omit_directory
2 parents d0f5c97 + b547cbf commit 6d7a3b6

3 files changed

Lines changed: 59 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Features:
1616
* Quests to-do list.
1717
* Chests hidden in directories.
1818

19+
See [this blog post](https://olano.dev/blog/deconstructing-the-role-playing-videogame/) for background on the development process.
20+
1921
## Installation
2022

2123
### From binary
@@ -234,7 +236,3 @@ The hero's class can be changed at the home directory using `rpg-cli class <name
234236
## Troubleshooting
235237

236238
* The release binary for macOS [is not signed](https://github.com/facundoolano/rpg-cli/issues/27). To open it for the first time, right click on the binary and select "Open" from the menu.
237-
238-
## Feedback appreciated!
239-
240-
If you find any issue, have features ideas, gameplay suggestions or example shell scripts, feel free to [file an issue](https://github.com/facundoolano/rpg-cli/issues/new) to start a conversation.

shell/README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ It can be integrated to the regular ls like this:
4848
ls () {
4949
command ls "$@"
5050
if [ $# -eq 0 ] ; then
51-
rpg cd -f .
52-
rpg ls
51+
rpg-cli cd -f .
52+
rpg-cli ls
5353
fi
5454
}
5555
```
@@ -135,3 +135,16 @@ cd () {
135135
rpg-cli battle
136136
}
137137
```
138+
139+
### Staying in the current work directory on death
140+
141+
By default the shell integrations will send the user back to the home directory after death. To prevent this, we can change back to the current directory after each battle
142+
143+
For example for cd:
144+
```sh
145+
cd () {
146+
builtin cd "$@"
147+
rpg-cli cd -f .
148+
rpg-cli battle; rpg-cli cd -f .
149+
}
150+
```

shell/example.ps1

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Shell integration for Windows Terminal
2+
#
3+
# Note:
4+
# - I couldn't figure out how to override `cd`, so I used `cdir` instead.
5+
# - To avoid hitting the absolute path length limit, I made the created directories single-digit numbers.
6+
# - It seems that `&&` can be used in PowerShell 7, but it's not available in version 5, so I omitted the error handling.
7+
#
8+
# See:
9+
# - [about_Profiles - PowerShell | Microsoft Learn](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-5.1)
10+
# - [Migrating from Windows PowerShell 5.1 to PowerShell 7 - PowerShell | Microsoft Learn](https://learn.microsoft.com/en-us/powershell/scripting/whats-new/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.4#separate-profiles)
11+
#
12+
Set-Variable -Option Constant -Name RPG -Value "C:\your\path\to\rpg-cli.exe"
13+
14+
function rpg() {
15+
& $RPG $args
16+
sync_rpg
17+
}
18+
19+
function cdir() {
20+
& $RPG cd $args
21+
sync_rpg
22+
}
23+
24+
function dn() {
25+
$current = (Get-Item $PWD).BaseName
26+
if ($current -match "^[0-9]+$") {
27+
$next = (([int]$current) + 1) % 10
28+
New-Item -ItemType Directory -ErrorAction SilentlyContinue $next > $null
29+
cdir $next
30+
} elseif (Test-Path "1") {
31+
cdir 1
32+
} else {
33+
New-Item -ItemType Directory -ErrorAction SilentlyContinue "dungeon\1" > $null
34+
cdir "dungeon/1"
35+
}
36+
rpg ls
37+
}
38+
39+
function sync_rpg() {
40+
$pwd = & $RPG pwd
41+
Set-Location -Path $pwd
42+
}

0 commit comments

Comments
 (0)