Jumat, 16 Mei 2014

learn-code .bashrc

apa sih bashrc itu?
pengguna linux pasti udah ga asing lagi dengan bashrc
yap bashrc adalah sebuah file linux yang di eksekusi ketika membuka terminal
misalnya
ketika awal membuka terminal langsung ada bacaan root@ubuntu : #
tapi kalo ini ada sedikit di beri tulisan "selamat datang" atau tulisan "abay ganteng" (hahay) kan bisa aja
ok langsung aja
bashrc ini adalah hasil buatan ane
ya walaupun banyak inspirasi dari forum dan juga google
akhirnya jadilah bashrc yang cupu ini
kira kira seperti ini lah setelah di modif bashrcnya
ok langsung ke scriptnya
buka file .bashrc nya
biasanya ada di home 
lalu paste script berikut

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# mod by abaywashere
# http://learn-code.or.id
# abay@learn-code.or.id
# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries.
export HISTCONTROL=ignoreboth

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color)
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    ;;
*)
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    ;;
esac

# Comment in the above and uncomment this below for a color prompt
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
    ;;
*)
    ;;
esac

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

#if [ -f ~/.bash_aliases ]; then
#    . ~/.bash_aliases
#fi

# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
    eval "`dircolors -b`"
    alias ls='ls --color=auto'
    #alias dir='ls --color=auto --format=vertical'
    #alias vdir='ls --color=auto --format=long'
fi

# some more ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

# Colors

Black="$(tput setaf 0)"
BlackBG="$(tput setab 0)"
DarkGrey="$(tput bold ; tput setaf 0)"
LightGrey="$(tput setaf 7)"
LightGreyBG="$(tput setab 7)"
White="$(tput bold ; tput setaf 7)"
Red="$(tput setaf 1)"
RedBG="$(tput setab 1)"
LightRed="$(tput bold ; tput setaf 1)"
Green="$(tput setaf 2)"
GreenBG="$(tput setab 2)"
LightGreen="$(tput bold ; tput setaf 2)"
Brown="$(tput setaf 3)"
BrownBG="$(tput setab 3)"
Yellow="$(tput bold ; tput setaf 3)"
Blue="$(tput setaf 4)"
BlueBG="$(tput setab 4)"
LightBlue="$(tput bold ; tput setaf 4)"
Purple="$(tput setaf 5)"
PurpleBG="$(tput setab 5)"
Pink="$(tput bold ; tput setaf 5)"
Cyan="$(tput setaf 6)"
CyanBG="$(tput setab 6)"
LightCyan="$(tput bold ; tput setaf 6)"
NC="$(tput sgr0)"       # No Color

# Functions

spin ()
{
echo -ne "$White-"
echo -ne "$LightGray\b|"
echo -ne "$LightGreen\bx"
sleep .02
echo -ne "$LightBlue\b+$RC"
}

welcome ()
{
sleep .02
echo -ne "$LightGreen L"
sleep .02
echo -ne o
sleep .02
echo -ne g
sleep .02
echo -ne i
sleep .02
echo -ne n
sleep .02
echo -ne " "
sleep .02
echo -ne t
sleep .02
echo -ne o
sleep .02
echo -ne " "
sleep .02
echo -ne s
sleep .02
echo -ne y
sleep .02
sleep .02
echo -ne s
sleep .02
echo -ne t
sleep .02
echo -ne e
sleep .02
echo -ne m
sleep .02
echo -ne " "
sleep .02
}

login()
{
sleep .2
echo -ne "$LightGreen L"
sleep .2
echo -ne o
sleep .2
echo -ne g
sleep .2
echo -ne i
sleep .2
echo -ne n
sleep .2
echo -ne " "
sleep .2
}
password()
{
sleep .2
echo -ne "$LightGreen P"
sleep .2
echo -ne a
sleep .2
echo -ne s
sleep .2
echo -ne s
sleep .2
echo -ne w
sleep .2
echo -ne o
sleep .2
echo -ne r
sleep .2
echo -ne d
sleep .2
echo -ne " "
sleep .5
}
logedin()
{
sleep .2
echo -ne "$Red Loged in"
sleep .5
echo -ne "$LightGreen ."
sleep .5
echo -ne .
sleep .5
echo -ne .
sleep .2
}
sukses()
{
sleep .1
echo -ne "$LightGreen L"
sleep .1
echo -ne o
sleep .1
echo -ne g
sleep .1
echo -ne i
sleep .1
echo -ne n
sleep .1
echo -ne " "
sleep .1
echo -ne s
sleep .1
echo -ne u
sleep .1
echo -ne c
sleep .1
echo -ne c
sleep .1
echo -ne e
sleep .1
echo -ne s
sleep .1
echo -ne s
sleep .1
echo -ne " "
sleep .1
}
spasi()
{
sleep .1
echo -ne " "
}
# Welcome screen

clear;
echo -e "";
for i in `seq 1 15` ; do spin; done; welcome; for i in `seq 1 15` ; do spin; done ;echo "";
echo "";
echo -e "";
login;for i in `seq 1 5`;do spasi;done;echo ": $LightBlue$USER";
password;for i in `seq 1 2`;do spasi;done;echo ":";
echo "";
logedin;
echo "";
echo -ne "$LightGreen Welcome $USER"
echo ""; sleep .3;
echo "";
for i in `seq 1 16` ; do spin; done; sukses; for i in `seq 1 16` ; do spin; done ;echo "";
echo ""; sleep .3;
echo "";
# Fancy bash

PS1='\[$LightBlue\]\[$LightGreen\]\u\[$LightBlue\]@\[$LightGreen\]\h\[$LightBlue\]:\[$LightGreen\]\w\[$LightBlue\]\$\[$NC\] '

lalu save,dan buka kembali terminal mu dan lihatlah hasilnya
semoga bermanfaat


0 komentar:

Posting Komentar