Update bash editor configuration

master
Hektor Misplon 2024-09-29 11:36:20 +02:00
parent 78fafd18ee
commit 6cf696e1f6
Signed by: hektor
GPG Key ID: 5151AF79E723F21C
3 changed files with 23 additions and 7 deletions

View File

@ -8,7 +8,7 @@ alias al-=unalias
# Edit configuration files # Edit configuration files
alias eba="nvim ~/.bashrc" alias eba="nvim ~/.bashrc"
alias eal="nvim ~/.bash_aliasrc" alias eal="nvim ~/.bash_aliasrc"
alias ev="nvim ~/.vimrc" alias ev="edit_editor_config"
# Navigation # Navigation
alias ..="cd .." alias ..="cd .."

10
.bashrc
View File

@ -4,6 +4,10 @@
source /etc/os-release source /etc/os-release
# Functions {{{
[ -f "$HOME/.bashrc.d/editor" ] && source "$HOME/.bashrc.d/editor"
# }}}
# Aliases {{{ # Aliases {{{
# Load aliases dynamically # Load aliases dynamically
[ -f "$HOME/.bash_aliases/all" ] && source "$HOME/.bash_aliases/all" [ -f "$HOME/.bash_aliases/all" ] && source "$HOME/.bash_aliases/all"
@ -53,12 +57,6 @@ export MANWIDTH=80
export PAGER=nvimpager export PAGER=nvimpager
# }}} # }}}
# Editor {{{
# Set vim as default editor
export EDITOR=nvim
export SUDO_EDITOR=nvim
# }}}
# Nvm # Nvm
export PATH=~/.nvm/versions/node/v14.16.0/bin:$PATH export PATH=~/.nvm/versions/node/v14.16.0/bin:$PATH
export NVM_DIR="$HOME/.nvm" export NVM_DIR="$HOME/.nvm"

18
.bashrc.d/editor Normal file
View File

@ -0,0 +1,18 @@
# vim: set ft=bash :
# Set NeoVim as default editor
export EDITOR=nvim
export SUDO_EDITOR="$EDITOR"
declare -A -r EDITOR_CONFIGS=(
["nvim"]="$HOME/.config/nvim/init.lua"
["vim"]="$HOME/.vimrc"
)
edit_editor_config() {
for editor in "${!EDITOR_CONFIGS[@]}"; do
if [ "$EDITOR" = "$editor" ]; then
$EDITOR "${EDITOR_CONFIGS[$editor]}"
fi
done
}