1# 2# Administrative startup for /bin/sh 3# Place user customizations in ~/config/settings/profile 4# 5 6_ARCH=`getarch 2>/dev/null` 7if [ "$_ARCH" = "`getarch -p 2>/dev/null`" ] ; then 8 echo -e "\nWelcome to the Haiku shell.\n" 9 PS1="\w" 10else 11 echo -e "\nSwitching to architecture `getarch`\n" 12 PS1="[$_ARCH] \w" 13fi 14unset _ARCH 15 16export PS1="\["'`if [ $? = 0 ]; then echo "\e[32m"; 17 else echo "\e[31m"; fi`'"\]$PS1\[\e[0m\]> " 18 19export USER=`id -un` 20export GROUP=`id -gn` 21 22if [ -z $BE_HOST_CPU ]; then 23 . /boot/system/boot/SetupEnvironment 24fi 25 26export HISTFILESIZE=500 27export HISTCONTROL=ignoredups 28 29alias ls="ls --color=auto" 30alias ll="ls -lA" 31alias la="ls -A" 32alias m="more" 33 34test -n "$BASH_VERSION" && shopt -s checkwinsize 35 36# 37# and now we include a few useful things... 38# 39 40# 41# An almost-ksh compatible `whence' command. This is as hairy as it is 42# because of the desire to exactly mimic ksh. 43# 44# This depends somewhat on knowing the format of the output of the bash 45# `builtin type' command. 46# 47# Chet Ramey 48# chet@ins.CWRU.Edu 49# 50test -n "$KSH_VERSION" || whence() 51{ 52 local vflag= path= 53 54 if [ "$#" = "0" ] ; then 55 echo "whence: argument expected" 56 return 1 57 fi 58 case "$1" in 59 -v) vflag=1 60 shift 1 61 ;; 62 -*) echo "whence: bad option: $1" 63 return 1 64 ;; 65 *) ;; 66 esac 67 68 if [ "$#" = "0" ] ; then 69 echo "whence: bad argument count" 70 return 1 71 fi 72 73 returnValue=0 74 75 for cmd 76 do 77 if [ "$vflag" ] ; then 78 echo $(builtin type $cmd | sed 1q) 79 else 80 path=$(builtin type -path $cmd) 81 if [ "$path" ] ; then 82 echo $path 83 else 84 case "$cmd" in 85 */*) if [ -x "$cmd" ]; then 86 echo "$cmd" 87 else 88 returnValue=1 89 fi 90 ;; 91 *) case "$(builtin type -type $cmd)" in 92 "") returnValue=1 93 ;; 94 *) echo "$cmd" 95 ;; 96 esac 97 ;; 98 esac 99 fi 100 fi 101 done 102 return $returnValue 103} 104 105if test -n "$KSH_VERSION"; then 106 ps1_pwd() { 107 local e=$? d=${PWD:-?}/ p=~ 108 [[ $p = ?(*/) ]] || d=${d/#$p\//\~/} 109 print -nr -- "${d%/}" 110 return $e 111 } 112 PS1=${PS1/'\w'/'$(ps1_pwd)'} 113 alias which='whence -p' 114else 115 test -n "$BASH_VERSION" || PS1=$(printf '%s' "$PS1" | \ 116 sed 's/\\w/$PWD/') 117 alias which='whence' 118fi 119 120function dir { 121 ls -lF "$@"; 122} 123 124for dir in `findpaths -Re B_FIND_PATH_DATA_DIRECTORY profile.d 2> /dev/null`; do 125 for i in $dir/*.sh; do 126 if [ -r $i ]; then 127 . $i 128 fi 129 done 130 unset i 131done 132unset dir 133 134if [ -d /etc/profile.d ]; then 135 for i in /etc/profile.d/*.sh; do 136 if [ -r $i ]; then 137 . $i 138 fi 139 done 140 unset i 141fi 142