Shell Configs: Difference between revisions

From Leo's Notes
This page was last edited on 28 April 2013, at 00:01.
Created page with "Below is my current bash profile (.bashrc). == Leo's .bashrc == # .bashrc # # Solaris? Bail out using /bin/sh and skip all the # bash fancinesses which applies mostly to l..."
 
Line 3: Line 3:
== Leo's .bashrc ==
== Leo's .bashrc ==


 
# .bashrc
 
# .bashrc
#
# Solaris? Bail out using /bin/sh and skip all the
#
# bash fancinesses which applies mostly to linux.
# Solaris? Bail out using /bin/sh and skip all the
#
# bash fancinesses which applies mostly to linux.
if [ "`uname`" = "SunOS" ] ; then
#
    exec sh
if [ "`uname`" = "SunOS" ] ; then
fi
    exec sh
 
fi
#
# The 'free' command doesn't exist in FreeBSD. Will
#
# run sysctl and show memory information instead.
# The 'free' command doesn't exist in FreeBSD. Will
#
# run sysctl and show memory information instead.
if [ "`uname`" = "FreeBSD" ] ; then
#
    alias free="sysctl hw.physmem"
if [ "`uname`" = "FreeBSD" ] ; then
fi
    alias free="sysctl hw.physmem"
 
fi
#
# Alias vi to vim only if vim exists
#
#
# Alias vi to vim only if vim exists
command -v vim >/dev/null 2>&1
#
if [ $? -eq 0 ] ; then
command -v vim >/dev/null 2>&1
    alias vi=vim
if [ $? -eq 0 ] ; then
fi
    alias vi=vim
 
fi
#
# Aliases to ls and grep with nice options as default
#
#
# Aliases to ls and grep with nice options as default
alias ls="ls --color -F -h"
#
alias grep="grep --color=always --line-buffered"
alias ls="ls --color -F -h"
 
alias grep="grep --color=always --line-buffered"
 


== Details ==
== Details ==

Revision as of 00:01, 28 April 2013

Below is my current bash profile (.bashrc).

Leo's .bashrc

# .bashrc

#
# Solaris? Bail out using /bin/sh and skip all the
# bash fancinesses which applies mostly to linux.
#
if [ "`uname`" = "SunOS" ] ; then
    exec sh
fi

#
# The 'free' command doesn't exist in FreeBSD. Will
# run sysctl and show memory information instead.
#
if [ "`uname`" = "FreeBSD" ] ; then
    alias free="sysctl hw.physmem"
fi

#
# Alias vi to vim only if vim exists
#
command -v vim >/dev/null 2>&1
if [ $? -eq 0 ] ; then
    alias vi=vim
fi

#
# Aliases to ls and grep with nice options as default
#
alias ls="ls --color -F -h"
alias grep="grep --color=always --line-buffered"

Details

ls

The command:

ls --color=always -F -h

Flags:

--color[=auto]

Ensures that the output is colorized only to stdout. We do not want colors to go through pipes. The 'auto' value is implied as it is the default option.

-F

Prints a forward slash on directories.

-h

Prints sizes in human readable form

grep

The command:

grep --color=always --line-buffered

Flags:

--color=always

Ensures output is colored even if not going to stdout. Makes it nice when piping to more or less.

--line-buffered

As I usually deal with lines of texts, this makes piping multiple greps together work properly.