From ff14ba61f9563b50661d6811623c4915fc7f9470 Mon Sep 17 00:00:00 2001 From: Galen Rowell Date: Tue, 20 Jul 2021 19:36:06 +1000 Subject: [PATCH 1/4] open new buffers, instead of tabs --- lua/mappings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/mappings.lua b/lua/mappings.lua index c682130..cc4b99a 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -133,7 +133,7 @@ map("n", "fh", [[Telescope help_tags]], opt) map("n", "fo", [[Telescope oldfiles]], opt) -- bufferline tab stuff -map("n", "", ":tabnew", opt) -- new tab +map("n", "", ":enew", opt) -- new tab map("n", "", ":bd!", opt) -- close tab -- move between tabs From a6ea40d7baaacc75cf39cd4fc02c21756458cc09 Mon Sep 17 00:00:00 2001 From: Galen Rowell Date: Tue, 20 Jul 2021 19:38:43 +1000 Subject: [PATCH 2/4] open default shell terminal with proper neovim commands, fix buffer tabline issue --- lua/mappings.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/mappings.lua b/lua/mappings.lua index cc4b99a..d779756 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -27,9 +27,9 @@ vim.api.nvim_set_keymap("t", "jk", "", {}) map("v", "p", '"_dP', opt) -- OPEN TERMINALS -- -map("n", "", [[vnew term://bash ]], opt) -- term over right -map("n", "", [[ split term://bash | resize 10 ]], opt) -- term bottom -map("n", "t", [[ tabnew | term ]], opt) -- term newtab +map("n", "", [[ vnew +terminal | setlocal nobuflisted ]], opt) -- term over right +map("n", "", [[ 10new +terminal | setlocal nobuflisted ]], opt) -- term bottom +map("n", "t", [[ terminal ]], opt) -- term buffer -- copy whole file content map("n", "", [[ %y+]], opt) From 15f20e8437b468f9d4fe616251822f7eaa40a6ac Mon Sep 17 00:00:00 2001 From: Galen Rowell Date: Tue, 20 Jul 2021 19:41:50 +1000 Subject: [PATCH 3/4] better shell setup scripting --- install.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/install.sh b/install.sh index 69bce33..9683ca4 100755 --- a/install.sh +++ b/install.sh @@ -71,27 +71,28 @@ _setup_terminal_shell() { _mappings_file="${_CONFIG_PATH}/lua/mappings.lua" # only ask for shellname if running in terminal if [ -t 1 ]; then - printf "%s\n: " "Which shell do you want to use ? [ Enter nothing for current shell ( $_CURRENT_SHELL ) ]" - read -r shellname + printf "\n%s\n" "Which shell do you want to use? (Eg. 2)" + printf "\t%s\n" "[ Enter nothing for current shell ( $_CURRENT_SHELL ) ]" + grep '^/bin/' '/etc/shells' | nl + read -r shellNUM fi - shellname="${shellname:-${_CURRENT_SHELL}}" - printf "%s\n" "$shellname" - # don't try to do any changes if given shellname is same as bash - if ! [ bash = "$shellname" ]; then + # don't try to do any changes user wants their default shell in nvim + if [ ! -z "$shellNUM" ]; then + shellpath=$(grep '^/bin/' '/etc/shells' | sed -n "$shellNUM p") # Reference: https://stackoverflow.com/a/4247319 - if "${_SED}" -i'.bak' -e "s/bash/$shellname/g" "${_mappings_file}"; then - printf "\n%s\n" "=> Shell changed to $shellname on nvim successfully!" + # \( & \) will use regex brackets (for later reference with \1) + # ( & ) will match text brackets + if "${_SED}" --posix -i'.bak' -e "s=^\(map(.* \+*terminal\) \(.*)\)=\1$shellpath \2=g" "${_mappings_file}"; then + printf "%s\n" "=> Neovim shell changed to $shellpath successfully!" else - printf "\n%s\n" "Cannot edit with sed, edit ${_mappings_file} manually to replace bash with $shellname." + printf "%s\n" "Cannot edit with sed, edit ${_mappings_file} manually to replace bash with $shellpath." fi rm -f "${_mappings_file}".bak # delete backup file created by sed - else - printf "\n%s\n" "=> Shell changed to $shellname on nvim successfully!" fi + printf "%s\n\n" "=> Neovim shell will be ${shellpath:-${_CURRENT_SHELL}}" return 0 } - _setup_arguments() { # default variables to be used _CONFIG_PATH="${HOME}/.config/nvim" From f35aa3c604e2f35d4339f868b9365bf846deb644 Mon Sep 17 00:00:00 2001 From: Galen Rowell Date: Tue, 20 Jul 2021 20:18:10 +1000 Subject: [PATCH 4/4] automatically close a terminal buffer if it has exited/returned --- lua/utils.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/utils.lua b/lua/utils.lua index cf915ed..44bb800 100644 --- a/lua/utils.lua +++ b/lua/utils.lua @@ -5,6 +5,7 @@ M.hideStuff = function() vim.api.nvim_exec( [[ au TermOpen term://* setlocal nonumber laststatus=0 + au TermClose term://* bd! au BufEnter,BufWinEnter,WinEnter,CmdwinEnter * if bufname('%') == "NvimTree" | set laststatus=0 | else | set laststatus=2 | endif ]], false