Skip to content

Commit a9ef645

Browse files
committed
update readme, install info, error mesages, minor fix, minor score tweak
1 parent 09dff91 commit a9ef645

16 files changed

+156
-218
lines changed

Makefile

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ GOFLAGS=-ldflags "-X main.version=${VERSION} -X main.commit=${REVISION}"
88
build: submodules bin/resh-session-init bin/resh-collect bin/resh-postcollect bin/resh-daemon\
99
bin/resh-evaluate bin/resh-sanitize bin/resh-control bin/resh-config bin/resh-inspect bin/resh-cli
1010

11-
install: build conf/config-dev.toml
11+
install: build
1212
scripts/install.sh
13-
# Dev config
14-
# cp -f conf/config-dev.toml ~/.config/resh.toml
1513

1614
test_go:
1715
# Running tests

README.md

+25-32
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,18 @@ Imagine being able to search your shell history based on both the command itself
5959
- :heavy_check_mark: search by keywords
6060
- :heavy_check_mark: relevant results show up first based on context (host, directory, git, exit status)
6161
- :heavy_check_mark: allow searching completely without context ("raw" mode)
62-
- :white_check_mark: include a help page with keybindings and onboarding in the app
63-
- :x: import and search history from before RESH was installed
62+
- :heavy_check_mark: import and search history from before RESH was installed
63+
- :white_check_mark: include a help with keybindings
6464
- :x: allow listing details for individual commands
6565
- :x: allow explicitly searching by metadata
6666

6767
- :white_check_mark: Provide bindings for arrow keys
68-
- :heavy_check_mark: imitate default behaviour
69-
- :heavy_check_mark: save additional metadata (e.g. command was recalled using arrow keys)
68+
- :heavy_check_mark: imitate default behaviour (serve recent history)
69+
- :heavy_check_mark: built-in prefix search
70+
- :heavy_check_mark: serve fully dedupicated history
7071
- :x: use arrow down for easy sequence repeating
7172
- :heavy_check_mark: zsh
72-
- :white_check_mark: bash *(performance issues)*
73+
- :white_check_mark: bash *(off by deafult because of bash performance issues)*
7374

7475
- :heavy_check_mark: Provide a `reshctl` utility to control and interact with the project
7576
- :heavy_check_mark: turn on/off resh key bindings
@@ -125,47 +126,47 @@ Check for updates and update
125126
reshctl update
126127
```
127128

128-
### RESH CLI tool
129+
### RESH SEARCH application
129130

130-
RESH CLI searches your history by commands. It uses host, directories, git remote, and exit status to show you relevant results first.
131+
RESH SEARCH app searches your history by commands. It uses host, directories, git remote, and exit status to show you relevant results first.
131132

132-
All this context is not in the regular shell history. RESH CLI will only search shell history that was recorded after you install this project.
133+
All this context is not in the regular shell history. RESH records shell history with context to use it when searching.
133134

134-
*I use RESH CLI everyday but please remember that it is still a prototype.*
135+
At first, the search application will look something like this. Some history with context and most of it without. As you can see, you can still search the history just fine.
135136

136-
![resh cli](img/screen-resh-cli-v2-6.png)
137+
![resh search app](img/screen-resh-cli-v2-7-init.png)
137138

138-
Without query, RESH CLI shows you the latest history based on the current context (host, directory, git).
139+
Eventually most of your history will have context and RESH SEARCH app will get more useful.
139140

140-
![resh cli](img/screen-resh-cli-v2-6-no-query.png)
141+
![resh search app](img/screen-resh-cli-v2-7.png)
141142

142-
RESH CLI tool can be bound to ctrl+R (recommended) or executed directly.
143+
Without a query, RESH SEARCH app shows you the latest history based on the current context (host, directory, git).
143144

144-
Enable/disable ctrl+R binding for THIS shell session:
145+
![resh search app](img/screen-resh-cli-v2-7-no-query.png)
145146

146-
```sh
147-
reshctl enable ctrl_r_binding
148-
reshctl disable ctrl_r_binding
149-
```
147+
RESH SEARCH app replaces the standard reverse search - launch it using Ctrl+R.
150148

151-
Enable/disable for FUTURE shell sessions:
149+
Enable/disable the Ctrl+R keybinding:
152150

153151
```sh
154-
reshctl enable ctrl_r_binding_global
155-
reshctl disable ctrl_r_binding_global
152+
reshctl enable ctrl_r_binding
153+
reshctl disable ctrl_r_binding
156154
```
157155

158-
Run the RESH CLI tool as a one-off:
156+
You can also run the RESH SEARCH app directly as a one-off:
159157

160158
```sh
161159
resh
162160
```
163161

162+
NOTE: One feature is not available when running RESH SEARCH app directly - arrow right won't paste the selected command onto the command line for editing.
163+
164164
### Arrow key bindings
165165

166166
Resh provides arrow key bindings.
167167

168-
These bindings do regular stepping through history and prefix search.
168+
These bindings provide regular stepping through history and prefix search.
169+
They also fully deduplicate the served history.
169170

170171
They allow resh to record bindings usage metadata.
171172

@@ -175,22 +176,14 @@ They allow resh to record bindings usage metadata.
175176

176177
Arrow key bindings are enabled by default in zsh and they are disabled by default in bash because there are some performance issues.
177178

178-
Enable/disable arrow key bindings for THIS shell session:
179+
Enable/disable arrow key bindings:
179180

180181
```sh
181182
reshctl enable arrow_key_bindings
182183

183184
reshctl disable arrow_key_bindings
184185
```
185186

186-
Enable/disable for FUTURE shell sessions:
187-
188-
```sh
189-
reshctl enable arrow_key_bindings_global
190-
191-
reshctl disable arrow_key_bindings_global
192-
```
193-
194187
See what your current setting is:
195188

196189
```sh

cmd/cli/item.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ func properMatch(str, term, padChar string) bool {
267267
func newItemFromRecordForQuery(record records.CliRecord, query query, debug bool) (item, error) {
268268
// Use numbers that won't add up to same score for any number of query words
269269
const hitScore = 1.307
270-
const properMatchScore = 0.603
270+
const properMatchScore = 0.503
271271
const hitScoreConsecutive = 0.002
272272

273273
// Host penalty

cmd/cli/main.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,9 @@ func (m manager) Layout(g *gocui.Gui) error {
378378
v.Editable = true
379379
v.Editor = m
380380
if m.s.rawMode {
381-
v.Title = " RESH CLI - NON-CONTEXTUAL \"RAW\" MODE - (CTRL+R to switch BACK) "
381+
v.Title = " RESH SEARCH - NON-CONTEXTUAL \"RAW\" MODE - (CTRL+R to switch BACK) "
382382
} else {
383-
v.Title = " RESH CLI - CONTEXTUAL MODE - (CTRL+R to switch to RAW MODE) "
383+
v.Title = " RESH SEARCH - CONTEXTUAL MODE - (CTRL+R to switch to RAW MODE) "
384384
}
385385

386386
g.SetCurrentView("input")
@@ -488,11 +488,12 @@ func (m manager) normalMode(g *gocui.Gui, v *gocui.View) error {
488488
realLineLength := maxX - 2
489489
printedLineLength := maxX - 4
490490
statusLine := m.s.data[m.s.highlightedItem].drawStatusLine(compactRenderingMode, printedLineLength, realLineLength)
491-
var statusLineHeight int = len(statusLine) + 1 // help line
491+
var statusLineHeight int = len(statusLine)
492492

493493
helpLineHeight := 1
494494
const helpLine = "HELP: type to search, UP/DOWN to select, RIGHT to edit, ENTER to execute, CTRL+G to abort, CTRL+C/D to quit; " +
495-
"TIP: when resh-cli is launched command line is used as initial search query"
495+
"FLAGS: G = this git repo, E# = exit status #"
496+
// "TIP: when resh-cli is launched command line is used as initial search query"
496497

497498
mainViewHeight := maxY - topBoxHeight - statusLineHeight - helpLineHeight
498499
m.s.displayedItemsCount = mainViewHeight
@@ -605,7 +606,7 @@ func SendCliMsg(m msg.CliMsg, port string) msg.CliResponse {
605606
client := &http.Client{}
606607
resp, err := client.Do(req)
607608
if err != nil {
608-
log.Fatal("resh-daemon is not running :(")
609+
log.Fatal("resh-daemon is not running - try restarting this terminal")
609610
}
610611

611612
defer resp.Body.Close()

cmd/control/cmd/enable.go

+48-94
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,26 @@ var enableCmd = &cobra.Command{
2121

2222
var enableArrowKeyBindingsCmd = &cobra.Command{
2323
Use: "arrow_key_bindings",
24-
Short: "enable bindings for arrow keys (up/down) FOR THIS SHELL SESSION",
25-
Run: func(cmd *cobra.Command, args []string) {
26-
exitCode = status.EnableArrowKeyBindings
27-
},
28-
}
29-
30-
var enableArrowKeyBindingsGlobalCmd = &cobra.Command{
31-
Use: "arrow_key_bindings_global",
32-
Short: "enable bindings for arrow keys (up/down) FOR FUTURE SHELL SESSIONS",
33-
Long: "Enable bindings for arrow keys (up/down) FOR FUTURE SHELL SESSIONS.\n" +
24+
Short: "enable bindings for arrow keys (up/down)",
25+
Long: "Enable bindings for arrow keys (up/down)\n" +
3426
"Note that this only affects sessions of the same shell.\n" +
35-
"(e.g. running this in zsh will only affect future zsh sessions)",
27+
"(e.g. running this in zsh will only enable the keybinding in zsh)",
3628
Run: func(cmd *cobra.Command, args []string) {
3729
exitCode = enableDisableArrowKeyBindingsGlobally(true)
30+
if exitCode == status.Success {
31+
exitCode = status.EnableArrowKeyBindings
32+
}
3833
},
3934
}
4035

4136
var enableControlRBindingCmd = &cobra.Command{
4237
Use: "ctrl_r_binding",
43-
Short: "enable binding for control+R FOR THIS SHELL SESSION",
44-
Run: func(cmd *cobra.Command, args []string) {
45-
exitCode = status.EnableControlRBinding
46-
},
47-
}
48-
49-
var enableControlRBindingGlobalCmd = &cobra.Command{
50-
Use: "ctrl_r_binding_global",
51-
Short: "enable bindings for control+R FOR FUTURE SHELL SESSIONS",
38+
Short: "enable RESH-CLI binding for Ctrl+R",
5239
Run: func(cmd *cobra.Command, args []string) {
5340
exitCode = enableDisableControlRBindingGlobally(true)
41+
if exitCode == status.Success {
42+
exitCode = status.EnableControlRBinding
43+
}
5444
},
5545
}
5646

@@ -63,36 +53,26 @@ var disableCmd = &cobra.Command{
6353

6454
var disableArrowKeyBindingsCmd = &cobra.Command{
6555
Use: "arrow_key_bindings",
66-
Short: "disable bindings for arrow keys (up/down) FOR THIS SHELL SESSION",
67-
Run: func(cmd *cobra.Command, args []string) {
68-
exitCode = status.DisableArrowKeyBindings
69-
},
70-
}
71-
72-
var disableArrowKeyBindingsGlobalCmd = &cobra.Command{
73-
Use: "arrow_key_bindings_global",
74-
Short: "disable bindings for arrow keys (up/down) FOR FUTURE SHELL SESSIONS",
75-
Long: "Disable bindings for arrow keys (up/down) FOR FUTURE SHELL SESSIONS.\n" +
56+
Short: "disable bindings for arrow keys (up/down)",
57+
Long: "Disable bindings for arrow keys (up/down)\n" +
7658
"Note that this only affects sessions of the same shell.\n" +
77-
"(e.g. running this in zsh will only affect future zsh sessions)",
59+
"(e.g. running this in zsh will only enable the keybinding in zsh)",
7860
Run: func(cmd *cobra.Command, args []string) {
7961
exitCode = enableDisableArrowKeyBindingsGlobally(false)
62+
if exitCode == status.Success {
63+
exitCode = status.DisableArrowKeyBindings
64+
}
8065
},
8166
}
8267

8368
var disableControlRBindingCmd = &cobra.Command{
8469
Use: "ctrl_r_binding",
85-
Short: "disable binding for control+R FOR THIS SHELL SESSION",
86-
Run: func(cmd *cobra.Command, args []string) {
87-
exitCode = status.DisableControlRBinding
88-
},
89-
}
90-
91-
var disableControlRBindingGlobalCmd = &cobra.Command{
92-
Use: "ctrl_r_binding_global",
93-
Short: "disable bindings for control+R FOR FUTURE SHELL SESSIONS",
70+
Short: "disable RESH-CLI binding for Ctrl+R",
9471
Run: func(cmd *cobra.Command, args []string) {
9572
exitCode = enableDisableControlRBindingGlobally(false)
73+
if exitCode == status.Success {
74+
exitCode = status.DisableControlRBinding
75+
}
9676
},
9777
}
9878

@@ -131,37 +111,24 @@ func enableDisableArrowKeyBindingsGlobally(value bool) status.Code {
131111
// I don't like the interface this function has - passing both config structure and a part of it feels wrong
132112
// It's ugly and could lead to future errors
133113
func setConfigBindArrowKey(configPath string, config *cfg.Config, configField *bool, shell string, value bool) error {
134-
if *configField == value {
135-
if value {
136-
fmt.Println("The RESH arrow key bindings are ALREADY GLOBALLY ENABLED for all future " + shell + " sessions - nothing to do - exiting.")
137-
} else {
138-
fmt.Println("The RESH arrow key bindings are ALREADY GLOBALLY DISABLED for all future " + shell + " sessions - nothing to do - exiting.")
139-
}
140-
return nil
141-
}
142-
if value {
143-
fmt.Println("ENABLING the RESH arrow key bindings GLOBALLY (in " + shell + ") ...")
144-
} else {
145-
fmt.Println("DISABLING the RESH arrow key bindings GLOBALLY (in " + shell + ") ...")
146-
}
147-
*configField = value
114+
if *configField != value {
115+
*configField = value
148116

149-
f, err := os.Create(configPath)
150-
if err != nil {
151-
fmt.Println("Error: Failed to create/open file:", configPath, "; error:", err)
152-
return err
153-
}
154-
defer f.Close()
155-
if err := toml.NewEncoder(f).Encode(config); err != nil {
156-
fmt.Println("Error: Failed to encode and write the config values to hdd. error:", err)
157-
return err
117+
f, err := os.Create(configPath)
118+
if err != nil {
119+
fmt.Println("Error: Failed to create/open file:", configPath, "; error:", err)
120+
return err
121+
}
122+
defer f.Close()
123+
if err := toml.NewEncoder(f).Encode(config); err != nil {
124+
fmt.Println("Error: Failed to encode and write the config values to hdd. error:", err)
125+
return err
126+
}
158127
}
159128
if value {
160-
fmt.Println("SUCCESSFULLY ENABLED the RESH arrow key bindings GLOBALLY (in " + shell + ") " +
161-
"- every new (" + shell + ") session will start with enabled RESH arrow key bindings!")
129+
fmt.Println("RESH arrow key bindings: ENABLED (in " + shell + ")")
162130
} else {
163-
fmt.Println("SUCCESSFULLY DISABLED the RESH arrow key bindings GLOBALLY (in " + shell + ") " +
164-
"- every new (" + shell + ") session will start with " + shell + " default arrow key bindings!")
131+
fmt.Println("RESH arrow key bindings: DISABLED (in " + shell + ")")
165132
}
166133
return nil
167134
}
@@ -175,37 +142,24 @@ func enableDisableControlRBindingGlobally(value bool) status.Code {
175142
fmt.Println("Error reading config", err)
176143
return status.Fail
177144
}
178-
if config.BindControlR == value {
179-
if value {
180-
fmt.Println("The RESH control+R binding is ALREADY GLOBALLY ENABLED for all future shell sessions - nothing to do - exiting.")
181-
} else {
182-
fmt.Println("The RESH control+R binding is ALREADY GLOBALLY DISABLED for all future shell sessions - nothing to do - exiting.")
183-
}
184-
return status.Fail
185-
}
186-
if value {
187-
fmt.Println("ENABLING the RESH arrow key bindings GLOBALLY ...")
188-
} else {
189-
fmt.Println("DISABLING the RESH arrow key bindings GLOBALLY ...")
190-
}
191-
config.BindControlR = value
145+
if config.BindControlR != value {
146+
config.BindControlR = value
192147

193-
f, err := os.Create(configPath)
194-
if err != nil {
195-
fmt.Println("Error: Failed to create/open file:", configPath, "; error:", err)
196-
return status.Fail
197-
}
198-
defer f.Close()
199-
if err := toml.NewEncoder(f).Encode(config); err != nil {
200-
fmt.Println("Error: Failed to encode and write the config values to hdd. error:", err)
201-
return status.Fail
148+
f, err := os.Create(configPath)
149+
if err != nil {
150+
fmt.Println("Error: Failed to create/open file:", configPath, "; error:", err)
151+
return status.Fail
152+
}
153+
defer f.Close()
154+
if err := toml.NewEncoder(f).Encode(config); err != nil {
155+
fmt.Println("Error: Failed to encode and write the config values to hdd. error:", err)
156+
return status.Fail
157+
}
202158
}
203159
if value {
204-
fmt.Println("SUCCESSFULLY ENABLED the RESH arrow key bindings GLOBALLY " +
205-
"- every new shell session will start with enabled RESH CLI control+R binding!")
160+
fmt.Println("RESH SEARCH app Ctrl+R binding: ENABLED")
206161
} else {
207-
fmt.Println("SUCCESSFULLY DISABLED the RESH arrow key bindings GLOBALLY " +
208-
"- every new shell session will start with your orignal control+R key binding!")
162+
fmt.Println("RESH SEARCH app Ctrl+R binding: DISABLED")
209163
}
210164
return status.Success
211165
}

cmd/control/cmd/root.go

-4
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,11 @@ func Execute(ver, com string) status.Code {
4343

4444
rootCmd.AddCommand(enableCmd)
4545
enableCmd.AddCommand(enableArrowKeyBindingsCmd)
46-
enableCmd.AddCommand(enableArrowKeyBindingsGlobalCmd)
4746
enableCmd.AddCommand(enableControlRBindingCmd)
48-
enableCmd.AddCommand(enableControlRBindingGlobalCmd)
4947

5048
rootCmd.AddCommand(disableCmd)
5149
disableCmd.AddCommand(disableArrowKeyBindingsCmd)
52-
disableCmd.AddCommand(disableArrowKeyBindingsGlobalCmd)
5350
disableCmd.AddCommand(disableControlRBindingCmd)
54-
disableCmd.AddCommand(disableControlRBindingGlobalCmd)
5551

5652
rootCmd.AddCommand(completionCmd)
5753
completionCmd.AddCommand(completionBashCmd)

cmd/inspect/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func SendInspectMsg(m msg.InspectMsg, port string) msg.MultiResponse {
6666
client := &http.Client{}
6767
resp, err := client.Do(req)
6868
if err != nil {
69-
log.Fatal("resh-daemon is not running :(")
69+
log.Fatal("resh-daemon is not running - try restarting this terminal")
7070
}
7171

7272
defer resp.Body.Close()

0 commit comments

Comments
 (0)