Skip to content

Commit f291156

Browse files
authored
Merge pull request #814 from yorukot/prompt_tutorial
SPF Prompt tutorial and fixes
2 parents 283a1f5 + 2d8999a commit f291156

File tree

9 files changed

+49
-20
lines changed

9 files changed

+49
-20
lines changed

asset/prompt_shell_mode.png

78.9 KB
Loading

asset/prompt_spf_mode.png

110 KB
Loading

src/internal/ui/prompt/consts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const (
1919
failureMessagePrefix = "Error"
2020

2121
shellModeString = "(Shell Mode)"
22-
spfModeString = "(Prompt Mode)"
22+
spfModeString = "(SPF Mode)"
2323

2424
// Error message string
2525
tokenizationError = "Failed during tokenization"

src/internal/ui/prompt/model.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (m *Model) HandleSPFActionResults(success bool, msg string) {
123123

124124
func (m *Model) Render() string {
125125
r := ui.PromptRenderer(m.maxHeight, m.width)
126-
r.SetBorderTitle(m.headline + modeString(m.shellMode))
126+
r.SetBorderTitle(m.headline + " " + modeString(m.shellMode))
127127
r.AddLines(" " + m.textInput.View())
128128

129129
if !m.shellMode {
@@ -148,7 +148,7 @@ func (m *Model) Render() string {
148148
}
149149
} else if m.textInput.Value() == "" {
150150
r.AddSection()
151-
r.AddLines(" '" + m.spfPromptHotkey + "' - Get into SPF Prompt mode")
151+
r.AddLines(" '" + m.spfPromptHotkey + "' - Get into SPF mode")
152152
}
153153

154154
if m.resultMsg != "" {

src/internal/ui/prompt/model_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -239,19 +239,19 @@ func TestModel_Render(t *testing.T) {
239239
m.setShellMode(true)
240240
res := ansi.Strip(m.Render())
241241
exp := "" +
242-
"╭─┤ " + icon.Terminal + " Superfile Prompt(Shell Mode) ├──╮\n" +
243-
// 000123--------4------------56789012345678901234567890123456789
242+
"╭─┤ " + icon.Terminal + " Superfile Prompt (Shell Mode) ├──╮\n" +
243+
// 23--------4------------56789012345678901234567890123456789
244244
"│ : │\n" +
245-
// 000123456789012345678901234567890123456789
245+
// 23456789012345678901234567890123456789
246246
"├──────────────────────────────────────┤\n" +
247-
"│ '>' - Get into SPF Prompt mode │\n" +
247+
"│ '>' - Get into SPF mode \n" +
248248
"╰──────────────────────────────────────╯"
249249
assert.Equal(t, exp, res)
250250
m.setShellMode(false)
251251
res = ansi.Strip(m.Render())
252252
exp = "" +
253-
"╭─┤ " + icon.Terminal + " Superfile Prompt(Prompt Mode) ├──╮\n" +
254-
// 000123--------4------------56789012345678901234567890123456789
253+
"╭─┤ " + icon.Terminal + " Superfile Prompt (SPF Mode) ├────╮\n" +
254+
// 23--------4------------56789012345678901234567890123456789
255255
"│ > │\n" +
256256
"├──────────────────────────────────────┤\n" +
257257
"│ ':' - Get into Shell mode │\n" +
@@ -292,25 +292,25 @@ func TestModel_Render(t *testing.T) {
292292
m.HandleShellCommandResults(0, "")
293293
res := ansi.Strip(m.Render())
294294
exp := "" +
295-
"╭─┤ " + icon.Terminal + " Superfile Prompt(Shell Mode) ├────────────╮\n" +
296-
// 000123--------4------------567890123456789012345678901234567890123456789
295+
"╭─┤ " + icon.Terminal + " Superfile Prompt (Shell Mode) ├────────────╮\n" +
296+
// 23--------4------------567890123456789012345678901234567890123456789
297297
"│ : │\n" +
298-
// 0001234567890123456789012345678901234567890123456789
298+
// 234567890123456789012345678901234567890123456789
299299
"├────────────────────────────────────────────────┤\n" +
300-
"│ '>' - Get into SPF Prompt mode │\n" +
300+
"│ '>' - Get into SPF mode \n" +
301301
"├────────────────────────────────────────────────┤\n" +
302302
"│ Success : Command exited with status 0 │\n" +
303303
"╰────────────────────────────────────────────────╯"
304304
assert.Equal(t, exp, res)
305305
m.HandleShellCommandResults(1, "")
306306
res = ansi.Strip(m.Render())
307307
exp = "" +
308-
"╭─┤ " + icon.Terminal + " Superfile Prompt(Shell Mode) ├────────────╮\n" +
309-
// 000123--------4------------567890123456789012345678901234567890123456789
308+
"╭─┤ " + icon.Terminal + " Superfile Prompt (Shell Mode) ├────────────╮\n" +
309+
// 23--------4------------567890123456789012345678901234567890123456789
310310
"│ : │\n" +
311-
// 0001234567890123456789012345678901234567890123456789
311+
// 234567890123456789012345678901234567890123456789
312312
"├────────────────────────────────────────────────┤\n" +
313-
"│ '>' - Get into SPF Prompt mode │\n" +
313+
"│ '>' - Get into SPF mode \n" +
314314
"├────────────────────────────────────────────────┤\n" +
315315
"│ Error : Command exited with status 1 │\n" +
316316
"╰────────────────────────────────────────────────╯"

src/internal/ui/prompt/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func getPromptAction(shellMode bool, value string, cwdLocation string) (common.M
5757

5858
default:
5959
return noAction, invalidCmdError{
60-
uiMsg: "Invalid spf prompt command : " + promptArgs[0],
60+
uiMsg: "Invalid spf command : " + promptArgs[0],
6161
}
6262
}
6363
}

src/internal/ui/prompt/utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestModel_getPromptAction(t *testing.T) {
6868
shellMode: false,
6969
expectecAction: common.NoAction{},
7070
expectedErr: true,
71-
expectedErrMsg: "Invalid spf prompt command : abcd",
71+
expectedErrMsg: "Invalid spf command : abcd",
7272
},
7373
{
7474
name: "Correct split command",

website/src/content/docs/getting-started/tutorial.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,31 @@ If your directory editor does not support opening the current directory with an
177177

178178
(Sorry, this video has a little bit of lag)
179179
[demo video](https://github.com/yorukot/superfile/assets/107802416/d0770b3f-025e-40c9-ad3f-8b2adaf1c6c5)
180+
181+
### SPF Prompt
182+
#### Shell Mode
183+
Press `:` to open the prompt in shell mode, and execute any shell command in the current directory.
184+
![Prompt-Shell-Mode](https://github.com/yorukot/superfile/blob/main/asset/prompt_shell_mode.png?raw=true)
185+
186+
:::note
187+
You won't receive any stdout outputs.
188+
For now, this is meant for executing more complex file manipulations via the shell,
189+
rather than handling interactive outputs.
190+
You will be able to see the exit code of the command.
191+
:::
192+
193+
#### SPF Mode
194+
Press `>` to open the prompt in SPF mode.
195+
![Prompt-SPF-Mode](https://github.com/yorukot/superfile/blob/main/asset/prompt_spf_mode.png?raw=true)
196+
197+
In this mode, you can execute these spf commands :
198+
- `split` - Open a new panel at a current file panel's path.
199+
- `open <PATH>` - Open a new panel at a specified path.
200+
- `cd <PATH>` - Change directory of current panel.
201+
202+
In this mode, You can substitute shell environment variables via `${}`, shell commands via `$()` and prefix path with `~` to get substituted to home directory
203+
For example
204+
- `cd ${HOME}` or `cd ~/xyz`
205+
- `open $(dirname $(which bash))`
206+
207+
Press `esc` or `ctrl`+`c` to exit Prompt.

website/src/content/docs/list/hotkey-list.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ These are the default hotkeys and you can [change](/configure/custom-hotkeys) th
3333
| Focus on the processbar panel | `p` | `focus_on_process_bar` |
3434
| Focus on the sidebar | `s` | `focus_on_side_bar` |
3535
| Focus on the metadata panel | `m` | `focus_on_metadata` |
36-
| Open command execution bar | `:` | `open_command_line` |
36+
| Open prompt in shell mode | `:` | `open_command_line` |
37+
| Open prompt in spf mode | `>` | `open_spf_prompt` |
3738

3839
## Panel movement
3940

0 commit comments

Comments
 (0)