ruby-shell 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/PLUGIN_GUIDE.md +757 -0
- data/README.md +89 -6
- data/bin/rsh +858 -48
- metadata +5 -4
data/README.md
CHANGED
|
@@ -33,7 +33,34 @@ Or simply `gem install ruby-shell`.
|
|
|
33
33
|
* All colors are themeable in .rshrc (see github link for possibilities)
|
|
34
34
|
* Copy current command line to primary selection (paste w/middle button) with `Ctrl-y`
|
|
35
35
|
|
|
36
|
-
## NEW in v3.
|
|
36
|
+
## NEW in v3.2.0 - Plugin System & Productivity ⭐⭐⭐
|
|
37
|
+
* **Plugin Architecture**: Extensible plugin system with lifecycle hooks and extension points
|
|
38
|
+
* **Lifecycle Hooks**: on_startup, on_command_before, on_command_after, on_prompt
|
|
39
|
+
* **Extension Points**: add_completions (TAB completion), add_commands (custom commands)
|
|
40
|
+
* **Plugin Management**: `:plugins` list/reload/enable/disable/info commands
|
|
41
|
+
* **Auto-loading**: Plugins in `~/.rsh/plugins/` load automatically on startup
|
|
42
|
+
* **Safe Execution**: Isolated plugin execution with error handling, no shell crashes
|
|
43
|
+
* **Example Plugins**: git_prompt (branch in prompt), command_logger (audit log), kubectl_completion (k8s shortcuts)
|
|
44
|
+
* **Auto-correct Typos**: `:config "auto_correct", "on"` with user confirmation (Y/n) before applying
|
|
45
|
+
* **Command Timing Alerts**: `:config "slow_command_threshold", "5"` warns on commands > 5 seconds
|
|
46
|
+
* **Inline Calculator**: `:calc 2 + 2`, `:calc "Math::PI"` - full Ruby Math library support
|
|
47
|
+
* **Enhanced History**: `!!` (last), `!-2` (2nd to last), `!5:7` (chain commands 5-7)
|
|
48
|
+
* **Stats Visualization**: `:stats --graph` for colorful ASCII bar charts with intensity colors
|
|
49
|
+
* **Documentation**: Complete PLUGIN_GUIDE.md with API reference and examples
|
|
50
|
+
|
|
51
|
+
## v3.1.0 - Quick Wins & Polish ⭐
|
|
52
|
+
* **Multiple Named Sessions**: Save/load different sessions - `:save_session "project"`, `:load_session "project"`
|
|
53
|
+
* **Stats Export**: Export analytics to CSV/JSON - `:stats --csv` or `:stats --json`
|
|
54
|
+
* **Session Auto-save**: Set `@session_autosave = 300` in .rshrc for automatic 5-minute saves
|
|
55
|
+
* **Bookmark Import/Export**: Share bookmarks - `:bm --export bookmarks.json`, `:bm --import bookmarks.json`
|
|
56
|
+
* **Bookmark Statistics**: See usage patterns - `:bm --stats` shows tag distribution and analytics
|
|
57
|
+
* **Color Themes**: 6 preset themes - `:theme solarized|dracula|gruvbox|nord|monokai|default`
|
|
58
|
+
* **Config Management**: `:config` shows/sets history_dedup, session_autosave, completion settings
|
|
59
|
+
* **Environment Variables**: `:env` lists/sets/exports environment variables
|
|
60
|
+
* **Bookmark TAB Completion**: Bookmarks appear in TAB completion alongside commands
|
|
61
|
+
* **List Sessions**: `:list_sessions` shows all saved sessions with timestamps and paths
|
|
62
|
+
|
|
63
|
+
## v3.0.0 - Major Feature Release ⭐⭐⭐
|
|
37
64
|
* **Persistent Ruby Functions**: defun functions now save to .rshrc and persist across sessions
|
|
38
65
|
* **Smart Command Suggestions**: Typo detection with "Did you mean...?" suggestions using Levenshtein distance
|
|
39
66
|
* **Command Analytics**: New `:stats` command shows usage statistics, performance metrics, and most-used commands
|
|
@@ -94,8 +121,10 @@ Special commands:
|
|
|
94
121
|
* `:bm "name"` or `:bookmark "name"` bookmark current directory, `:bm "name path #tags"` with tags (NEW in v3.0)
|
|
95
122
|
* `:bm` lists all bookmarks, just type bookmark name to jump (e.g., `work`) (NEW in v3.0)
|
|
96
123
|
* `:bm "-name"` delete bookmark, `:bm "?tag"` search by tag (NEW in v3.0)
|
|
97
|
-
* `:save_session` saves
|
|
98
|
-
* `:
|
|
124
|
+
* `:save_session "name"` saves named session, `:load_session "name"` loads session (NEW in v3.0)
|
|
125
|
+
* `:list_sessions` shows all saved sessions, `:rmsession "name"` or `:rmsession "*"` deletes (NEW in v3.1)
|
|
126
|
+
* `:theme "name"` applies color scheme, `:config` manages settings, `:env` manages environment (NEW in v3.1)
|
|
127
|
+
* `:plugins` lists plugins, `:plugins "disable", "name"` disables, `:plugins "reload"` reloads (NEW in v3.2)
|
|
99
128
|
* `:info` shows introduction and feature overview
|
|
100
129
|
* `:version` Shows the rsh version number and the last published gem file version
|
|
101
130
|
* `:help` will display a compact command reference in two columns
|
|
@@ -125,12 +154,19 @@ Add to your `.rshrc`:
|
|
|
125
154
|
While you `cd` around to different directories, you can see the last 10 directories visited via the command `:dirs` or the convenient shortcut `#`. Entering the number in the list (like `6` and ENTER) will jump you to that directory. Entering `-` will jump you back to the previous dir (equivalent of `1`. Entering `~` will get you to your home dir. If you want to bookmark a special directory, you can do that via a general nick like this: `:gnick "x = /path/to/a/dir/"` - this would bookmark the directory to the single letter `x`.
|
|
126
155
|
|
|
127
156
|
## Nicks
|
|
128
|
-
Add command nicks (aliases) with `:nick "some_nick = some_command"`, e.g. `:nick "ls = ls --color"`. Add general nicks that will substitute anything on a command line (not just commands) like this `:gnick "some_gnick = some_command"`, e.g. `:gnick "x = /home/user/somewhere"`. List
|
|
157
|
+
Add command nicks (aliases) with `:nick "some_nick = some_command"`, e.g. `:nick "ls = ls --color"`. Add general nicks that will substitute anything on a command line (not just commands) like this `:gnick "some_gnick = some_command"`, e.g. `:gnick "x = /home/user/somewhere"`. List nicks with `:nick`, list gnicks with `:gnick`. Remove a nick with `:nick "-some_command"`, e.g. `:nick "-ls"` to remove an `ls` nick. Same for gnicks.
|
|
129
158
|
|
|
130
159
|
## Tab completion
|
|
131
|
-
You can tab complete almost anything. Hitting `TAB` will try to complete in this priority: nicks, gnicks, commands, dirs/files.
|
|
160
|
+
You can tab complete almost anything. Hitting `TAB` will try to complete in this priority: nicks, gnicks, commands, dirs/files. Special completions:
|
|
161
|
+
- `ls -<TAB>` lists command switches from --help with descriptions
|
|
162
|
+
- `:st<TAB>` completes colon commands (:stats, etc.)
|
|
163
|
+
- `$HO<TAB>` completes environment variables ($HOME, etc.)
|
|
164
|
+
- `git <TAB>` shows git subcommands (add, commit, push, etc.)
|
|
165
|
+
- `--format=<TAB>` completes option values (json, yaml, xml, etc.)
|
|
132
166
|
|
|
133
|
-
|
|
167
|
+
You can add to (or subtract from) the search criteria while selecting matches - hit any letter to refine the search, backspace removes a letter from the criteria.
|
|
168
|
+
|
|
169
|
+
Hitting Shift-TAB will search through the command history with fuzzy matching.
|
|
134
170
|
|
|
135
171
|
## Open files
|
|
136
172
|
If you press `ENTER` after writing or tab-completing to a file, rsh will try to open the file in the user's EDITOR of choice (if it is a valid text file) or use `xdg-open` to open the file using the correct program. If you, for some reason want to use `run-mailcap` instead of `xdg-open` as the file opener, simply add `@runmailcap = true` to your `.rshrc`.
|
|
@@ -191,6 +227,52 @@ Ruby functions have access to:
|
|
|
191
227
|
- JSON/XML parsing
|
|
192
228
|
- And everything else Ruby can do!
|
|
193
229
|
|
|
230
|
+
## Plugin System (v3.2.0+)
|
|
231
|
+
|
|
232
|
+
rsh supports a powerful plugin system for extending functionality. Plugins are Ruby classes placed in `~/.rsh/plugins/` that can:
|
|
233
|
+
|
|
234
|
+
- Add custom commands
|
|
235
|
+
- Add TAB completions
|
|
236
|
+
- Hook into command execution (before/after)
|
|
237
|
+
- Modify the prompt
|
|
238
|
+
- Access rsh internals (history, bookmarks, etc.)
|
|
239
|
+
|
|
240
|
+
**Quick Start:**
|
|
241
|
+
```ruby
|
|
242
|
+
# Create ~/.rsh/plugins/hello.rb
|
|
243
|
+
class HelloPlugin
|
|
244
|
+
def initialize(rsh_context)
|
|
245
|
+
@rsh = rsh_context
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def add_commands
|
|
249
|
+
{
|
|
250
|
+
"hello" => lambda { |*args| "Hello, #{args[0] || 'World'}!" }
|
|
251
|
+
}
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Then in rsh: `hello Geir` outputs `Hello, Geir!`
|
|
257
|
+
|
|
258
|
+
**Plugin Management:**
|
|
259
|
+
```bash
|
|
260
|
+
:plugins # List all loaded plugins
|
|
261
|
+
:plugins "disable", "git_prompt" # Disable a plugin
|
|
262
|
+
:plugins "enable", "git_prompt" # Enable a plugin
|
|
263
|
+
:plugins "reload" # Reload all plugins
|
|
264
|
+
:plugins "info", "plugin_name" # Show plugin details
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**Included Example Plugins:**
|
|
268
|
+
- **git_prompt** - Shows current git branch in prompt
|
|
269
|
+
- **command_logger** - Logs all commands with timestamps (`show_log` to view)
|
|
270
|
+
- **kubectl_completion** - Kubernetes shortcuts and completions (k, kns, kctx)
|
|
271
|
+
|
|
272
|
+
**See PLUGIN_GUIDE.md for complete development documentation.**
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
194
276
|
## Integrations
|
|
195
277
|
rsh is integrated with the [rtfm file manager](https://github.com/isene/RTFM), with [fzf](https://github.com/junegunn/fzf) and with the programming language [XRPN](https://github.com/isene/xrpn).
|
|
196
278
|
|
|
@@ -215,6 +297,7 @@ Variable | Description
|
|
|
215
297
|
`@c_path` | Color for valid path
|
|
216
298
|
`@c_switch` | Color for command switches/options
|
|
217
299
|
`@c_bookmark` | Color for bookmarks (NEW in v3.0)
|
|
300
|
+
`@c_colon` | Color for colon commands (NEW in v3.1)
|
|
218
301
|
`@c_tabselect` | Color for selected tabcompleted item
|
|
219
302
|
`@c_taboption` | Color for unselected tabcompleted item
|
|
220
303
|
`@c_stamp` | Color for time stamp/command
|