feat(shell): add automatic bash configuration with modern tools
- commit
- df08da051da6b2d5716688bbc58f3bbd9820aafa
- author
- bnema · · 2025-10-20 21:07 UTC
- committer
- bnema · · 2025-10-20 20:44 UTC
- parent
- e694903
- signature
- unsigned
3 files · +160 -1
M install/helpers/download.sh +1 -1
| @@ -58,7 +58,7 @@ download_archup_files() { | |||
| 58 | 58 | ||
| 59 | 59 | # Post-install | |
| 60 | 60 | download_section "Downloading post-install scripts..." "post-install" \ | |
| 61 | - | all.sh boot-logo.sh plymouth.sh snapper.sh post-boot-setup.sh hooks.sh verify.sh unmount.sh | |
| 61 | + | all.sh boot-logo.sh plymouth.sh snapper.sh post-boot-setup.sh hooks.sh shell-config.sh verify.sh unmount.sh | |
| 62 | 62 | ||
| 63 | 63 | # Post-boot | |
| 64 | 64 | download_section "Downloading post-boot scripts..." "post-boot" \ | |
| @@ -58,7 +58,7 @@ download_archup_files() { | |||||
| 58 | 58 | ||||
| 59 | # Post-install | 59 | # Post-install | ||
| 60 | download_section "Downloading post-install scripts..." "post-install" \ | 60 | download_section "Downloading post-install scripts..." "post-install" \ | ||
| 61 | - | all.sh boot-logo.sh plymouth.sh snapper.sh post-boot-setup.sh hooks.sh verify.sh unmount.sh | 61 | + | all.sh boot-logo.sh plymouth.sh snapper.sh post-boot-setup.sh hooks.sh shell-config.sh verify.sh unmount.sh |
| 62 | 62 | ||||
| 63 | # Post-boot | 63 | # Post-boot | ||
| 64 | download_section "Downloading post-boot scripts..." "post-boot" \ | 64 | download_section "Downloading post-boot scripts..." "post-boot" \ | ||
M install/post-install/all.sh +1 -0
| @@ -6,5 +6,6 @@ source "$ARCHUP_INSTALL/post-install/plymouth.sh" | |||
| 6 | 6 | source "$ARCHUP_INSTALL/post-install/snapper.sh" | |
| 7 | 7 | source "$ARCHUP_INSTALL/post-install/post-boot-setup.sh" | |
| 8 | 8 | source "$ARCHUP_INSTALL/post-install/hooks.sh" | |
| 9 | + | source "$ARCHUP_INSTALL/post-install/shell-config.sh" | |
| 9 | 10 | source "$ARCHUP_INSTALL/post-install/verify.sh" | |
| 10 | 11 | # source "$ARCHUP_INSTALL/post-install/unmount.sh" # DISABLED FOR DEBUGGING | |
| @@ -6,5 +6,6 @@ source "$ARCHUP_INSTALL/post-install/plymouth.sh" | |||||
| 6 | source "$ARCHUP_INSTALL/post-install/snapper.sh" | 6 | source "$ARCHUP_INSTALL/post-install/snapper.sh" | ||
| 7 | source "$ARCHUP_INSTALL/post-install/post-boot-setup.sh" | 7 | source "$ARCHUP_INSTALL/post-install/post-boot-setup.sh" | ||
| 8 | source "$ARCHUP_INSTALL/post-install/hooks.sh" | 8 | source "$ARCHUP_INSTALL/post-install/hooks.sh" | ||
| 9 | + | source "$ARCHUP_INSTALL/post-install/shell-config.sh" | |||
| 9 | source "$ARCHUP_INSTALL/post-install/verify.sh" | 10 | source "$ARCHUP_INSTALL/post-install/verify.sh" | ||
| 10 | # source "$ARCHUP_INSTALL/post-install/unmount.sh" # DISABLED FOR DEBUGGING | 11 | # source "$ARCHUP_INSTALL/post-install/unmount.sh" # DISABLED FOR DEBUGGING | ||
A install/post-install/shell-config.sh +158 -0
| @@ -0,0 +1,158 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | # Configure bash shell with archup default structure | |
| 3 | + | ||
| 4 | + | # Get the username created during installation | |
| 5 | + | USERNAME=$(arch-chroot /mnt ls /home | head -1) | |
| 6 | + | ||
| 7 | + | if [[ -z "${USERNAME}" ]]; then | |
| 8 | + | echo "ERROR: Could not find user for shell configuration" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 9 | + | exit 1 | |
| 10 | + | fi | |
| 11 | + | ||
| 12 | + | USER_HOME="/mnt/home/$USERNAME" | |
| 13 | + | ARCHUP_DEFAULT="$USER_HOME/.local/share/archup/default/bash" | |
| 14 | + | ||
| 15 | + | echo "Configuring bash shell for $USERNAME..." >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 16 | + | ||
| 17 | + | # Create archup default directory structure | |
| 18 | + | mkdir -p "$ARCHUP_DEFAULT" | |
| 19 | + | ||
| 20 | + | # Create shell configuration (history, bash-completion, PATH) | |
| 21 | + | cat > "$ARCHUP_DEFAULT/shell" << 'SHELL_END' | |
| 22 | + | # History control | |
| 23 | + | shopt -s histappend | |
| 24 | + | HISTCONTROL=ignoreboth | |
| 25 | + | HISTSIZE=32768 | |
| 26 | + | HISTFILESIZE="${HISTSIZE}" | |
| 27 | + | ||
| 28 | + | # Bash completion | |
| 29 | + | if [[ ! -v BASH_COMPLETION_VERSINFO && -f /usr/share/bash-completion/bash_completion ]]; then | |
| 30 | + | source /usr/share/bash-completion/bash_completion | |
| 31 | + | fi | |
| 32 | + | ||
| 33 | + | # Set complete path | |
| 34 | + | export PATH="$HOME/.local/bin:$PATH" | |
| 35 | + | set +h | |
| 36 | + | SHELL_END | |
| 37 | + | ||
| 38 | + | # Create init configuration (starship, zoxide, fzf) | |
| 39 | + | cat > "$ARCHUP_DEFAULT/init" << 'INIT_END' | |
| 40 | + | # Starship prompt | |
| 41 | + | if command -v starship &> /dev/null; then | |
| 42 | + | eval "$(starship init bash)" | |
| 43 | + | fi | |
| 44 | + | ||
| 45 | + | # Zoxide (smarter cd) | |
| 46 | + | if command -v zoxide &> /dev/null; then | |
| 47 | + | eval "$(zoxide init bash)" | |
| 48 | + | fi | |
| 49 | + | ||
| 50 | + | # FZF fuzzy finder | |
| 51 | + | if command -v fzf &> /dev/null; then | |
| 52 | + | eval "$(fzf --bash)" | |
| 53 | + | fi | |
| 54 | + | INIT_END | |
| 55 | + | ||
| 56 | + | # Create aliases configuration | |
| 57 | + | cat > "$ARCHUP_DEFAULT/aliases" << 'ALIASES_END' | |
| 58 | + | # Eza aliases (modern ls replacement) | |
| 59 | + | if command -v eza &> /dev/null; then | |
| 60 | + | alias ls='eza -lh --group-directories-first --icons=auto' | |
| 61 | + | alias lsa='ls -a' | |
| 62 | + | alias lt='eza --tree --level=2 --long --icons --git' | |
| 63 | + | alias lta='lt -a' | |
| 64 | + | alias ll='eza -l --icons=auto' | |
| 65 | + | alias la='eza -la --icons=auto' | |
| 66 | + | fi | |
| 67 | + | ||
| 68 | + | # Bat + FZF integration | |
| 69 | + | if command -v bat &> /dev/null && command -v fzf &> /dev/null; then | |
| 70 | + | alias ff="fzf --preview 'bat --style=numbers --color=always {}'" | |
| 71 | + | fi | |
| 72 | + | ||
| 73 | + | # Bat aliases | |
| 74 | + | if command -v bat &> /dev/null; then | |
| 75 | + | alias cat='bat --paging=never' | |
| 76 | + | alias less='bat' | |
| 77 | + | fi | |
| 78 | + | ||
| 79 | + | # Directories | |
| 80 | + | alias ..='cd ..' | |
| 81 | + | alias ...='cd ../..' | |
| 82 | + | alias ....='cd ../../..' | |
| 83 | + | ||
| 84 | + | # Git shortcuts | |
| 85 | + | alias g='git' | |
| 86 | + | alias gs='git status' | |
| 87 | + | alias ga='git add' | |
| 88 | + | alias gc='git commit' | |
| 89 | + | alias gp='git push' | |
| 90 | + | alias gl='git log --oneline --graph --decorate' | |
| 91 | + | ALIASES_END | |
| 92 | + | ||
| 93 | + | # Create envs configuration (environment variables) | |
| 94 | + | cat > "$ARCHUP_DEFAULT/envs" << 'ENVS_END' | |
| 95 | + | # Bat configuration | |
| 96 | + | if command -v bat &> /dev/null; then | |
| 97 | + | export BAT_THEME="TwoDark" | |
| 98 | + | fi | |
| 99 | + | ||
| 100 | + | # FZF default options | |
| 101 | + | if command -v fzf &> /dev/null && command -v bat &> /dev/null; then | |
| 102 | + | export FZF_DEFAULT_OPTS="--preview 'bat --color=always --style=numbers --line-range=:500 {}' --preview-window right:60%:wrap" | |
| 103 | + | fi | |
| 104 | + | ENVS_END | |
| 105 | + | ||
| 106 | + | # Create functions configuration | |
| 107 | + | cat > "$ARCHUP_DEFAULT/functions" << 'FUNCTIONS_END' | |
| 108 | + | # Zoxide cd wrapper | |
| 109 | + | if command -v zoxide &> /dev/null; then | |
| 110 | + | zd() { | |
| 111 | + | if [ $# -eq 0 ]; then | |
| 112 | + | builtin cd ~ && return | |
| 113 | + | elif [ -d "$1" ]; then | |
| 114 | + | builtin cd "$1" | |
| 115 | + | else | |
| 116 | + | z "$@" || echo "Error: Directory not found" | |
| 117 | + | fi | |
| 118 | + | } | |
| 119 | + | alias cd="zd" | |
| 120 | + | fi | |
| 121 | + | FUNCTIONS_END | |
| 122 | + | ||
| 123 | + | # Create rc file that sources everything | |
| 124 | + | cat > "$ARCHUP_DEFAULT/rc" << 'RC_END' | |
| 125 | + | source ~/.local/share/archup/default/bash/shell | |
| 126 | + | source ~/.local/share/archup/default/bash/init | |
| 127 | + | source ~/.local/share/archup/default/bash/aliases | |
| 128 | + | source ~/.local/share/archup/default/bash/envs | |
| 129 | + | source ~/.local/share/archup/default/bash/functions | |
| 130 | + | RC_END | |
| 131 | + | ||
| 132 | + | # Create user .bashrc that sources archup defaults | |
| 133 | + | cat > "$USER_HOME/.bashrc" << 'BASHRC_END' | |
| 134 | + | # All the default ArchUp aliases and functions | |
| 135 | + | # (don't mess with these directly, just override them here!) | |
| 136 | + | source ~/.local/share/archup/default/bash/rc | |
| 137 | + | ||
| 138 | + | # Add your own exports, aliases, and functions here. | |
| 139 | + | # | |
| 140 | + | # Make an alias for invoking commands you use constantly | |
| 141 | + | # alias p='python' | |
| 142 | + | BASHRC_END | |
| 143 | + | ||
| 144 | + | # Configure git to use delta for diffs | |
| 145 | + | arch-chroot /mnt su - "$USERNAME" -c "git config --global core.pager delta" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 146 | + | arch-chroot /mnt su - "$USERNAME" -c "git config --global interactive.diffFilter 'delta --color-only'" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 147 | + | arch-chroot /mnt su - "$USERNAME" -c "git config --global delta.navigate true" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 148 | + | arch-chroot /mnt su - "$USERNAME" -c "git config --global delta.light false" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 149 | + | arch-chroot /mnt su - "$USERNAME" -c "git config --global delta.side-by-side true" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 150 | + | arch-chroot /mnt su - "$USERNAME" -c "git config --global merge.conflictstyle diff3" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 151 | + | arch-chroot /mnt su - "$USERNAME" -c "git config --global diff.colorMoved default" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 152 | + | ||
| 153 | + | # Set ownership | |
| 154 | + | arch-chroot /mnt chown -R "$USERNAME:$USERNAME" "$USER_HOME/.local" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 155 | + | arch-chroot /mnt chown "$USERNAME:$USERNAME" "$USER_HOME/.bashrc" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 156 | + | ||
| 157 | + | gum style --foreground 2 --padding "0 0 0 $PADDING_LEFT" "[OK] Shell configured" | |
| 158 | + | echo "Configured shell for user: $USERNAME" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| @@ -0,0 +1,158 @@ | |||||
| 1 | + | #!/bin/bash | |||
| 2 | + | # Configure bash shell with archup default structure | |||
| 3 | + | ||||
| 4 | + | # Get the username created during installation | |||
| 5 | + | USERNAME=$(arch-chroot /mnt ls /home | head -1) | |||
| 6 | + | ||||
| 7 | + | if [[ -z "${USERNAME}" ]]; then | |||
| 8 | + | echo "ERROR: Could not find user for shell configuration" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 9 | + | exit 1 | |||
| 10 | + | fi | |||
| 11 | + | ||||
| 12 | + | USER_HOME="/mnt/home/$USERNAME" | |||
| 13 | + | ARCHUP_DEFAULT="$USER_HOME/.local/share/archup/default/bash" | |||
| 14 | + | ||||
| 15 | + | echo "Configuring bash shell for $USERNAME..." >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 16 | + | ||||
| 17 | + | # Create archup default directory structure | |||
| 18 | + | mkdir -p "$ARCHUP_DEFAULT" | |||
| 19 | + | ||||
| 20 | + | # Create shell configuration (history, bash-completion, PATH) | |||
| 21 | + | cat > "$ARCHUP_DEFAULT/shell" << 'SHELL_END' | |||
| 22 | + | # History control | |||
| 23 | + | shopt -s histappend | |||
| 24 | + | HISTCONTROL=ignoreboth | |||
| 25 | + | HISTSIZE=32768 | |||
| 26 | + | HISTFILESIZE="${HISTSIZE}" | |||
| 27 | + | ||||
| 28 | + | # Bash completion | |||
| 29 | + | if [[ ! -v BASH_COMPLETION_VERSINFO && -f /usr/share/bash-completion/bash_completion ]]; then | |||
| 30 | + | source /usr/share/bash-completion/bash_completion | |||
| 31 | + | fi | |||
| 32 | + | ||||
| 33 | + | # Set complete path | |||
| 34 | + | export PATH="$HOME/.local/bin:$PATH" | |||
| 35 | + | set +h | |||
| 36 | + | SHELL_END | |||
| 37 | + | ||||
| 38 | + | # Create init configuration (starship, zoxide, fzf) | |||
| 39 | + | cat > "$ARCHUP_DEFAULT/init" << 'INIT_END' | |||
| 40 | + | # Starship prompt | |||
| 41 | + | if command -v starship &> /dev/null; then | |||
| 42 | + | eval "$(starship init bash)" | |||
| 43 | + | fi | |||
| 44 | + | ||||
| 45 | + | # Zoxide (smarter cd) | |||
| 46 | + | if command -v zoxide &> /dev/null; then | |||
| 47 | + | eval "$(zoxide init bash)" | |||
| 48 | + | fi | |||
| 49 | + | ||||
| 50 | + | # FZF fuzzy finder | |||
| 51 | + | if command -v fzf &> /dev/null; then | |||
| 52 | + | eval "$(fzf --bash)" | |||
| 53 | + | fi | |||
| 54 | + | INIT_END | |||
| 55 | + | ||||
| 56 | + | # Create aliases configuration | |||
| 57 | + | cat > "$ARCHUP_DEFAULT/aliases" << 'ALIASES_END' | |||
| 58 | + | # Eza aliases (modern ls replacement) | |||
| 59 | + | if command -v eza &> /dev/null; then | |||
| 60 | + | alias ls='eza -lh --group-directories-first --icons=auto' | |||
| 61 | + | alias lsa='ls -a' | |||
| 62 | + | alias lt='eza --tree --level=2 --long --icons --git' | |||
| 63 | + | alias lta='lt -a' | |||
| 64 | + | alias ll='eza -l --icons=auto' | |||
| 65 | + | alias la='eza -la --icons=auto' | |||
| 66 | + | fi | |||
| 67 | + | ||||
| 68 | + | # Bat + FZF integration | |||
| 69 | + | if command -v bat &> /dev/null && command -v fzf &> /dev/null; then | |||
| 70 | + | alias ff="fzf --preview 'bat --style=numbers --color=always {}'" | |||
| 71 | + | fi | |||
| 72 | + | ||||
| 73 | + | # Bat aliases | |||
| 74 | + | if command -v bat &> /dev/null; then | |||
| 75 | + | alias cat='bat --paging=never' | |||
| 76 | + | alias less='bat' | |||
| 77 | + | fi | |||
| 78 | + | ||||
| 79 | + | # Directories | |||
| 80 | + | alias ..='cd ..' | |||
| 81 | + | alias ...='cd ../..' | |||
| 82 | + | alias ....='cd ../../..' | |||
| 83 | + | ||||
| 84 | + | # Git shortcuts | |||
| 85 | + | alias g='git' | |||
| 86 | + | alias gs='git status' | |||
| 87 | + | alias ga='git add' | |||
| 88 | + | alias gc='git commit' | |||
| 89 | + | alias gp='git push' | |||
| 90 | + | alias gl='git log --oneline --graph --decorate' | |||
| 91 | + | ALIASES_END | |||
| 92 | + | ||||
| 93 | + | # Create envs configuration (environment variables) | |||
| 94 | + | cat > "$ARCHUP_DEFAULT/envs" << 'ENVS_END' | |||
| 95 | + | # Bat configuration | |||
| 96 | + | if command -v bat &> /dev/null; then | |||
| 97 | + | export BAT_THEME="TwoDark" | |||
| 98 | + | fi | |||
| 99 | + | ||||
| 100 | + | # FZF default options | |||
| 101 | + | if command -v fzf &> /dev/null && command -v bat &> /dev/null; then | |||
| 102 | + | export FZF_DEFAULT_OPTS="--preview 'bat --color=always --style=numbers --line-range=:500 {}' --preview-window right:60%:wrap" | |||
| 103 | + | fi | |||
| 104 | + | ENVS_END | |||
| 105 | + | ||||
| 106 | + | # Create functions configuration | |||
| 107 | + | cat > "$ARCHUP_DEFAULT/functions" << 'FUNCTIONS_END' | |||
| 108 | + | # Zoxide cd wrapper | |||
| 109 | + | if command -v zoxide &> /dev/null; then | |||
| 110 | + | zd() { | |||
| 111 | + | if [ $# -eq 0 ]; then | |||
| 112 | + | builtin cd ~ && return | |||
| 113 | + | elif [ -d "$1" ]; then | |||
| 114 | + | builtin cd "$1" | |||
| 115 | + | else | |||
| 116 | + | z "$@" || echo "Error: Directory not found" | |||
| 117 | + | fi | |||
| 118 | + | } | |||
| 119 | + | alias cd="zd" | |||
| 120 | + | fi | |||
| 121 | + | FUNCTIONS_END | |||
| 122 | + | ||||
| 123 | + | # Create rc file that sources everything | |||
| 124 | + | cat > "$ARCHUP_DEFAULT/rc" << 'RC_END' | |||
| 125 | + | source ~/.local/share/archup/default/bash/shell | |||
| 126 | + | source ~/.local/share/archup/default/bash/init | |||
| 127 | + | source ~/.local/share/archup/default/bash/aliases | |||
| 128 | + | source ~/.local/share/archup/default/bash/envs | |||
| 129 | + | source ~/.local/share/archup/default/bash/functions | |||
| 130 | + | RC_END | |||
| 131 | + | ||||
| 132 | + | # Create user .bashrc that sources archup defaults | |||
| 133 | + | cat > "$USER_HOME/.bashrc" << 'BASHRC_END' | |||
| 134 | + | # All the default ArchUp aliases and functions | |||
| 135 | + | # (don't mess with these directly, just override them here!) | |||
| 136 | + | source ~/.local/share/archup/default/bash/rc | |||
| 137 | + | ||||
| 138 | + | # Add your own exports, aliases, and functions here. | |||
| 139 | + | # | |||
| 140 | + | # Make an alias for invoking commands you use constantly | |||
| 141 | + | # alias p='python' | |||
| 142 | + | BASHRC_END | |||
| 143 | + | ||||
| 144 | + | # Configure git to use delta for diffs | |||
| 145 | + | arch-chroot /mnt su - "$USERNAME" -c "git config --global core.pager delta" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 146 | + | arch-chroot /mnt su - "$USERNAME" -c "git config --global interactive.diffFilter 'delta --color-only'" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 147 | + | arch-chroot /mnt su - "$USERNAME" -c "git config --global delta.navigate true" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 148 | + | arch-chroot /mnt su - "$USERNAME" -c "git config --global delta.light false" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 149 | + | arch-chroot /mnt su - "$USERNAME" -c "git config --global delta.side-by-side true" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 150 | + | arch-chroot /mnt su - "$USERNAME" -c "git config --global merge.conflictstyle diff3" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 151 | + | arch-chroot /mnt su - "$USERNAME" -c "git config --global diff.colorMoved default" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 152 | + | ||||
| 153 | + | # Set ownership | |||
| 154 | + | arch-chroot /mnt chown -R "$USERNAME:$USERNAME" "$USER_HOME/.local" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 155 | + | arch-chroot /mnt chown "$USERNAME:$USERNAME" "$USER_HOME/.bashrc" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |||
| 156 | + | ||||
| 157 | + | gum style --foreground 2 --padding "0 0 0 $PADDING_LEFT" "[OK] Shell configured" | |||
| 158 | + | echo "Configured shell for user: $USERNAME" >> "$ARCHUP_INSTALL_LOG_FILE" | |||