Files
dotfiles/config/shell/.bashrc
T
2026-07-27 02:53:24 +02:00

97 lines
2.3 KiB
Bash

#!/hint/bash
[[ $- == *i* ]] || return
if type fish &>/dev/null; then
alias f="exec fish"
if [[ ${UY_ENABLE_FISH_AUTO_LOGIN:-0} == 1 ]] &&
[[ $(ps --no-header --pid=$PPID --format=comm) != "fish" && -z ${BASH_EXECUTION_STRING} && ${SHLVL} == 1 ]]; then
shopt -q login_shell && LOGIN_OPTION='--login' || LOGIN_OPTION=''
exec fish $LOGIN_OPTION
fi
fi
HISTCONTROL=ignoreboth
HISTSIZE=16384
HISTFILESIZE=32768
shopt -s histappend checkwinsize
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias ll='ls -l' la='ls -A' l='ls -CF'
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
for app in helix nvim vim vi nano; do
if type "$app" &>/dev/null; then
EDITOR="$app"
VISUAL="$app"
break
fi
done
export EDITOR VISUAL
if type helix &>/dev/null && ! type hx &>/dev/null; then
alias hx="helix"
fi
if type gpg &>/dev/null; then
GPG_TTY=$(tty)
export GPG_TTY
fi
if type fnm &>/dev/null; then
eval "$(fnm env --shell bash --use-on-cd)"
fi
# $uy_ssh_keys should be set in a device-specific file or left empty for defaults
if [[ ${UY_ENABLE_GPG_AGENT_SSH:-0} == 1 ]] &&
[ -x "$HOME/.local/scripts/gpg-init" ] && type gpgconf &>/dev/null; then
: # GPG agent handles SSH — nothing to do
elif [[ ${UY_USING_SSH_AGENT:-0} == 1 ]]; then
function sshs() {
if ! ssh-add -l &>/dev/null; then
if [ ${#uy_ssh_keys[@]} -gt 0 ]; then
ssh-add "${uy_ssh_keys[@]}"
else
ssh-add
fi
fi
ssh "$@"
}
fi
if type starship &>/dev/null; then
eval "$(starship init bash)"
fi
if type fzf &>/dev/null; then
source <(fzf --bash)
# use fd if available (search cwd only, skip vcs/cache junk)
if type fd &>/dev/null; then
export FD_CMD="fd"
elif type fdfind &>/dev/null; then
export FD_CMD="fdfind"
fi
if [[ -n "$FD_CMD" ]]; then
export FZF_DEFAULT_COMMAND="$FD_CMD --type f --hidden --exclude .git"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="$FD_CMD --type d --hidden --exclude .git"
fi
# C-y to copy fzf's output
if type wl-copy &>/dev/null; then
export FZF_DEFAULT_OPTS="--bind \"ctrl-y:execute-silent(echo -n {+} | wl-copy)+abort\""
fi
fi