#!/bin/sh # .profile - Bourne-like shell (sh, ksh, bash, dash, zsh) init script # set the default file creation mask to something reasonably safe umask 022 # set the PATH to directories where binaries are usually located PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/local/bin:/opt/local/sbin PATH=$PATH:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin PATH=$PATH:/usr/local/zfs/bin:$HOME/bin export PATH # make ksh read .profile instead of .kshrc ENV="$HOME/.profile" # disable history in ksh/zsh HISTFILE=/dev/null # 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 ENV HISTFILE SHELL_SESSION_HISTORY SHELL_SESSIONS_DISABLE case $- in # interactive shell startup *i*) HOST="`uname -n | sed -e 's/\..*$//' | tr 'A-Z' 'a-z'`" # default prompt PS1="$HOST$ " PS2="> " # change the prompt if running as root (e.g. via sudo) if [ X"$EUID" = X"0" ] ; then PS1="$HOST# " PS2="#> " fi # include our home directory and our documents folder # in the CDPATH CDPATH=".:$HOME:$HOME/Documents:$HOME/Documents/src" # 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, and use raw control characters LESS="-XR" # disable history and use secure mode LESSHISTFILE="/dev/null" LESSHISTSIZE="0" LESSSECURE="1" export LESS LESSHISTFILE LESSHISTSIZE LESSSECURE fi # make ksh read .profile instead of .kshrc ENV="$HOME/.profile" export PS1 PS2 PAGER EDITOR VISUAL FCEDIT CDPATH # set bash and ksh specific options case "$0" in *bash*|*dash*) set -o emacs ignoreeof noclobber ;; *zsh*) bindkey -e set -o IGNORE_EOF MARK_DIRS ;; *ksh*) set -o emacs # additional options, may not be available on # all ksh versions set -o ignoreeof >/dev/null 2>&1 set -o noclobber >/dev/null 2>&1 set -o markdirs >/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 # OpenBSD ksh command completion, based on # https://github.com/qbit/dotfiles/blob/master/common/dot_ksh_completions # git if type git > /dev/null 2>&1 ; then set -A complete_git_1 -- \ branch \ checkout \ commit \ diff \ fetch \ pull \ push \ restore \ status \ switch \ > /dev/null 2>&1 fi # gpg if type gpg > /dev/null 2>&1 ; then set -A complete_gpg_1 -- \ --delete-keys \ --import \ --list-keys \ --list-public-keys \ --list-secret-keys \ --receive-keys \ --recv-keys \ --send-keys \ --verify \ > /dev/null 2>&1 fi # openssl if type openssl > /dev/null 2>&1 ; then set -A complete_openssl_1 -- \ md5 rmd160 sha1 sha256 sha512 \ > /dev/null 2>&1 fi # tmux if type tmux > /dev/null 2>&1 ; then set -A complete_tmux_1 -- \ attach \ ls \ new-session \ new-window \ > /dev/null 2>&1 fi ;; esac # create some safety functions cp () { /bin/cp -i "$@" ; } mv () { /bin/mv -i "$@" ; } rm () { /bin/rm -i "$@" ; } ls () { /bin/ls -aFC "$@" ; } yes() { echo "yes" ; } y() { echo "y" ; } # define aliases (if alias is available) if type alias > /dev/null 2>&1 ; then # 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" ; # run w3m in monochrome mode alias w3m="w3m -M" fi ;; esac # look for and load a local shell startup files if [ -r "$HOME/.profile_local" ] ; then . "$HOME/.profile_local" fi