Commit aabf64a2 authored by Vladimir Bashkirtsev's avatar Vladimir Bashkirtsev

Improve profile and bashrc scripts

parent 00011f8b
all: bash.profile locale.conf inputrc all: profile bash-completion dircolors extrapaths readline umask i18n bashrc locale-conf inputrc
tar xf bash-5.0.tar.gz tar xf bash-5.0.tar.gz
cd bash-5.0 && ./configure --build=$(CLFS_TARGET) --prefix=/usr --docdir=/usr/share/doc/bash-5.0 --without-bash-malloc --with-installed-readline cd bash-5.0 && ./configure --build=$(CLFS_TARGET) --prefix=/usr --docdir=/usr/share/doc/bash-5.0 --without-bash-malloc --with-installed-readline
$(MAKE) -C bash-5.0 $(MAKE) -C bash-5.0
...@@ -9,39 +9,246 @@ all: bash.profile locale.conf inputrc ...@@ -9,39 +9,246 @@ all: bash.profile locale.conf inputrc
fi fi
$(MAKE) -C bash-5.0 install $(MAKE) -C bash-5.0 install
mv -vf /usr/bin/bash /bin mv -vf /usr/bin/bash /bin
mkdir /etc/bash_completion.d @echo "$$PROFILE" > /etc/profile
@echo "$$BASHPROFILE" > /etc/profile install --directory --mode=0755 --owner=root --group=root /etc/profile.d
@echo "$$LOCALECONF" > /etc/locale.conf @echo "$$BASH_COMPLETION" > /etc/profile.d/bash_completion.sh
install --directory --mode=0755 --owner=root --group=root /etc/bash_completion.d
@echo "$$DIRCOLORS" > /etc/profile.d/dircolors.sh
dircolors -p > /etc/dircolors
@echo "$$EXTRAPATHS" > /etc/profile.d/extrapaths.sh
@echo "$$READLINE" > /etc/profile.d/readline.sh
@echo "$$UMASK" > /etc/profile.d/umask.sh
@echo "$$I18N" > /etc/profile.d/i18n.sh
@echo "$$BASHRC" > /etc/bashrc
dircolors -p > /etc/dircolors
@echo "$$LOCALE_CONF" > /etc/locale.conf
@echo "$$INPUTRC" > /etc/inputrc @echo "$$INPUTRC" > /etc/inputrc
rm -rf bash-5.0 rm -rf bash-5.0
bash.profile: profile:
define BASHPROFILE define PROFILE
# Begin /etc/profile # Begin /etc/profile
# Written for Beyond Linux From Scratch
# by James Robertson <jameswrobertson@earthlink.net>
# modifications by Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>
source /etc/locale.conf # System wide environment variables and startup programs.
for f in /etc/bash_completion.d/* # System wide aliases and functions should go in /etc/bashrc. Personal
do # environment variables and startup programs should go into
if [ -e $${f} ]; then source $${f}; fi # ~/.bash_profile. Personal aliases and functions should go into
# ~/.bashrc.
# Functions to help us manage paths. Second argument is the name of the
# path variable to be modified (default: PATH)
pathremove () {
local IFS=':'
local NEWPATH
local DIR
local PATHVARIABLE=$${2:-PATH}
for DIR in $${!PATHVARIABLE} ; do
if [ "$$DIR" != "$$1" ] ; then
NEWPATH=$${NEWPATH:+$$NEWPATH:}$$DIR
fi
done
export $$PATHVARIABLE="$$NEWPATH"
}
pathprepend () {
pathremove $$1 $$2
local PATHVARIABLE=$${2:-PATH}
export $$PATHVARIABLE="$$1$${!PATHVARIABLE:+:$${!PATHVARIABLE}}"
}
pathappend () {
pathremove $$1 $$2
local PATHVARIABLE=$${2:-PATH}
export $$PATHVARIABLE="$${!PATHVARIABLE:+$${!PATHVARIABLE}:}$$1"
}
export -f pathremove pathprepend pathappend
# Set the initial path
export PATH=/usr/bin
# Attempt to provide backward compatibility with LFS earlier than 11
if [ ! -L /bin ]; then
pathappend /bin
fi
if [ $$EUID -eq 0 ] ; then
pathappend /usr/sbin
if [ ! -L /sbin ]; then
pathappend /sbin
fi
unset HISTFILE
fi
# Setup some environment variables.
export HISTSIZE=1000
export HISTIGNORE="&:[bf]g:exit"
# Set some defaults for graphical systems
export XDG_DATA_DIRS=$${XDG_DATA_DIRS:-/usr/share/}
export XDG_CONFIG_DIRS=$${XDG_CONFIG_DIRS:-/etc/xdg/}
export XDG_RUNTIME_DIR=$${XDG_RUNTIME_DIR:-/tmp/xdg-$$USER}
PS1="$$[\u@\h \W]\$$ "
for script in /etc/profile.d/*.sh ; do
if [ -r $$script ] ; then
. $$script
fi
done done
unset f
export INPUTRC=/etc/inputrc unset script
# End /etc/profile # End /etc/profile
endef endef
export BASHPROFILE export PROFILE
bash-completion:
define BASH_COMPLETION
# Begin /etc/profile.d/bash_completion.sh
# Import bash completion scripts
# If the bash-completion package is installed, use its configuration instead
if [ -f /usr/share/bash-completion/bash_completion ]; then
# Check for interactive bash and that we haven't already been sourced.
if [ -n "$${BASH_VERSION-}" -a -n "$${PS1-}" -a -z "$${BASH_COMPLETION_VERSINFO-}" ]; then
# Check for recent enough version of bash.
if [ $${BASH_VERSINFO[0]} -gt 4 ] || \
[ $${BASH_VERSINFO[0]} -eq 4 -a $${BASH_VERSINFO[1]} -ge 1 ]; then
[ -r "$${XDG_CONFIG_HOME:-$$HOME/.config}/bash_completion" ] && \
. "$${XDG_CONFIG_HOME:-$$HOME/.config}/bash_completion"
if shopt -q progcomp && [ -r /usr/share/bash-completion/bash_completion ]; then
# Source completion code.
. /usr/share/bash-completion/bash_completion
fi
fi
fi
else
# bash-completions are not installed, use only bash completion directory
if shopt -q progcomp; then
for script in /etc/bash_completion.d/* ; do
if [ -r $$script ] ; then
. $$script
fi
done
fi
fi
# End /etc/profile.d/bash_completion.sh
endef
export BASH_COMPLETION
dircolors:
define DIRCOLORS
# Setup for /bin/ls and /bin/grep to support color, the alias is in /etc/bashrc.
if [ -f "/etc/dircolors" ] ; then
eval $$(dircolors -b /etc/dircolors)
fi
if [ -f "$$HOME/.dircolors" ] ; then
eval $$(dircolors -b $$HOME/.dircolors)
fi
alias ls='ls --color=auto'
alias grep='grep --color=auto'
endef
export DIRCOLORS
extrapaths:
define EXTRAPATHS
if [ -d /usr/local/lib/pkgconfig ] ; then
pathappend /usr/local/lib/pkgconfig PKG_CONFIG_PATH
fi
if [ -d /usr/local/bin ]; then
pathprepend /usr/local/bin
fi
if [ -d /usr/local/sbin -a $$EUID -eq 0 ]; then
pathprepend /usr/local/sbin
fi
# Set some defaults before other applications add to these paths.
pathappend /usr/share/man MANPATH
pathappend /usr/share/info INFOPATH
endef
export EXTRAPATHS
readline:
define READLINE
# Setup the INPUTRC environment variable.
if [ -z "$$INPUTRC" -a ! -f "$$HOME/.inputrc" ] ; then
INPUTRC=/etc/inputrc
fi
export INPUTRC
endef
export READLINE
umask:
define UMASK
# By default, the umask should be set.
if [ "$$(id -gn)" = "$$(id -un)" -a $$EUID -gt 99 ] ; then
umask 002
else
umask 022
fi
endef
export UMASK
i18n:
define I18N
# Set up i18n variables
. /etc/locale.conf
export LANG
endef
export I18N
bashrc:
define BASHRC
# Begin /etc/bashrc
# Written for Beyond Linux From Scratch
# by James Robertson <jameswrobertson@earthlink.net>
# updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>
# System wide aliases and functions.
# System wide environment variables and startup programs should go into
# /etc/profile. Personal environment variables and startup programs
# should go into ~/.bash_profile. Personal aliases and functions should
# go into ~/.bashrc
# Provides colored /bin/ls and /bin/grep commands. Used in conjunction
# with code in /etc/profile.
alias ls='ls --color=auto'
alias grep='grep --color=auto'
# Provides prompt for non-login shells, specifically shells started
# in the X environment. [Review the LFS archive thread titled
# PS1 Environment Variable for a great case study behind this script
# addendum.]
PS1="$$[\u@\h \W]\$$ "
# End /etc/bashrc
endef
export BASHRC
locale.conf: locale-conf:
define LOCALECONF define LOCALE_CONF
# Begin /etc/locale.conf # Begin /etc/locale.conf
LANG=$(SYSTEM_LOCALE) LANG=$(SYSTEM_LOCALE)
# End /etc/locale.conf # End /etc/locale.conf
endef endef
export LOCALECONF export LOCALE_CONF
inputrc: inputrc:
define INPUTRC define INPUTRC
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment