From 42656cc5a63408550cf54d41bc7adbb04224dfc7 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Tue, 10 Feb 2026 16:30:24 +0700 Subject: [PATCH] Add bashrc and bash-completion --- config/aarch64/ci.toml | 1 + config/i586/ci.toml | 1 + config/riscv64gc/ci.toml | 1 + config/x86_64/ci.toml | 1 + recipes/shells/bash/etc/bash.bashrc | 39 ++++++++ recipes/shells/bash/etc/profile | 27 ++++++ recipes/shells/bash/etc/skel/.bashrc | 99 ++++++++++++++++++++ recipes/shells/bash/etc/skel/.profile | 25 +++++ recipes/shells/bash/recipe.toml | 3 +- recipes/terminal/bash-completion/recipe.toml | 14 +++ 10 files changed, 210 insertions(+), 1 deletion(-) create mode 100644 recipes/shells/bash/etc/bash.bashrc create mode 100644 recipes/shells/bash/etc/profile create mode 100644 recipes/shells/bash/etc/skel/.bashrc create mode 100644 recipes/shells/bash/etc/skel/.profile create mode 100644 recipes/terminal/bash-completion/recipe.toml diff --git a/config/aarch64/ci.toml b/config/aarch64/ci.toml index bdaca67b..7b66b1df 100644 --- a/config/aarch64/ci.toml +++ b/config/aarch64/ci.toml @@ -25,6 +25,7 @@ acid = {} base = {} base-initfs = {} bash = {} +bash-completion = {} bootloader = {} bottom = {} ca-certificates = {} diff --git a/config/i586/ci.toml b/config/i586/ci.toml index 2fe46485..dbee8306 100644 --- a/config/i586/ci.toml +++ b/config/i586/ci.toml @@ -25,6 +25,7 @@ acid = {} base = {} base-initfs = {} bash = {} +bash-completion = {} bootloader = {} bottom = {} ca-certificates = {} diff --git a/config/riscv64gc/ci.toml b/config/riscv64gc/ci.toml index 5da2a641..0d203be9 100644 --- a/config/riscv64gc/ci.toml +++ b/config/riscv64gc/ci.toml @@ -25,6 +25,7 @@ acid = {} base = {} base-initfs = {} bash = {} +bash-completion = {} bootloader = {} bottom = {} ca-certificates = {} diff --git a/config/x86_64/ci.toml b/config/x86_64/ci.toml index 86db36fa..92f055c0 100644 --- a/config/x86_64/ci.toml +++ b/config/x86_64/ci.toml @@ -30,6 +30,7 @@ automake = {} base = {} base-initfs = {} bash = {} +bash-completion = {} binutils = {} bootloader = {} bottom = {} diff --git a/recipes/shells/bash/etc/bash.bashrc b/recipes/shells/bash/etc/bash.bashrc new file mode 100644 index 00000000..0f84bea4 --- /dev/null +++ b/recipes/shells/bash/etc/bash.bashrc @@ -0,0 +1,39 @@ +# System-wide .bashrc file for interactive bash(1) shells. + +# To enable the settings / commands in this file for login shells as well, +# this file has to be sourced in /etc/profile. + +# If not running interactively, don't do anything +[ -z "$PS1" ] && return + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# TODO: redox_chroot +if [ -z "${redox_chroot:-}" ] && [ -r /etc/redox_chroot ]; then + redox_chroot=$(cat /etc/redox_chroot) +fi + +# set a fancy prompt (non-color, overwrite the one in /etc/profile) +# but only if not SUDOing and have SUDO_PS1 set; then assume smart user. +if ! [ -n "${SUDO_USER}" -a -n "${SUDO_PS1}" ]; then + PS1='${redox_chroot:+($redox_chroot)}\u@\h:\w\$ ' +fi + +# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default. +# If this is an xterm set the title to user@host:dir +#case "$TERM" in +#xterm*|rxvt*) +# PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' +# ;; +#*) +# ;; +#esac + +# enable bash completion in interactive shells +#if ! shopt -oq posix; then +# if [ -f /etc/bash_completion ]; then +# . /etc/bash_completion +# fi +#fi diff --git a/recipes/shells/bash/etc/profile b/recipes/shells/bash/etc/profile new file mode 100644 index 00000000..7f85066c --- /dev/null +++ b/recipes/shells/bash/etc/profile @@ -0,0 +1,27 @@ +# /etc/profile: system-wide .profile file for the Bourne shell (sh(1)) +# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...). + +if [ "${PS1-}" ]; then + if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then + # The file bash.bashrc already sets the default PS1. + # PS1='\h:\w\$ ' + if [ -f /etc/bash.bashrc ]; then + . /etc/bash.bashrc + fi + else + if [ "$(id -u)" -eq 0 ]; then + PS1='# ' + else + PS1='$ ' + fi + fi +fi + +if [ -d /etc/profile.d ]; then + for i in /etc/profile.d/*.sh; do + if [ -r $i ]; then + . $i + fi + done + unset i +fi diff --git a/recipes/shells/bash/etc/skel/.bashrc b/recipes/shells/bash/etc/skel/.bashrc new file mode 100644 index 00000000..43783741 --- /dev/null +++ b/recipes/shells/bash/etc/skel/.bashrc @@ -0,0 +1,99 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color|*-256color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${redox_chroot:+($redox_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + PS1='${redox_chroot:+($redox_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# some more ls aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +# TODO +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +# alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + if [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi diff --git a/recipes/shells/bash/etc/skel/.profile b/recipes/shells/bash/etc/skel/.profile new file mode 100644 index 00000000..04df37bd --- /dev/null +++ b/recipes/shells/bash/etc/skel/.profile @@ -0,0 +1,25 @@ +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi diff --git a/recipes/shells/bash/recipe.toml b/recipes/shells/bash/recipe.toml index 3f6e8b1c..3bb164d2 100644 --- a/recipes/shells/bash/recipe.toml +++ b/recipes/shells/bash/recipe.toml @@ -12,7 +12,7 @@ dependencies = [ "readline", ] script = """ -DYNAMIC_INIT +# compiled statically COOKBOOK_CONFIGURE_FLAGS+=( ac_cv_func_wcwidth=no # TODO: add more wc functions and remove this bash_cv_func_sigsetjmp=no @@ -23,4 +23,5 @@ COOKBOOK_CONFIGURE_FLAGS+=( COOKBOOK_MAKE_JOBS=1 # workaround for parallel make bugs cookbook_configure ln -s "bash" "${COOKBOOK_STAGE}/usr/bin/sh" +cp -r "${COOKBOOK_RECIPE}/etc" "${COOKBOOK_STAGE}/etc" """ diff --git a/recipes/terminal/bash-completion/recipe.toml b/recipes/terminal/bash-completion/recipe.toml new file mode 100644 index 00000000..ce41919b --- /dev/null +++ b/recipes/terminal/bash-completion/recipe.toml @@ -0,0 +1,14 @@ +[source] +tar = "https://src.fedoraproject.org/repo/pkgs/bash-completion/bash-completion-1.3.tar.bz2/a1262659b4bbf44dc9e59d034de505ec/bash-completion-1.3.tar.bz2" +blake3 = "02014d743f403407f40fc05c2405c4bdce85c33a571d6b4b9a269369710c803f" + +[build] +template = "configure" +configureflags = [ + "--prefix=/", +] + +[package] +dependencies = [ + "sed", +]