In .bashrc, check nvim/fish installed
x1phosura x1phosura@x1phosura.zone
Wed, 30 Oct 2024 23:10:31 -0700
1 files changed,
19 insertions(+),
9 deletions(-)
jump to
M
.bashrc
→
.bashrc
@@ -11,12 +11,6 @@
# If not running interactively, don't do anything [[ $- != *i* ]] && return -############################################################################ - # SWITCH TO FISH SHELL # - # TODO detect if fish installed - exec fish -############################################################################ - # source global bashrc settings (turned off by default, uncomment otherwise) # [ -f /etc/bashrc ] && source /etc/bashrc@@ -39,6 +33,11 @@ *) operating_system='other' ;;
esac [ -f /etc/hostname ] && hostname="$(cat /etc/hostname)" + +__is_cmd_installed() { + cmd="$1" + command -v "$cmd" &> /dev/null ; return $? +} # set PATH to something tolerable # NOTE: in Arch, everything's already in /usr/bin, /usr/sbin anyway@@ -75,12 +74,14 @@ if [[ "$operating_system" = "macOS" || "$operating_system" = "BSD" ]] ; then
export CLICOLOR=1 fi + + # use 'nvim' if it exists on system -if [ command -v nvim &> /dev/null ]; then - export EDITOR='vim' -else +if __is_cmd_installed nvim ; then export EDITOR='nvim' alias vim='nvim ' +else + export EDITOR='vim' fi # make less more friendly for non-text input files, see lesspipe(1)@@ -408,6 +409,15 @@ complete -cf sudo # so sudo actually has tab autocompletion
bind 'set completion-ignore-case on' # case-insensitive tab autocompletion [ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" # if not in .bash_profile + +if __is_cmd_installed fish ; then +############################################################################ + # SWITCH TO FISH SHELL # + # TODO detect if fish installed + exec fish + # Note: this invokes fish with all my bash-configured settings # +############################################################################ +fi # uncomment below to profile bashrc startup in /tmp/bashstart.SEC.NANOSEC #set -x