dotfiles/.bashrc
2017-12-05 20:56:54 +01:00

125 lines
2.9 KiB
Bash

###############################################################################
# File .bashrc
# jul.io
###############################################################################
umask 022
# set PATH so it includes user's private bin if it exists
if [ -d ~/bin ] ; then
PATH="~/bin:${PATH}"
export PATH
fi
# do the same with MANPATH
if [ -d ~/man ]; then
MANPATH=~/man:"${MANPATH}"
export MANPATH
fi
# some programs use a special .dot directory for not
# trashing the home directory with .dotfiles
if [ -d ~/.dot ]; then
DOT=~/.dot
export DOT
fi
export COLORTERM=1
# prefered editor
export EDITOR=vi
# bash history control
export HISTCONTROL=ignoreboth:erasedups
export HISTFILESIZE=
export HISTSIZE=5000
shopt -s histappend
shopt -s cmdhist
# completion
shopt -s cdspell
shopt -s hostcomplete
# If not running interactively, don't do any more
[ -z "$PS1" ] && return
###############################################################################
# running interactively
###############################################################################
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# only linux, not SunOS etc
if [ `uname` == "Linux" ]; then
# enable color support of ls
if [ "$TERM" != "dumb" ]; then
eval `dircolors -b`
alias ls='ls --color'
fi
fi
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
# set a fancy prompt
if [ $UID == 0 ]; then
# root: red
PS_COLOR="\[\033[1;31m\]"
else
# user
PS_COLOR="\[\033[33m\]"
fi
PS1="\t ${PS_COLOR}${debian_chroot:+($debian_chroot)}\u\[\033[0m\]@\h:\w\$ "
# if this is an xterm modify the title
case $TERM in
xterm*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME} $(date +%H:%M:%S) [${PWD}]\007"'
;;
*)
;;
esac
# define your own aliases in ~/.bash_aliases
[ -f ~/.bash_aliases ] && source ~/.bash_aliases
# local bashrc
[ -f ~/.bashrc_local ] && source ~/.bashrc_local
# enable programmable completion features
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# This allows you to bookmark your favorite places across the file system
# Define a variable containing a path and you will be able to cd into it regardless of the directory you're in
shopt -s cdable_vars
# Examples:
# export dotfiles="$HOME/dotfiles"
export projects="$HOME/projects"
export elements="$HOME/elements"
export develop="$HOME/elements/develop"
# ssh using a new window when we are in TMUX
SSHEXEC=$(which ssh)
ssh() {
if [ -n "$TMUX" ]
then
title="$*"
#if [ "$1" = -t ]
#then
# title="$2"
# shift 2
#fi
#if [ "$1" = "stay" ]
#then
# "$SSHEXEC $@"
#else
tmux new-window -n "$title" "$SSHEXEC $( echo $@ | sed 's/stay//')"
#fi
else
$SSHEXEC $@
fi
}