bash_profile @ c29a6ab95e91

A bit more remote stuff
author Steve Losh <steve@stevelosh.com>
date Fri, 17 Jan 2020 22:09:22 -0500
parents dcbf704290a1
children 93820aa446f2
#!/usr/bin/env bash

shopt -s expand_aliases
shopt -s histappend

# Save multiline commands as a single history entry.
shopt -s cmdhist

HISTFILESIZE=100000
HISTSIZE=100000
HISTCONTROL=ignoreboth

# Flush commands to history immediately instead of waiting for logout.
PROMPT_COMMAND='history -a'

if test -e ~/.dircolors; then
    eval "$(dircolors -b ~/.dircolors)"
fi

D=$'\e[37m'
PINK=$'\e[35m'
GREEN=$'\e[32m'
ORANGE=$'\e[33m'
RED=$'\e[31m'
CYAN=$'\e[34m'

function last_return_value() {
    x="$?"
    if test "$x" -ne 0; then
        echo -n "${RED}[$x] ${D}"
    fi
}

function histgrep {
    history | grep "$@" | tac | f 2-
}

if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
  HOST_COLOR="$CYAN"
else
  HOST_COLOR="$ORANGE"
fi

export PS1='\n${PINK}\u ${D}at ${HOST_COLOR}\h ${D}in ${GREEN}\w${D}\n$(last_return_value)$ '

alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ......="cd ../../../../.."

alias js='cd ~/scratch'

alias :q=exit
alias :qa=exit
alias :wqa=exit

if command -v ag >/dev/null; then
    AG_BIN="$(command -v ag)"
    function ag() {
        if test -f '.agignore' && grep -q 'pragma: skipvcs' '.agignore'; then
            $AG_BIN --search-files -U "$@"
        else
            $AG_BIN --search-files "$@"
        fi
    }
fi

export PATH=~/bin:~/src/dotfiles/bin:~/src/dotfiles/lisp/bin:/usr/local/bin/:$PATH
export PAGER=less

function psg() {
    ps auxww | grep --color=always "$@" | grep -v grep | collapse | cuts -f 2,11-
}

GPG_TTY=$(tty)
export GPG_TTY

export EDITOR=nvim