summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Sobkowski <maciej.sobkowski@nokia.com>2015-07-02 13:52:25 +0200
committerMaciej Sobkowski <maciej.sobkowski@nokia.com>2015-07-02 13:52:25 +0200
commit0d9fcf8df448db25e8b805b9812f44314ea89936 (patch)
treeb7392df7b20d18e4305322644dc4e03edab83ed4
parent4d87c1d86db2518cc561a008e6315a0897e70ea6 (diff)
Added Bash configuration
-rw-r--r--bash/.bash/aliases/generic.bash5
-rw-r--r--bash/.bash/aliases/ls.bash2
-rw-r--r--bash/.bash/color_codes17
-rw-r--r--bash/.bash/shenv.example4
-rw-r--r--bash/.bash_profile6
-rw-r--r--bash/.bashrc247
6 files changed, 281 insertions, 0 deletions
diff --git a/bash/.bash/aliases/generic.bash b/bash/.bash/aliases/generic.bash
new file mode 100644
index 0000000..ea98e25
--- /dev/null
+++ b/bash/.bash/aliases/generic.bash
@@ -0,0 +1,5 @@
+alias clr="clear"
+alias cls="clear"
+alias c="clear"
+alias v="vim"
+alias ..="cd .."
diff --git a/bash/.bash/aliases/ls.bash b/bash/.bash/aliases/ls.bash
new file mode 100644
index 0000000..4e7fb97
--- /dev/null
+++ b/bash/.bash/aliases/ls.bash
@@ -0,0 +1,2 @@
+alias l="ls -l"
+alias ll="ls -l"
diff --git a/bash/.bash/color_codes b/bash/.bash/color_codes
new file mode 100644
index 0000000..922574b
--- /dev/null
+++ b/bash/.bash/color_codes
@@ -0,0 +1,17 @@
+BLACK="\[\033[0;30m\]"
+RED="\[\033[0;31m\]"
+GREEN="\[\033[0;32m\]"
+BROWN="\[\033[0;33m\]"
+BLUE="\[\033[0;34m\]"
+PURPLE="\[\033[0;35m\]"
+CYAN="\[\033[0;36m\]"
+LIGHT_GRAY="\[\033[0;37m\]"
+DARK_GRAY="\[\033[1;30m\]"
+LIGHT_RED="\[\033[1;31m\]"
+LIGHT_GREEN="\[\033[1;32m\]"
+YELLOW="\[\033[1;33m\]"
+LIGHT_BLUE="\[\033[1;34m\]"
+LIGHT_PURPLE="\[\033[1;35m\]"
+LIGHT_CYAN="\[\033[1;36m\]"
+WHITE="\[\033[1;37m\]"
+PS_CLEAR="\[\033[0m\]"
diff --git a/bash/.bash/shenv.example b/bash/.bash/shenv.example
new file mode 100644
index 0000000..84cc953
--- /dev/null
+++ b/bash/.bash/shenv.example
@@ -0,0 +1,4 @@
+proxy=http://10.144.1.10:8080
+#proxy=plwrprx-fiesprx.glb.nsn-net.net:8081
+
+prompt_color
diff --git a/bash/.bash_profile b/bash/.bash_profile
new file mode 100644
index 0000000..b45e64f
--- /dev/null
+++ b/bash/.bash_profile
@@ -0,0 +1,6 @@
+# .bash_profile
+
+# Get the aliases and functions
+if [ -f ~/.bashrc ]; then
+ . ~/.bashrc
+fi
diff --git a/bash/.bashrc b/bash/.bashrc
new file mode 100644
index 0000000..f8968c7
--- /dev/null
+++ b/bash/.bashrc
@@ -0,0 +1,247 @@
+# Basic variables
+: ${HOME=~}
+: ${LOGNAME=$(id -un)}
+: ${UNAME=$(uname)}
+
+# SSH known hosts
+: ${HOSTFILE=~/.ssh/known_hosts}
+
+# Config for readline
+: ${INPUTRC=~/.inputrc}
+
+# -----------------------------------------------------------------------------
+# Options for shell
+# -----------------------------------------------------------------------------
+
+# If system-wide bashrc exists, bring it in
+test -r /etc/bash.bashrc &&
+ . /etc/bash.bashrc
+
+# notify of background job completion immediately
+set -o notify
+
+# Explanation of used shell options:
+# cdspell - autocorrect minor errors in cd path
+# extglob - enable extended pattern matching
+# histappend - append to HISTFILE insteead of overriding
+# hostcomplete - if readline used, bash will attempt to complete hostnames
+# interactive_comments - if line in prompt begins with #, treat as comment
+# mailwarn - warning when mail file accessed
+# no_empty_cmd_completion - don't attempt to search path for completion if
+# empty line
+shopt -s cdspell >/dev/null 2>&1
+shopt -s extglob >/dev/null 2>&1
+shopt -s histappend >/dev/null 2>&1
+shopt -s hostcomplete >/dev/null 2>&1
+shopt -s interactive_comments >/dev/null 2>&1
+shopt -u mailwarn >/dev/null 2>&1
+shopt -s no_empty_cmd_completion >/dev/null 2>&1
+
+# disable core dumps
+ulimit -S -c 0
+
+# set umask
+umask 0022
+
+# -----------------------------------------------------------------------------
+# Environment configuration
+# -----------------------------------------------------------------------------
+
+# detect interactive shell
+case "$~" in
+ *i*) INTERACTIVE=yes ;;
+ *) unset INTERACTIVE ;;
+esac
+
+# detect login shell
+case "$0" in
+ -*) LOGIN=yes ;;
+ *) unset LOGIN ;;
+esac
+
+# set en_US locale with utf-8
+: ${LANG:="en_US.UTF-8"}
+: ${LANGUAGE:="en"}
+: ${LC_CTYPE:="en_US.UTF-8"}
+: ${LC_ALL:="en_US.UTF-8"}
+export LANG LANGUAGE LC_CTYPE LC_ALL
+
+# use PASSIVE ftp mode
+: ${FTP_PASSIVE:=1}
+export FTP_PASSIVE
+
+# ignore python bytecode, vim swap files
+FIGNORE=".pyc:.swp:.swa:.swo"
+
+# history related variables
+export HISTCONTROL=ignoreboth
+export HISTFILESIZE=50000
+export HISTSIZE=50000
+export HISTIGNORE='ls:bg:fg:history'
+export PROMPT_COMMAND='history -a'
+
+# -----------------------------------------------------------------------------
+# Pager/editor settings
+# -----------------------------------------------------------------------------
+
+HAVE_GVIM=$(command -v gvim)
+HAVE_VIM=$(command -v vim)
+
+# editor
+test -n "$HAVE_VIM" &&
+EDITOR=vim ||
+EDITOR=vi
+export EDITOR
+
+# pager
+if test -n "$(command -v less)"; then
+ PAGER="less -FirSwX"
+ MANPAGER="less -FirSwX"
+else
+ PAGER=more
+ MANPAGER=more
+fi
+
+if test -n "$HAVE_VIM"; then
+ export MANPAGER="/bin/sh -c \"col -b | vim -c 'set ft=man ts=8 nomod nolist nonu noma' -\""
+fi
+
+# -----------------------------------------------------------------------------
+# Prompt
+# -----------------------------------------------------------------------------
+
+# Base16 Shell
+BASE16_SHELL="$HOME/.config/base16-shell/base16-default.dark.sh"
+[[ -s $BASE16_SHELL ]] && source $BASE16_SHELL
+
+# load color codes
+test -r ~/.bash/color_codes &&
+ . ~/.bash/color_codes
+
+# set colors according to username
+if [ "$LOGNAME" = "root" ]; then
+ COLOR1="${RED}"
+ COLOR2="${BROWN}"
+ P="#"
+else
+ COLOR1="${LIGHT_GREEN}"
+ COLOR2="${BROWN}"
+ P="\$"
+fi
+
+prompt_simple() {
+
+ unset PROMPT_COMMAND
+ PS1="[\u@\h:\w] ${P} "
+ PS2="${P} "
+
+}
+
+jobscount() {
+ local stopped='$(jobs -s | wc -l | tr -d " ")'
+ local running='$(jobs -r | wc -l | tr -d " ")'
+ echo -n "${running}r/${stopped}s"
+ }
+
+prompt_color() {
+
+ PS1="${BLUE}[${GREEN}\T${BLUE}][${YELLOW}\u${GREY}@${PURPLE}\h${GREY}:${CYAN}\W${BLUE}][${RED}\j${BLUE}]${BROWN}$P${PS_CLEAR} "
+ PS2="${P} "
+
+}
+
+
+# -----------------------------------------------------------------------------
+# Ls and dircolors
+# -----------------------------------------------------------------------------
+
+# always passed to ls
+LS_COMMON="-hBG"
+
+# if dircolors tool available, set it up
+dircolors="$(type -P gdircolors dircolors | head -1)"
+
+# -----------------------------------------------------------------------------
+# Bash completion
+# -----------------------------------------------------------------------------
+
+for f in /usr/local/etc/bash_completion/* \
+ /etc/bash_completion/* \
+ ~/.bash/completion/*
+do
+
+ if [ -f $f ]; then
+ . $f
+ fi
+done
+
+# override and disable tilde expansion
+_expand() {
+return 0
+}
+
+# -----------------------------------------------------------------------------
+# Aliases
+# -----------------------------------------------------------------------------
+
+for f in ~/.bash/aliases/*
+do
+ if [ -f $f ]; then
+ . $f
+ fi
+done
+
+# -----------------------------------------------------------------------------
+# Proxy related functions
+# -----------------------------------------------------------------------------
+
+function proxy_on() {
+
+ export http_proxy=$proxy
+ export https_proxy=$proxy
+ export ftp_proxy=$proxy
+ export rsync_proxy=$proxy
+ return 0
+
+}
+
+function proxy_off() {
+
+ unset http_proxy
+ unset https_proxy
+ unset ftp_proxy
+ unset rsync_proxy
+
+}
+
+# -----------------------------------------------------------------------------
+# Archive extracting function
+# -----------------------------------------------------------------------------
+
+extract () {
+ if [ -f $1 ] ; then
+ case $1 in
+ *.tar.bz2) tar xjf $1 ;;
+ *.tar.gz) tar xzf $1 ;;
+ *.bz2) bunzip2 $1 ;;
+ *.rar) rar x $1 ;;
+ *.gz) gunzip $1 ;;
+ *.tar) tar xf $1 ;;
+ *.tbz2) tar xjf $1 ;;
+ *.tgz) tar xzf $1 ;;
+ *.zip) unzip $1 ;;
+ *.Z) uncompress $1 ;;
+ *) echo "'$1' cannot be extracted via extract()" ;;
+ esac
+ else
+ echo "'$1' is not a valid file"
+ fi
+}
+
+# -----------------------------------------------------------------------------
+# Personal configuration
+# -----------------------------------------------------------------------------
+
+# load shenv file - personal configuration
+test -r ~/.bash/shenv &&
+ . ~/.bash/shenv