├── README.md ├── bashrc ├── bashrc.d ├── 20-shell.sh ├── 20-vcs.sh ├── 90-bash-completion └── _vcs │ ├── git │ └── hg ├── profile ├── profile.d ├── 25-coreutils.sh └── 40-desktopenvironments.sh └── skel ├── .bash_logout ├── .bash_profile └── .bashrc /README.md: -------------------------------------------------------------------------------- 1 | bash-config 2 | =========== 3 | 4 | AOSC's bash & sh startup files in `/etc`. This is meant to be a minimal 5 | one with *some* features, and if you really want a cool one, consult things 6 | like bashstyle-ng. 7 | 8 | Features 9 | -------- 10 | 11 | * Colored PS1 with VCS branch display and return-value based prompt 12 | ![bashrc with git, commit b9913ca](http://ibin.co/1QscpgR0BOyN) 13 | * OS X-like `/etc/paths` management scheme. 14 | * Regular `somefile.d` directorys. 15 | * Common aliases. 16 | 17 | Structure 18 | --------- 19 | 20 | * `bashrc` - Bash's global startup file, sourced by `~/.bashrc`. Contains 21 | stuffs that we think is good for all users. 22 | * Sources `profile` for environmental variables 23 | * Sets some variables for colors 24 | * Sources `bashrc.d` 25 | * Sets up the PS1 26 | * Sets up aliases 27 | * Sets up some bash-specific variables. 28 | * `profile` - Environment variables for all POSIX login shells 29 | * Sets up `$PATH` and `$MANPATH`: 30 | * Ignores lines starting with `#`. 31 | * Adds each line of `/etc/paths.d/._pre*` to `$PATH`, 32 | * Adds each line of `/etc/paths` to `$PATH`, 33 | * Adds each line of `/etc/paths.d/*` to `$PATH`. 34 | * Then do almost the same for `manpaths`. 35 | * If those are still empty, default values `{,/usr{,/local}}/{s,}bin` and 36 | `/usr/{,local/}man` are used. 37 | * Sets up `$TZ` and some common history variables. 38 | * Sources `profile.d`. 39 | * `skel` - `$HOME` Skeleton. Contains what we think is good for most users. 40 | * `.bashrc` - User bash startup, sources `/etc/bashrc`. 41 | * `.bash_profile` - User bash login, sources `~/.bashrc`. 42 | * `.bash_logout` - User bash logout. 43 | * `bashrc.d` - Files sourced by `/etc/bashrc`. 44 | * `20-vcs` - VCS aliases and PS1. Provides `_vcs_status`. 45 | * `.vcs_*` - VCS Implementations. 46 | * `profile.d` - Files sourced by `/etc/profile`. 47 | 48 | Dependencies 49 | ------------ 50 | 51 | * GNU Bash for `bashrc` stuffs. When we are happy, we try to make most parts of 52 | `bashrc` compatible with other bourne/POSIX-like shells, e.g. `hush`/`ash`. 53 | * At least a mostly POSIX-compatible shell for `profile`. We try our best to 54 | guarantee that it's written fully POSIXly. Send us an issue if it's not. 55 | * Coreutils for `profile`. More specifically, `cat`, `sed` and `mkdir`. 56 | GNU/Busybox ones are preferred. See [#Porting](#Porting) for more info. 57 | 58 | Invocation 59 | ---------- 60 | 61 | This briefly describes how bash processes the files. and put here as a sort of 62 | reference: 63 | 64 | On Startup: 65 | ```Bash 66 | # Pseudo-code functions: 67 | # _bash_optarg: The argument for an option. 68 | # _bash_opts: If this option is set: [[ $- == *$1* ]]. 69 | _is_sh(){ [ "$(basename "$BASH")" == "sh" ]; } 70 | _is_posix(){ shopt -oq posix; } 71 | _is_interactive() { case "$-" in *i*) return 0; esac; return 1; } 72 | _is_login(){ [ "${0:0:1}" == - ] || _bash_opts -l; } 73 | # Real bash doesn't change the return value, just for convenience with || 74 | load_if_exists(){ [ -r "$1" ] || return 1; . "$@"; true; } 75 | if _is_interactive; then 76 | if _is_login && ! _bash_opts --noprofile; then 77 | load_if_exists /etc/profile 78 | if ! _is_sh; then 79 | load_if_exists ~/.bash_profile || 80 | load_if_exists ~/.bash_login || 81 | load_if_exists ~/.profile 82 | else 83 | load_if_exists ~/.profile 84 | fi 85 | elif ! _bash_opts --norc; then 86 | if ! _is_posix; then 87 | _is_sh || load_if_exists "$(_bash_optarg --rcfile || echo ~/.bashrc)" 88 | else 89 | load_if_exists "$ENV" 90 | fi 91 | elif _is_network_input; then 92 | is_sh || load_if_exists ~/.bashrc 93 | fi 94 | # Non-interactive (i.e. To run a script) 95 | else 96 | if ! _is_sh; then 97 | load_if_exists "$BASH_ENV" 98 | fi 99 | fi 100 | _is_sh && shopt -os posix 101 | ``` 102 | 103 | On exit: 104 | ```Bash 105 | if _is_login && ! _is_sh && ! _is_posix; then 106 | load_if_exists ~/.bash_logout 107 | fi 108 | ``` 109 | 110 | Porting 111 | ------- 112 | 113 | The master branch of this repo can be easily ported to other platforms 114 | with bash and an echo with -e flag. For earlier bash without `\e` escaping, 115 | perform `sed -i -e 's@\\e@\\33@g' **` on the tree. 116 | 117 | If you use BSD coreutils, change `ls --color=auto` to `ls -G`. 118 | 119 | If you use OS X or wants to make an OS X distribution, you had better include 120 | the workaround mentioned in 121 | [#3](https://github.com/AOSC-Dev/bash-config/issues/3), 122 | in order to avoid "Please install XCode Developer Tools" 123 | from appearing too many times. 124 | 125 | This package provides an example: 126 | [Bash 4.3 for OS X](http://pan.baidu.com/s/1c0xlkFu). 127 | 128 | F@Q 129 | --- 130 | 131 | Those are questions collected over time. I got tired answering this, although 132 | some people like @Icenowy keeps annoying me with those. 133 | 134 | ### Why did I get a command `lastdir` not found error on logout? 135 | 136 | Because including that feature was a mistake, and we fixed it. You will need 137 | to replace corresponding file(s) with those in `/etc/skel`, so just run 138 | `cat /etc/skel/.bash_logout > ~/.bash_logout`. 139 | 140 | If you have made extra changes to that file, merge them by yourself. 141 | 142 | ### Why are you breaking things? 143 | 144 | Because AOSC OS itself is beta. Luckily, although it comes with no warrenty, 145 | documented things will not be changed frequently. Data loss should be super 146 | rare, or *epic*, too. Even ourselves use it on production environment. 147 | 148 | If those things happens to you, we can buy you some lolipop. You can also open 149 | _Love Live_ and perform a 11-time recruit. 150 | -------------------------------------------------------------------------------- /bashrc: -------------------------------------------------------------------------------- 1 | # Begin /etc/bashrc 2 | # Written for Beyond Linux From Scratch 3 | # by James Robertson 4 | # updated by Bruce Dubbs 5 | 6 | # Then improved and changed to fit AOSC OS. 7 | # By Mingcong Bai and Arthur Wang. 8 | 9 | # System wide aliases and functions. 10 | [ "$BASH" ] || shopt(){ return ${shopt_def-0}; } 11 | _is_posix(){ shopt -oq posix; } 12 | 13 | # System wide environment variables and startup programs should go into 14 | # /etc/profile. Personal environment variables and startup programs 15 | # should go into ~/.bash_profile. Personal aliases and functions should 16 | # go into ~/.bashrc 17 | 18 | # Provides prompt for non-login shells, specifically shells started 19 | # in the X environment. 20 | 21 | # Setting shell options: 22 | # 23 | # - Make bash append rather than overwrite the history on disk. 24 | # - Allows user to edit a failed hist exp. 25 | # - Allows user to verify the results of hist exp. 26 | # - When changing directory small typos can be ignored by bash. 27 | # - Chdirs into it if command is a dir. 28 | # - Do not complete when readline buf is empty. 29 | # - Extended glob (3.5.8.1) & find-all-glob with **. 30 | # - Hashtable the commands! 31 | # - Winsize. 32 | shopt -s \ 33 | histappend \ 34 | histreedit \ 35 | histverify \ 36 | cdspell \ 37 | autocd \ 38 | no_empty_cmd_completion \ 39 | extglob \ 40 | globstar \ 41 | checkwinsize 42 | HISTIGNORE='&:[bf]g:exit' 43 | HISTCONTROL='ignorespace' 44 | 45 | # Disable executable path hashing. It gets confusing quickly, as the same 46 | # command can in fact exist in multiple PATH locations. 47 | set +h 48 | 49 | # Colors 50 | alias l='ls -AFlh' 51 | alias ll='ls -Flh' 52 | alias la='ls -AF' 53 | for c in {e,f,}grep {v,}dir ls; do alias $c="$c --color=auto"; done 54 | 55 | # ip color 56 | alias ip='ip --color=auto' 57 | 58 | # space and time efficient cp 59 | alias cp='cp --reflink=auto --sparse=always' 60 | 61 | # So they can be unset. 62 | # I need someone to help me assign those names properly. 63 | # Those are actually bold colors. 64 | _aosc_bashrc_colors='NORMAL BOLD RED GREEN CYAN IRED YELLOW' 65 | NORMAL='\e[0m' 66 | BOLD='\e[1m' 67 | RED='\e[1;31m' 68 | GREEN='\e[1;32m' 69 | CYAN='\e[1;36m' 70 | YELLOW='\e[1;93m' 71 | IRED='\e[0;91m' 72 | 73 | if _rc_term_colors="$(tput colors)"; then 74 | [ "$_rc_term_colors" -le 16 ] 75 | else 76 | case "$TERM" in (linux|msys|cygwin) true;; (*) false;; esac 77 | fi && YELLOW='\e[1;33m' IRED='\e[0;31m' 78 | unset _rc_term_colors 79 | 80 | # if our TERM has no color support, then unset $_aosc_bashrc_colors 81 | 82 | # A simple error level reporting function. 83 | # Loaded back to PS1 84 | _ret_prompt() { 85 | case $? in 86 | 0|130) # Input C-c, we have to override the \$ 87 | ((EUID)) && echo -n '$' || echo -n '#';; 88 | 127) # Command not found 89 | echo -ne '\01\e[1;36m\02?' 90 | ;; 91 | *) # Other errors 92 | echo -ne '\01'$YELLOW'\02!' 93 | ;; 94 | esac 95 | } 96 | 97 | _ret_same() { return $?; } 98 | 99 | _ssh_session() { 100 | # Store error code. 101 | err="$?" 102 | # This if branch would overwrite the current error code. 103 | if [[ x"${SSH_CONNECTION:-}" != "x" ]]; then 104 | echo '(ssh)' 105 | fi 106 | # Load error code. 107 | return "$err" 108 | unset err 109 | } 110 | 111 | # Set up PATH and MANPATH 112 | # WSL compatibility (retain PATH from Windows host). 113 | if [[ ! -v WSL_DISTRO_NAME ]]; then 114 | unset PATH 115 | fi 116 | unset MANPATH 117 | 118 | # WSL compatibility (retain PATH from Windows host). 119 | if [[ ! -v WSL_DISTRO_NAME ]]; then 120 | : ${PATH=$HOME/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin} 121 | else 122 | : ${PATH=$PATH:$HOME/.local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin} 123 | fi 124 | : ${MANPATH=/usr/share/man:/usr/local/share/man} 125 | export PATH MANPATH 126 | 127 | # Base functions ready. Let's load bashrc.d. 128 | for script in /etc/bashrc.d/!(_vcs); do . "$script"; done 129 | 130 | # The prompt depends on vcs_status! Get one backup anyway. 131 | type _vcs_status &>/dev/null || \ 132 | alias _vcs_status=_ret_same 133 | 134 | # To be shipped together. See comments in bashrc_repo on _ret and _ret_status(). 135 | 136 | # Use "\w" if you want the script to display full path 137 | # How about using cut to "\w($PWD)" to give path of a certain depth? 138 | # Well, forget it. 139 | 140 | if [[ "$EUID" == 0 ]] ; then 141 | PS1="\[$YELLOW\]\$(_ssh_session)\[$NORMAL\]\[$RED\]\u\[$NORMAL\]\[$BOLD\]@\[$NORMAL\]\h [ \W\$(_vcs_status) ]\[$RED\] \$(_ret_prompt) \[$NORMAL\]" 142 | else 143 | PS1="\[$YELLOW\]\$(_ssh_session)\[$NORMAL\]\[$GREEN\]\u\[$NORMAL\]\[$BOLD\]@\[$NORMAL\]\h [ \W\$(_vcs_status) ]\[$GREEN\] \$(_ret_prompt) \[$NORMAL\]" 144 | fi 145 | 146 | # Extra Aliases for those lazy ones :) 147 | gen_dotdotdot() { 148 | local _i='cd ..' 149 | local _ii='..' 150 | for i in {0..16}; do 151 | alias $_ii="$_i" 152 | _i+='/..' 153 | _ii+='.' 154 | done 155 | } 156 | gen_dotdotdot 157 | alias nano='nano -w -u' 158 | alias ed='ed -p: -v' 159 | 160 | # A standard alias for which (debianutils vs GNU) 161 | _is_posix || which --version 2>/dev/null | grep -q GNU && alias which='(alias; declare -f) | which -i --read-functions' 162 | 163 | # Misc stuffs 164 | FIGNORE='~' 165 | TIMEFORMAT=$'\nreal\t%3lR\t%P%%\nuser\t%3lU\nsys\t%3lS' 166 | 167 | _IFS=' 168 | ' # $' \t\n' 169 | IFS=' 170 | ' # $'\n' 171 | for pth in $(cat /etc/paths.d/._* /etc/paths /etc/paths.d/*); do 172 | case "$pth" in \#*) continue;; esac 173 | PATH="$PATH:$pth" 174 | done 2>/dev/null 175 | 176 | for pth in $(cat /etc/manpaths.d/._* /etc/manpaths /etc/manpaths.d/*); do 177 | case "$pth" in \#*) continue;; esac 178 | MANPATH="$MANPATH:$pth" 179 | done 2>/dev/null 180 | IFS="$_IFS" 181 | 182 | # Setup some environment variables. 183 | export HISTFILESIZE="${HISTFILESIZE:-4096}" 184 | 185 | # Timezone variable $TZ, Wine and stuff alike need it. 186 | export TZ="$(readlink /etc/localtime | sed -e 's/^\.\.//g' -e 's@/usr/share/zoneinfo/@@')" 187 | 188 | unset pth script shopt 189 | # End /etc/bashrc 190 | -------------------------------------------------------------------------------- /bashrc.d/20-shell.sh: -------------------------------------------------------------------------------- 1 | # Setup the INPUTRC environment variable. 2 | if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ] ; then 3 | INPUTRC=/etc/inputrc 4 | fi 5 | export INPUTRC 6 | 7 | # By default, the umask should be set. 8 | if [ "$(id -gn)" = "$(id -un)" -a $EUID -gt 99 ] ; then 9 | umask 002 10 | else 11 | umask 022 12 | fi 13 | 14 | if [ -d ~/bin ]; then 15 | PATH="$HOME/bin:$PATH" 16 | fi 17 | -------------------------------------------------------------------------------- /bashrc.d/20-vcs.sh: -------------------------------------------------------------------------------- 1 | # 20-vcs, the version control display for AOSC OS PS1. 2 | # by Arthur Wang 3 | 4 | # This module is highly extensible. Just read the source. 5 | # Long-term TODO: svn, vns and bzr. 6 | 7 | # We are not POSIX-compatible. 8 | _is_posix && return 9 | 10 | # Get functions 11 | if [ -e /etc/bashrc.d/_vcs ]; then 12 | for _vcs in /etc/bashrc.d/_vcs/*; do 13 | . "$_vcs" 14 | _vcs_mods+=" $(basename ${_vcs})" 15 | done 16 | else 17 | _vcs_status(){ true; } 18 | unset _vcs_files 19 | return 20 | fi 21 | unset _vcs 22 | 23 | # Output 24 | _vcs_status() { 25 | _ret=$? 26 | local _vcs 27 | for _vcs in $_vcs_mods; do 28 | _ps1_"$_vcs"_status && break 29 | done 30 | return $_ret 31 | } 32 | -------------------------------------------------------------------------------- /bashrc.d/90-bash-completion: -------------------------------------------------------------------------------- 1 | # load bash-completion if installed 2 | 3 | if [[ -r /usr/share/bash-completion/bash_completion ]]; then 4 | . /usr/share/bash-completion/bash_completion 5 | fi 6 | -------------------------------------------------------------------------------- /bashrc.d/_vcs/git: -------------------------------------------------------------------------------- 1 | # bashrc extra functions written for AOSC OS, package "git" 2 | 3 | # Aliases, mostly from http://blog.sina.com.cn/s/blog_630c58cb01011uid.html 4 | alias g="git status" 5 | alias ga="git add" 6 | alias gaa="git add ." 7 | alias gau="git add -u" 8 | alias gct="git commit" 9 | alias gcm="git commit -m" 10 | alias gca="git commit -am" 11 | alias gb="git branch" 12 | alias gbd="git branch -d" 13 | alias gco="git checkout" 14 | alias gcob="git checkout -b" 15 | alias gt="git stash" 16 | alias gta="git stash apply" 17 | alias gmg="git merge" 18 | alias gr="git rebase" 19 | alias gl="git log --oneline --decorate" 20 | alias gsh="git show" 21 | alias gd="git diff --ws-error-highlight all" 22 | alias gdca="git diff --ws-error-highlight all --cached" 23 | alias gbl="git blame" 24 | alias gps="git push" 25 | alias gpl="git pull" 26 | alias gcp="git cherry-pick" 27 | 28 | # Prompt 29 | if command -v bash-git-status 2>&1>/dev/null; then 30 | alias __ps1_git_branch="bash-git-status" 31 | else 32 | alias __ps1_git_branch="git branch 2>/dev/null | grep '*' | sed 's/*\ //g'" 33 | fi 34 | 35 | _ps1_git_status() { 36 | if command -v bash-git-status 2>&1>/dev/null; then 37 | local bgs 38 | bgs=$(bash-git-status) 39 | case "$?" in 40 | 1) 41 | return 1 42 | ;; 43 | 5) 44 | echo -e "\01\e[1m\02@\01\e[0;32m\0002$bgs\01\e[0m\02" 45 | ;; 46 | 6) 47 | echo -e "\01\e[1m\02@\01$IRED\0002$bgs\01\e[0m\02" 48 | ;; 49 | 7) 50 | echo -e "\01\e[1m\02@\01\e[0;35m\0002$bgs\01\e[0m\02" 51 | ;; 52 | 8) 53 | echo -e "\01\e[1m\02@\01\e[0;37m\0002$bgs\01\e[0m\02" 54 | ;; 55 | esac 56 | else 57 | gbr=$(git branch 2>/dev/null) || return 1 58 | gbr=$(printf %s "$gbr" | grep '*' | sed 's/*\ //g') 59 | local gst 60 | gst=$(LC_ALL=C git status 2>&1) 61 | if printf %s "$gst" | grep -q "nothing to commit"; then 62 | echo -e "\01\e[1m\02@\01\e[0;32m\0002$gbr\01\e[0m\02" 63 | elif printf %s "$gst" | grep -q "nothing added to commit"; then # Untracked 64 | echo -e "\01\e[1m\02@\01\e[0;35m\0002$gbr\01\e[0m\02" 65 | elif printf %s "$gst" | grep -q "must be run in a work tree"; then # Not in work tree 66 | echo -e "\01\e[1m\02@\01\e[0;37m\0002$gbr\01\e[0m\02" 67 | else # Change not added/not merged yet 68 | echo -e "\01\e[1m\02@\01$IRED\0002$gbr\01\e[0m\02" 69 | fi 70 | fi 71 | } 72 | 73 | 74 | # A shorter one without color 75 | # alias _git_status='_st="$(__git_branch)"; ((!PIPESTATUS[0])) && echo "@$_st"' 76 | # For users of the contrib/completion __git_ps1 77 | # _git_status(){ git branch &>/dev/null || return 1; echo -n ' '; __git_ps1; } 78 | -------------------------------------------------------------------------------- /bashrc.d/_vcs/hg: -------------------------------------------------------------------------------- 1 | # bashrc extra functions written for AOSC OSes, package "hg" 2 | # by Arthur Wang 3 | 4 | [ "$TERMCOLOR"=="8" ] && IRED="\e[0;31m" || IRED="\e[0;91m" 5 | 6 | # Aliases from https://gist.github.com/shukydvir/1112265 7 | alias hl='hg pull' 8 | alias hp='hg push' 9 | alias hd='hg diff' 10 | alias hc='hg commit' 11 | alias hco='hg checkout' 12 | alias hb='hg branch' 13 | alias hs='hg status' 14 | alias ha='hg add .' 15 | 16 | _detect_hg() { 17 | local _hg_dir="$1" 18 | local i=1 19 | if [ "${_hg_dir:0:1}" != "/" ] ; then 20 | echo "$FUNCNAME: absolute path required" >&2 21 | return 1 22 | fi 23 | # NOTE $_hg_dir is empty when it reaches /. 24 | while ! [ "/$_hg_dir" -ef "/" ] ; do 25 | if [ -d "$_hg_dir"/.hg ] ; then 26 | return 0 27 | fi 28 | _hg_dir="${_hg_dir%/*}" 29 | done 30 | [ -d /.hg ] 31 | } 32 | 33 | # From http://mediadoneright.com/content/ultimate-git-ps1-bash-prompt 34 | # Modified for hg. 35 | _ps1_hg_status() { 36 | # skip the check if possible, because hg is slow. 37 | _detect_hg $PWD || return 1 38 | hgb=$(hg branch 2>/dev/null) || return 1 39 | hgs=$(LC_ALL=C hg status 2>&1) 40 | if [ -z "$hgs" ]; then # unmodified 41 | echo -e "\01\e[1m\02@\01\e[0;32m\0002$hgb\01\e[0m\02" 42 | elif printf %s "$hgs" | grep -q '^[M!]'; then # modified or deleted 43 | echo -e "\01\e[1m\02@\01$IRED\0002$hgb\01\e[0m\02" 44 | elif printf %s "$hgs" | grep -q '^?'; then # untracked 45 | echo -e "\01\e[1m\02@\01\e[0;35m\0002$hgb\01\e[0m\02" 46 | else 47 | echo -e "\01\e[1m\02@\01\e[0;37m\0002$hgb\01\e[0m\02" 48 | fi 49 | } 50 | 51 | # A shorter one without color 52 | # alias _hg_status='_st="$(hg branch)" && echo "@$st"' 53 | -------------------------------------------------------------------------------- /profile: -------------------------------------------------------------------------------- 1 | # Begin /etc/profile 2 | # Written for Beyond Linux From Scratch 3 | # by James Robertson 4 | # modifications by Dagmar d'Surreal 5 | 6 | # System wide environment variables and startup programs. 7 | 8 | # System wide aliases and functions should go in /etc/bashrc. Personal 9 | # environment variables and startup programs should go into 10 | # ~/.bash_profile. Personal aliases and functions should go into 11 | # ~/.bashrc. 12 | 13 | # Source profile scripts 14 | for script in /etc/profile.d/* ; do 15 | case "$script" in 16 | *.bash) 17 | [ "$BASH" ] && . "$script" ;; 18 | *.sh) 19 | . "$script" ;; 20 | esac 21 | done 22 | 23 | # Now to clean up 24 | unset pth script 25 | # End /etc/profile 26 | -------------------------------------------------------------------------------- /profile.d/25-coreutils.sh: -------------------------------------------------------------------------------- 1 | # Setup for /bin/ls to support color, the alias is in /etc/bashrc. 2 | if [ "$LS_COLORS" ]; then 3 | : 4 | elif [ -f "/etc/dircolors" ]; then 5 | eval "$(dircolors -b /etc/dircolors)" 6 | elif [ -f "$HOME/.dircolors" ] ; then 7 | eval "$(dircolors -b "$HOME/.dircolors")" 8 | else 9 | eval "$(dircolors -b)" 10 | fi 11 | -------------------------------------------------------------------------------- /profile.d/40-desktopenvironments.sh: -------------------------------------------------------------------------------- 1 | # Set locale for legacy desktop environments that do not respect localectl. 2 | # TODO: export and fallback all the stuffs as defined in locale.conf(7). 3 | [ -f /etc/locale.conf ] && . /etc/locale.conf 4 | export LANG 5 | if test -z "${XDG_RUNTIME_DIR}"; then 6 | if test -d "/run/user/${UID}"; then 7 | # Systemd uses this as XDG_RUNTIME_DIR 8 | export XDG_RUNTIME_DIR=/run/user/${UID} 9 | else 10 | export XDG_RUNTIME_DIR=/tmp/${UID}-runtime-dir 11 | if ! test -d "${XDG_RUNTIME_DIR}"; then 12 | mkdir -p "${XDG_RUNTIME_DIR}" 13 | chmod 0700 "${XDG_RUNTIME_DIR}" 14 | fi 15 | fi 16 | fi 17 | 18 | -------------------------------------------------------------------------------- /skel/.bash_logout: -------------------------------------------------------------------------------- 1 | # Begin ~/.bash_logout 2 | # Written for Beyond Linux From Scratch 3 | # by James Robertson 4 | 5 | # End ~/.bash_logout 6 | -------------------------------------------------------------------------------- /skel/.bash_profile: -------------------------------------------------------------------------------- 1 | # Begin ~/.bash_profile 2 | # Written for Beyond Linux From Scratch 3 | # by James Robertson 4 | # updated by Bruce Dubbs 5 | 6 | # Personal environment variables and startup programs. 7 | 8 | # Personal aliases and functions should go in ~/.bashrc. System wide 9 | # environment variables and startup programs are in /etc/profile. 10 | # System wide aliases and functions are in /etc/bashrc. 11 | 12 | append () { 13 | # First remove the directory 14 | local IFS=':' 15 | local NEWPATH DIR 16 | for DIR in $PATH; do 17 | if [ "$DIR" != "$1" ]; then 18 | NEWPATH="${NEWPATH:+$NEWPATH:}$DIR" 19 | fi 20 | done 21 | # Then append the directory 22 | export PATH="$NEWPATH:$1" 23 | } 24 | 25 | # Set GCC_COLORS to something to trigger the tty-dependent auto coloring. 26 | # Using a dummy value so we are not overriding the defaults. 27 | export GCC_COLORS="${GCC_COLORS:-aosc-dummy=01}" 28 | 29 | if [ -f "$HOME/.bashrc" ] ; then 30 | source $HOME/.bashrc 31 | fi 32 | 33 | # End ~/.bash_profile 34 | -------------------------------------------------------------------------------- /skel/.bashrc: -------------------------------------------------------------------------------- 1 | # Begin ~/.bashrc 2 | # Written for Beyond Linux From Scratch 3 | # by James Robertson 4 | 5 | # Personal aliases and functions. 6 | 7 | # Personal environment variables and startup programs should go in 8 | # ~/.bash_profile. System wide environment variables and startup 9 | # programs are in /etc/profile. System wide aliases and functions are 10 | # in /etc/bashrc. 11 | 12 | if [ -f "/etc/bashrc" ] ; then 13 | source /etc/bashrc 14 | fi 15 | 16 | # End ~/.bashrc 17 | --------------------------------------------------------------------------------