Skip to content

Commit 9f79b15

Browse files
committed
added quick editing
1 parent 3eccbd5 commit 9f79b15

File tree

5 files changed

+23
-3
lines changed

5 files changed

+23
-3
lines changed

.conf.template

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
editor_command=vim
2+
quick_editor_command=vim
23
print_command=cat
34
default_collection=scripts

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
---
44

5-
## [v1.0.0](https://github.com/cophilot/msh/tree/1.0.0) (2024-??-??)
5+
## [v1.0.0](https://github.com/cophilot/msh/tree/1.0.0) (2025-??-??)
66

77
- Added `manual` command
8+
- Added `quick` flag for the `edit` command
9+
- Added `quick-edit` flag for the `new` command
810

911
---
1012

src/commands/edit

+8-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
# Edit a script in the editor
66
function edit_command {
77
require_dir $HOME_DIR
8-
edcom=$(get_editor_command)
98
script_name=${VALUES[0]}
109

10+
edcom=$(get_editor_command)
11+
if [ "$(is_flag_specified '-quick' '-q')" == "true" ]; then
12+
edcom=$(get_quick_editor_command)
13+
fi
14+
1115
if [ -z "$script_name" ]; then
1216
$edcom $HOME_DIR
1317
myexit 0
@@ -25,8 +29,10 @@ function edit_command {
2529

2630
# Print help for the edit command
2731
function edit_help {
28-
log " edit|e [script-name] - Open a specified or all scripts in the editor"
32+
log " edit|e [script-name] [flags] - Open a specified or all scripts in the editor"
2933
log " script-name - If provided, the script with the specified name will be opened in the editor"
34+
log " Flags:"
35+
log " -quick|-q - Use the quick editor command"
3036
log ""
3137
}
3238

src/commands/new

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ function new_command {
3636
edcom=$(get_editor_command)
3737
$edcom $sc_dir/$script_name
3838
fi
39+
if [ "$(is_flag_specified '-quick-edit' '-qe')" == "true" ]; then
40+
edcom=$(get_quick_editor_command)
41+
$edcom $sc_dir/$script_name
42+
fi
3943
}
4044

4145
# Print help for the new command
@@ -46,6 +50,7 @@ function new_help {
4650
log " Flags:"
4751
log " -edit|-e - Open the script in the editor after creation"
4852
log " -man|-m - Add a manual to the script"
53+
log " -quick-edit|-qe - Open the script in the editor after creation, using the quick editor command"
4954
log ""
5055
}
5156

src/utils/conf

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ function get_editor_command() {
4747
echo "$editor_command"
4848
}
4949

50+
# Get the quick editor command from the conf file
51+
function get_quick_editor_command() {
52+
local editor_command=$(get_conf "quick_editor_command" "vim")
53+
echo "$editor_command"
54+
}
55+
5056
# Get the print command from the conf file
5157
function get_print_command() {
5258
local print_command=$(get_conf "print_command" "cat")

0 commit comments

Comments
 (0)