diff --git a/README.md b/README.md
index 100f912..9a2b772 100644
--- a/README.md
+++ b/README.md
@@ -80,6 +80,7 @@ echo "Hello $USER!"
| ,qa | Close all without saving |
| ,t | Tagbar |
| ,rr | Run script in new tab (python, go, preview markdown)|
+| ,rs | Run script in new tab by shebang |
| ,rf | Format file (go, rust) |
diff --git a/sub/nvim/lua/base/keys/run-scripts.lua b/sub/nvim/lua/base/keys/run-scripts.lua
index d3282d0..9a40569 100644
--- a/sub/nvim/lua/base/keys/run-scripts.lua
+++ b/sub/nvim/lua/base/keys/run-scripts.lua
@@ -19,9 +19,18 @@ local function set_keymap_format_file(cmd)
set_keymap_base("f", cmd_string)
end
+local function set_keymap_run_script_base(key, cmd)
+ local run_script_string = [[:tabnew %% :terminal %s %% :set nocursorline number norelativenumber G ]]
+ local cmd_string = string.format(run_script_string, cmd)
+ set_keymap_base(key, cmd_string)
+end
+
local function set_keymap_run_script(cmd)
- local cmd_string = string.format([[:tabnew %% :terminal %s %% :set nocursorline number norelativenumber G ]], cmd)
- set_keymap_base("r", cmd_string)
+ set_keymap_run_script_base("r", cmd)
+end
+
+local function set_keymap_run_script_by_shebang(cmd)
+ set_keymap_run_script_base("s", cmd)
end
local function create_function_autocmd_by_filetype(set_keymap_func, ft, cmd)
@@ -58,3 +67,5 @@ autocmd(create_function_autocmd_by_filename(set_keymap_run_script, 'manpage', 'm
autocmd_format_file_by_filetype('rust', 'cargo fmt -p')
autocmd_format_file_by_filetype('go', 'go fmt')
+
+autocmd(function() set_keymap_run_script_by_shebang([[$(head -1 % | cut -c 3-) %]]) end)