# .bashrc # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # Shell control export HISTCONTROL=ignorespace:erasedups export HISTSIZE=100000 export HISTFILESIZE=100000 shopt -s histappend shopt -s checkwinsize # User specific aliases and functions alias rm='rm -i' alias l='less -N' alias dotgit='/usr/bin/git --git-dir=$HOME/code/dotfiles.git --work-tree=$HOME' # Add to path cleanly local_pathmunge () { case ":${PATH}:" in *:"$1":*) ;; *) if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi esac } local_pathmunge ~/usr/local/bin # An emacs 'alias' with the ability to read from stdin; example: # echo "hello world" | ef - ef() { # If the argument is - then write stdin to a tempfile and open the # tempfile. if [[ "$1" == "-" ]]; then tempfile=$(mktemp emacs-stdin-$USER.XXXXXXX --tmpdir) cat - > $tempfile emacsclient -n -c -e "(progn (find-file \"$tempfile\") (set-visited-file-name nil) (rename-buffer \"*stdin*\" t)) " 2>&1 > /dev/null else emacsclient -n -c "$@" fi } # Source first available file in list source_first() { for x in $*; do [ -f $x ] && source $x && break done } # fasd: Jump to directory or use FZF j() { [ $# -gt 0 ] && fasd_cd -d "$*" && return local dir dir=$(fasd -Rdl "$1" | fzf -1 -0 --no-sort +m) && cd "${dir}" || return 1 } # Set up command-line key bindings case "$-" in *i*) # Interactive shells # Set up fzf and fasd source_first /usr/share/fzf/shell/key-bindings.bash ~/.fzf.bash eval "$(~/usr/local/bin/fasd --init auto)" complete -d j eval "$(direnv hook bash)" source ~/usr/local/bin/commacd.sh # Emacs tramp wants a simple prompt that it can recognize if [[ "$TERM" = "dumb" ]]; then PS1="> " fi ;; *) # Non-interactive shells ;; esac