Merge pull request #167 from G-Rowell/dev-terminalAndScript
Fix buffers/tab terminal issues, improve terminal install scripting
This commit is contained in:
commit
f72c36f4ab
3 changed files with 18 additions and 16 deletions
25
install.sh
25
install.sh
|
@ -71,27 +71,28 @@ _setup_terminal_shell() {
|
||||||
_mappings_file="${_CONFIG_PATH}/lua/mappings.lua"
|
_mappings_file="${_CONFIG_PATH}/lua/mappings.lua"
|
||||||
# only ask for shellname if running in terminal
|
# only ask for shellname if running in terminal
|
||||||
if [ -t 1 ]; then
|
if [ -t 1 ]; then
|
||||||
printf "%s\n: " "Which shell do you want to use ? [ Enter nothing for current shell ( $_CURRENT_SHELL ) ]"
|
printf "\n%s\n" "Which shell do you want to use? (Eg. 2)"
|
||||||
read -r shellname
|
printf "\t%s\n" "[ Enter nothing for current shell ( $_CURRENT_SHELL ) ]"
|
||||||
|
grep '^/bin/' '/etc/shells' | nl
|
||||||
|
read -r shellNUM
|
||||||
fi
|
fi
|
||||||
shellname="${shellname:-${_CURRENT_SHELL}}"
|
|
||||||
printf "%s\n" "$shellname"
|
|
||||||
|
|
||||||
# don't try to do any changes if given shellname is same as bash
|
# don't try to do any changes user wants their default shell in nvim
|
||||||
if ! [ bash = "$shellname" ]; then
|
if [ ! -z "$shellNUM" ]; then
|
||||||
|
shellpath=$(grep '^/bin/' '/etc/shells' | sed -n "$shellNUM p")
|
||||||
# Reference: https://stackoverflow.com/a/4247319
|
# Reference: https://stackoverflow.com/a/4247319
|
||||||
if "${_SED}" -i'.bak' -e "s/bash/$shellname/g" "${_mappings_file}"; then
|
# \( & \) will use regex brackets (for later reference with \1)
|
||||||
printf "\n%s\n" "=> Shell changed to $shellname on nvim successfully!"
|
# ( & ) 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
|
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
|
fi
|
||||||
rm -f "${_mappings_file}".bak # delete backup file created by sed
|
rm -f "${_mappings_file}".bak # delete backup file created by sed
|
||||||
else
|
|
||||||
printf "\n%s\n" "=> Shell changed to $shellname on nvim successfully!"
|
|
||||||
fi
|
fi
|
||||||
|
printf "%s\n\n" "=> Neovim shell will be ${shellpath:-${_CURRENT_SHELL}}"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
_setup_arguments() {
|
_setup_arguments() {
|
||||||
# default variables to be used
|
# default variables to be used
|
||||||
_CONFIG_PATH="${HOME}/.config/nvim"
|
_CONFIG_PATH="${HOME}/.config/nvim"
|
||||||
|
|
|
@ -27,9 +27,9 @@ vim.api.nvim_set_keymap("t", "jk", "<esc>", {})
|
||||||
map("v", "p", '"_dP', opt)
|
map("v", "p", '"_dP', opt)
|
||||||
|
|
||||||
-- OPEN TERMINALS --
|
-- OPEN TERMINALS --
|
||||||
map("n", "<C-l>", [[<Cmd>vnew term://bash <CR>]], opt) -- term over right
|
map("n", "<C-l>", [[<Cmd> vnew +terminal | setlocal nobuflisted <CR>]], opt) -- term over right
|
||||||
map("n", "<C-x>", [[<Cmd> split term://bash | resize 10 <CR>]], opt) -- term bottom
|
map("n", "<C-x>", [[<Cmd> 10new +terminal | setlocal nobuflisted <CR>]], opt) -- term bottom
|
||||||
map("n", "<C-t>t", [[<Cmd> tabnew | term <CR>]], opt) -- term newtab
|
map("n", "<C-t>t", [[<Cmd> terminal <CR>]], opt) -- term buffer
|
||||||
|
|
||||||
-- copy whole file content
|
-- copy whole file content
|
||||||
map("n", "<C-a>", [[ <Cmd> %y+<CR>]], opt)
|
map("n", "<C-a>", [[ <Cmd> %y+<CR>]], opt)
|
||||||
|
@ -133,7 +133,7 @@ map("n", "<Leader>fh", [[<Cmd>Telescope help_tags<CR>]], opt)
|
||||||
map("n", "<Leader>fo", [[<Cmd>Telescope oldfiles<CR>]], opt)
|
map("n", "<Leader>fo", [[<Cmd>Telescope oldfiles<CR>]], opt)
|
||||||
|
|
||||||
-- bufferline tab stuff
|
-- bufferline tab stuff
|
||||||
map("n", "<S-t>", ":tabnew<CR>", opt) -- new tab
|
map("n", "<S-t>", ":enew<CR>", opt) -- new tab
|
||||||
map("n", "<S-x>", ":bd!<CR>", opt) -- close tab
|
map("n", "<S-x>", ":bd!<CR>", opt) -- close tab
|
||||||
|
|
||||||
-- move between tabs
|
-- move between tabs
|
||||||
|
|
|
@ -5,6 +5,7 @@ M.hideStuff = function()
|
||||||
vim.api.nvim_exec(
|
vim.api.nvim_exec(
|
||||||
[[
|
[[
|
||||||
au TermOpen term://* setlocal nonumber laststatus=0
|
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
|
au BufEnter,BufWinEnter,WinEnter,CmdwinEnter * if bufname('%') == "NvimTree" | set laststatus=0 | else | set laststatus=2 | endif
|
||||||
]],
|
]],
|
||||||
false
|
false
|
||||||
|
|
Loading…
Reference in a new issue