bash configuration
This commit is contained in:
35
bash_aliases
Normal file
35
bash_aliases
Normal file
@@ -0,0 +1,35 @@
|
||||
alias c='echo -n "\033&a0c0R";clear'
|
||||
alias xterm='xterm -rv -fg grey -bg black -sb -sl 2000 &'
|
||||
alias term='aterm -sr -sl 10000 -fg white -bg black &'
|
||||
alias tterm='aterm -tr -trsb -sr -sl 10000 -sh 40 -fg white -bg black &'
|
||||
alias cterm='bterm -tr +scrollBar -sh 40 -fg white -bg black'
|
||||
alias alterm='bterm -tr +scrollBar -sh 80 -fg white -bg black'
|
||||
|
||||
# some more ls aliases
|
||||
alias ll='ls -l'
|
||||
alias l='ls'
|
||||
|
||||
alias mroe='more'
|
||||
alias m='more'
|
||||
|
||||
alias grep='grep --color=auto'
|
||||
|
||||
alias weather='curl -H "Accept-Language: en" http://wttr.in/Lausanne'
|
||||
|
||||
function dias() {
|
||||
n=$1
|
||||
shift
|
||||
ssh diascld$n.iccluster.epfl.ch -A -Y $@
|
||||
}
|
||||
|
||||
function diasrange() {
|
||||
start=$1
|
||||
end=$2
|
||||
shift; shift;
|
||||
for d in $(seq ${start} ${end})
|
||||
do
|
||||
echo diascld$d
|
||||
dias $d -x "$@"
|
||||
echo ------------------------------------------------------------------------------
|
||||
done
|
||||
}
|
||||
7
bash_logout
Normal file
7
bash_logout
Normal file
@@ -0,0 +1,7 @@
|
||||
# ~/.bash_logout: executed by bash(1) when login shell exits.
|
||||
|
||||
# when leaving the console clear the screen to increase privacy
|
||||
|
||||
if [ "$SHLVL" = 1 ]; then
|
||||
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
|
||||
fi
|
||||
117
bashrc
Normal file
117
bashrc
Normal file
@@ -0,0 +1,117 @@
|
||||
# Check for an interactive session
|
||||
[ -z "${PS1}" ] && return
|
||||
|
||||
# don't put duplicate lines in the history. See bash(1) for more options
|
||||
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
|
||||
#export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
|
||||
# ... or force ignoredups and ignorespace
|
||||
export HISTCONTROL=ignoreboth
|
||||
export HISTSIZE=1000
|
||||
|
||||
# append to the history file, don't overwrite it
|
||||
shopt -s histappend
|
||||
|
||||
# check the window size after each command and, if necessary,
|
||||
# update the values of LINES and COLUMNS.
|
||||
shopt -s checkwinsize
|
||||
|
||||
export VISUAL=vi
|
||||
export EDITOR=vi
|
||||
|
||||
case "$TERM" in
|
||||
xterm*) color_prompt=yes;;
|
||||
linux) color_prompt=yes;;
|
||||
*) color_prompt=no;;
|
||||
esac
|
||||
|
||||
#-------------------------------------
|
||||
# Set the PWD to max pwd_length characters
|
||||
function fixprmpt {
|
||||
local pwd_length=20
|
||||
if [ $(echo -n "${PWD}" | wc -c | tr -d ' ') -gt ${pwd_length} ]; then
|
||||
local newPWD="...$(echo -n ${PWD} | sed -e "s/.*\(.\{${pwd_length}\}\)/\1/")"
|
||||
else
|
||||
local newPWD="$(echo -n ${PWD})"
|
||||
fi
|
||||
echo ${newPWD}
|
||||
}
|
||||
|
||||
# Functions & colours used in prompt :
|
||||
#=====================================
|
||||
# define the colors
|
||||
export RESET="\[\033[m\]"
|
||||
export LRED="\[\033[1;31m\]"
|
||||
export LBLUE="\[\033[1;34m\]"
|
||||
export LGREY="\[\033[0;37m\]"
|
||||
export WHITE="\[\033[0;38m\]"
|
||||
export LWHITE="\[\033[1;37m\]"
|
||||
export LGREEN="\[\033[1;32m\]"
|
||||
export LYELLOW="\[\033[1;33m\]"
|
||||
|
||||
#-------------------------
|
||||
# Set prompt in red for root and in green for users
|
||||
# if where are at the console or in an xterm compatible terminal
|
||||
function usercolor {
|
||||
if [ "$color_prompt" = "yes" ]; then
|
||||
if [ 'root' = `id -un` ]; then
|
||||
echo -n ${LRED}
|
||||
else
|
||||
echo -n ${LGREEN}
|
||||
fi
|
||||
else
|
||||
if [ 'root' = `id -un` ]; then
|
||||
echo -n ${LWHITE}
|
||||
else
|
||||
echo -n ${LGREY}
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$color_prompt" = "yes" ]; then
|
||||
PS1="${LBLUE}\$(date '+%H:%M')${LGREY} [$(usercolor)\u${LGREY}@\h:\$(fixprmpt)] \!$LYELLOW>${RESET} "
|
||||
else
|
||||
#PS1="\$(date '+%H:%M') [\u@\h:\$(fixprmpt)] \!> "
|
||||
PS1="${LGREY}\$(date '+%H:%M') ${LWHITE}[$(usercolor)\u${LWHITE}@${LGREY}\h${LWHITE}:${LGREY}\$(fixprmpt)${LWHITE}]${LGREY} \!${LWHITE}>${RESET} "
|
||||
fi
|
||||
|
||||
# enable color support of ls
|
||||
if [ -x /bin/dircolors ]; then
|
||||
eval "`dircolors -b`"
|
||||
alias ls='ls --color=auto'
|
||||
fi
|
||||
|
||||
# Alias definitions.
|
||||
if [ -f ~/.bash_aliases ]; then
|
||||
. ~/.bash_aliases
|
||||
fi
|
||||
|
||||
#colorize stderr
|
||||
function swapandcolorize()
|
||||
{
|
||||
# "$@" 3>&2 2>&1 1>&3 | while read line
|
||||
# do
|
||||
# echo -e "\e[91m$line\e[0m"
|
||||
# done
|
||||
"$@" 3>&2 2>&1 1>&3 | perl -e 'while(<>)
|
||||
{
|
||||
chomp;
|
||||
#Print in LYELLOW and blue background xenomai stuff warning and such
|
||||
if (m/^xenomai.+:\d+:(\d+:)?\s+warning.*/)
|
||||
{print "\033[1;45m".$_."\033[m\n"; next;}
|
||||
|
||||
#Print in DARKBLUE forced warnings
|
||||
if (m/.*\#warning.*/)
|
||||
{print "\033[1;34m".$_."\033[m\n"; next;}
|
||||
#Print in LYELLOW warning and such
|
||||
if (m/.+:\d+:(\d+:)?\s+warning.*/)
|
||||
{print "\033[1;33m".$_."\033[m\n"; next;}
|
||||
#print in LRED errors
|
||||
if (m/.+:\d+:(\d+:)?\s+error.*/ ||
|
||||
m/.+:\d+:(\d+:)? undefined reference to `/)
|
||||
{print "\033[1;31m".$_."\033[m\n"; next;}
|
||||
#Print in default colors
|
||||
{print "\033[m".$_."\n"; next;}
|
||||
};'
|
||||
return ${PIPESTATUS[0]}
|
||||
}
|
||||
export -f swapandcolorize
|
||||
34
profile
Normal file
34
profile
Normal file
@@ -0,0 +1,34 @@
|
||||
# ~/.profile: executed by the command interpreter for login shells.
|
||||
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
|
||||
# exists.
|
||||
# see /usr/share/doc/bash/examples/startup-files for examples.
|
||||
# the files are located in the bash-doc package.
|
||||
|
||||
# the default umask is set in /etc/profile; for setting the umask
|
||||
# for ssh logins, install and configure the libpam-umask package.
|
||||
#umask 022
|
||||
|
||||
# When running bash
|
||||
if [ -n "$BASH_VERSION" ]; then
|
||||
# include .bashrc if it exists
|
||||
if [ -f "$HOME/.bashrc" ]; then
|
||||
. "$HOME/.bashrc"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Add brew
|
||||
if [ -x /opt/homebrew/bin/brew ]; then
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
fi
|
||||
|
||||
# Add ~/bin
|
||||
if [ -e "$HOME/bin" ]; then
|
||||
PATH="$HOME/bin:$PATH"
|
||||
fi
|
||||
|
||||
# Add cargo
|
||||
if [ -e "$HOME/.cargo/bin" ]; then
|
||||
PATH="$HOME/.cargo/bin:$PATH"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user