update shell config

This commit is contained in:
2026-03-15 08:51:55 +01:00
parent e0b49d5520
commit 16d2d6faa6
10 changed files with 52 additions and 71 deletions
+33 -9
View File
@@ -34,8 +34,7 @@ export XDG_CACHE_HOME="$HOME/.cache"
# Better than nothing
if [[ -z "$LANG" ]]; then
LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
export LANG LC_ALL
export LANG
fi
# Paths
@@ -48,21 +47,21 @@ export PATH
# fnm
if type fnm &>/dev/null; then
eval $(fnm env --shell bash)
eval "$(fnm env --shell bash)"
fi
# export ENABLE_GPG_AGENT_SSH=1 in .profile to enable GPG agent for SSH
if [ -x "$HOME/.local/scripts/gpg-init" ] && \
[ -n "$ENABLE_GPG_AGENT_SSH" ] && [ "$ENABLE_GPG_AGENT_SSH" != "0" ] && \
[ -n "$ENABLE_GPG_AGENT_SSH" ] && [ "$ENABLE_GPG_AGENT_SSH" = "1" ] && \
type gpgconf &>/dev/null; then
# GPG agent for SSH
eval "$($HOME/.local/scripts/gpg-init 2>/dev/null)" >/dev/null 2>&1
eval "$($HOME/.local/scripts/gpg-init 2>/dev/null)" &>/dev/null
elif [ -x "$HOME/.local/scripts/ssh-init" ] && type ssh-agent &>/dev/null; then
# SSH with cross-session ssh-agent
eval "$($HOME/.local/scripts/ssh-init 2>/dev/null)" >/dev/null 2>&1
eval "$($HOME/.local/scripts/ssh-init 2>/dev/null)" &>/dev/null
fi
# Triggered in SSH sessions
# Triggered in interactive shells (e.g. ssh)
if [[ $- == *i* ]]; then
# Set EDITOR and VISUAL, mainly for sudoedit
for app in nvim helix vim vi nano; do
@@ -74,9 +73,34 @@ if [[ $- == *i* ]]; then
done
export EDITOR VISUAL
# Create shortcut alias for helix
if type helix &>/dev/null && ! type hx &>/dev/null; then
alias hx="helix"
fi
# For gpg
GPG_TTY=$(tty)
export GPG_TTY
if type gpgconf &>/dev/null; then
GPG_TTY=$(tty)
export GPG_TTY
fi
if [ -x "$HOME/.local/scripts/gpg-init" ] && \
[ -n "$ENABLE_GPG_AGENT_SSH" ] && [ "$ENABLE_GPG_AGENT_SSH" = "1" ] && \
type gpgconf &>/dev/null; then
true
elif [ -x "$HOME/.local/scripts/ssh-init" ] && type ssh-add &>/dev/null; then
function sshs() {
# test if keys are added to ssh-agent
if ! ssh-add -l &>/dev/null; then
if [ -n "$ssh_keys" ]; then
ssh-add "${ssh_keys[@]}"
else
ssh-add
fi
fi
ssh "$@"
}
fi
# Shortcut alias for launching fish
if type fish &>/dev/null && ! type f &>/dev/null; then
+1 -11
View File
@@ -1,9 +1,4 @@
# PATH
fish_add_path $HOME/go/bin
fish_add_path $HOME/.cargo/bin
fish_add_path $HOME/.local/scripts
fish_add_path $HOME/.local/bin
fish_add_path $HOME/.local/share/fnm
# PATH is managed by .bash_profile
# man
if type -q bat
@@ -28,11 +23,6 @@ end
# gpg
set -x -g GPG_TTY (tty)
# fnm
if type -q fnm
eval (fnm env --shell fish)
end
# done
set -U __done_min_cmd_duration 10000
set -U __done_notification_urgency_level low
@@ -1,22 +0,0 @@
if test -n "$XDG_CURRENT_DESKTOP"; and test "$XDG_CURRENT_DESKTOP" = "niri"
set -l env_config "$HOME/.config/niri/config/envs.kdl"
if test -f "$env_config"
while read -la line
# Remove comments
set line (string replace -r '//.*' '' -- "$line")
# Trim whitespace
set line (string trim -- "$line")
# Skip "environment" block lines
if test -z "$line"; or string match -q "environment*" -- "$line"; or test "$line" = "}"
continue
end
# Match lines like: VARIABLE "value" where VARIABLE is alphanumeric/underscore
set -l matches (string match -r '^([0-9A-Za-z_]+)\s+"(.*)"$' -- "$line")
# If have a matches, set the environment variable
if test (count $matches) -eq 3
set -xg $matches[2] $matches[3]
end
end < "$env_config"
end
end
@@ -1,21 +0,0 @@
# ssh with encrypted private keys
# $ssh_keys should be set in advance or left empty to use the default keys
if set -q ENABLE_GPG_AGENT_SSH; and test $ENABLE_GPG_AGENT_SSH != "0";\
and type -q gpg-init; and type -q gpgconf
# GPG agent for SSH
bass $(gpg-init) > /dev/null 2>&1
else if type -q ssh-init; and type -q ssh-add
# SSH with cross-session ssh-agent
bass $(ssh-init) > /dev/null 2>&1
# avoid entering passphrase every time
function sshs
# test if keys are added to ssh-agent
if not ssh-add -l > /dev/null 2>&1
ssh-add $ssh_keys
end
ssh $argv
end
end