#!/bin/sh # .profile - init script for Bourne-like shells (sh, ksh, bash, dash, zsh) # set the default file creation mask to something reasonably safe umask 022 # set the PATH to directories where binaries are usually located PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/local/sbin:/opt/local/bin PATH=$PATH:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin PATH=$PATH:/usr/games:/usr/local/zfs/bin:/usr/local/games:$HOME/bin export PATH # disable per-session history in bash and zsh on MacOSX # see: https://stackoverflow.com/a/54338056 # https://superuser.com/a/1610999 # also remember to create $HOME/.bash_sessions_disable SHELL_SESSION_HISTORY=0 SHELL_SESSIONS_DISABLE=1 export SHELL_SESSION_HISTORY SHELL_SESSIONS_DISABLE case $- in # interactive shell startup *i*) # default prompt PS1='$ ' PS2='> ' # change the prompt if running as root (e.g. via su) if [ X"$EUID" = X"0" ] ; then PS1='# ' PS2='#> ' else # only include home directory, documents, and src in CDPATH # if not running as root CDPATH=".:$HOME:$HOME/Documents:$HOME/Documents/src" fi # default the editor to vi EDITOR="vi" VISUAL="$EDITOR" FCEDIT="$EDITOR" # default to more unless less is available PAGER="more" if type less > /dev/null 2>&1 ; then PAGER="less" # disable terminal init in less, and use raw control characters LESS="-XR" # disable less' history and use secure mode LESSHISTFILE="/dev/null" LESSHISTSIZE="0" LESSSECURE="1" export LESS LESSHISTFILE LESSHISTSIZE LESSSECURE fi # set the scale for dc to 20 (same as bc -l) DC_ENV_ARGS="-e 10k" # export variables for interactive shells export PS1 PS2 CDPATH EDITOR VISUAL FCEDIT PAGER DC_ENV_ARGS # remove all aliases, if possible unalias -a > /dev/null 2>&1 # shell options case "$0" in *bash*) set -o emacs ignoreeof noclobber PS1='\h\$ ' ENV="$HOME/.profile" HISTFILE=/dev/null ;; *dash*) set -o emacs ignoreeof noclobber ENV="$HOME/.profile" HISTFILE=/dev/null ;; *zsh*) bindkey -e set -o IGNORE_EOF MARK_DIRS PS1="%m%# " ENV="$HOME/.profile" HISTFILE=/dev/null ;; *ksh*) # ksh options, may not be available in all versions set -o emacs > /dev/null 2>&1 set -o ignoreeof > /dev/null 2>&1 set -o noclobber > /dev/null 2>&1 set -o markdirs > /dev/null 2>&1 set -o csh-history > /dev/null 2>&1 # bash style tab completion in emacs mode if type bind > /dev/null 2>&1 ; then bind "^I=complete-list" #bind "^I=complete" #bind "^I^I=complete-list" fi # ignore duplicates in command history HISTCONTROL=ignoredups export HISTCONTROL # for interactive ksh sessions, load # customizations in .kshrc ENV="$HOME/.kshrc" ;; esac export ENV HISTFILE if [ X"$ENV" != X"$HOME/.kshrc" ] ; then # create helpful aliases, if possible if type alias > /dev/null 2>&1 ; then unalias cp mv rm ls yes y gti suod bc w3m > /dev/null 2>&1 alias cp="/bin/cp -i" alias mv="/bin/mv -i" alias rm="/bin/rm -i" alias ls="/bin/ls -aFC" alias yes="echo yes" alias y="echo y" # alias for typos alias gti="git" alias suod="sudo" # run bc with -l option to load the math # library so that we get floating point # math, instead of just integer math alias bc="bc -l" > /dev/null 2>&1 # run w3m in monochrome mode alias w3m="w3m -M" > /dev/null 2>&1 else # create some functions cp () { /bin/cp -i "$@" ; } mv () { /bin/mv -i "$@" ; } rm () { /bin/rm -i "$@" ; } ls () { /bin/ls -aFC "$@" ; } yes() { echo "yes" ; } y() { echo "y" ; } fi fi ;; esac # load a local shell startup file, if present if [ -r "$HOME/.profile_local" ] ; then . "$HOME/.profile_local" fi