refactor: use drop-ins for aliases and path management
This commit is contained in:
@@ -77,23 +77,15 @@ configure_shell() {
|
||||
# Add ~/.local/bin to PATH for the current process
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
|
||||
local config_file="$HOME/.bashrc"
|
||||
if [ -f "$config_file" ]; then
|
||||
# Ensure ~/.local/bin is in PATH for this file if not already present
|
||||
if ! grep -q '\.local/bin' "$config_file" 2>/dev/null; then
|
||||
log_info "Adding ~/.local/bin to PATH in $config_file..."
|
||||
local path_content='export PATH="$HOME/.local/bin:$PATH"'
|
||||
inject_block "$config_file" "local-bin path" "$path_content"
|
||||
fi
|
||||
# Clean up legacy in-place configuration blocks
|
||||
IFS=' ' read -ra target_files <<< "$(get_shell_configs)"
|
||||
for config_file in "${target_files[@]}"; do
|
||||
remove_block "$config_file" "local-bin path"
|
||||
remove_block "$config_file" "starship init"
|
||||
done
|
||||
|
||||
log_info "Adding starship initialization to $config_file..."
|
||||
local content='eval "$(starship init bash)"'
|
||||
|
||||
inject_block "$config_file" "starship init" "$content"
|
||||
|
||||
# Source to apply changes in the current context
|
||||
. "$config_file" 2>/dev/null || true
|
||||
fi
|
||||
write_env_snippet "local-bin" 'export PATH="$HOME/.local/bin:$PATH"'
|
||||
write_env_snippet "starship" 'eval "$(starship init bash)"'
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
Reference in New Issue
Block a user