Android
Kumpulan bash.bashrc Termux Keren
Selamat Pagi Semua
Sesuai judul di atas kali ini saya ingin membagikan kode bash.bashrc yang menurut ane keren abis, bash.bashrc ini saya dapatkan dari berbagai sumber yang tentu nya saya modif sedikit agar ramah pada termux agan.
Sebelum kita mulai alangkah baiknya kalo kita backup terlebih dahulu bash.bashrc kita.
cd ../usr/etc
cat bash.bashrc > bash.bashrc.backup
Ok langsung saja kita lanjut ke kode bash.bashrc nya
Kumpulan bash.bashrc Untuk Termux
Tampilan
if [ -x /data/data/com.termux/files/usr/libexec/termux/command-not-found ]; then
command_not_found_handle() {
/data/data/com.termux/files/usr/libexec/termux/command-not-found "$1"
}
fi
#!/bin/bash
#------------------------------------------////
# Last Modified 9 Jan 2019 by @NgopiTruk
# Running on Termux 0.6
#------------------------------------------////
#------------------------------------------////
# Colors:
#------------------------------------------////
black='\e[0;30m'
blue='\e[0;34m'
green='\e[0;32m'
cyan='\e[0;36m'
red='\e[0;31m'
purple='\e[0;35m'
brown='\e[0;33m'
lightgray='\e[0;37m'
darkgray='\e[1;30m'
lightblue='\e[1;34m'
lightgreen='\e[1;32m'
lightcyan='\e[1;36m'
lightred='\e[1;31m'
lightpurple='\e[1;35m'
yellow='\e[1;33m'
white='\e[1;37m'
nc='\e[0m'
#------------------------------------------////
# Aliases:
#------------------------------------------////
#alias myip='curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
alias findbig='find . -type f -exec ls -s {} \; | sort -n -r | head -5'
#alias ps='my_ps'
alias ports='netstat -nape --inet'
alias ping='ping -c 6'
alias ns='netstat -alnp --protocol=inet'
alias ls='ls -aF --color=always'
alias la='ls -Al'
alias lx='ls -lXB'
alias lk='ls -lSr'
alias lc='ls -lcr'
alias lu='ls -lur'
alias lr='ls -lR'
alias lt='ls -ltr'
alias lm='ls -al |more'
alias rm='rm -rf'
#------------------------------------------////
# Functions and Scripts:
#------------------------------------------////
localnet ()
{
/sbin/ifconfig | awk /'inet addr/ {print $2}'
echo ""
/sbin/ifconfig | awk /'Bcast/ {print $3}'
echo ""
}
upinfo ()
{
echo -ne "${green}$HOSTNAME ${red}uptime is ${green} \t ";uptime | awk /'up/ {print $3,$4,$5,$6,$7,$8,$9,$10}'
}
cd()
{
if [ -n "$1" ]; then
builtin cd "$@" && ls
else
builtin cd ~ && ls
fi
}
#------------------------------------------////
# Some original .bashrc contents:
#------------------------------------------////
# 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
# 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 identify\e[1;32ming 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
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]anher@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
#------------------------------------------////
# Prompt:
#------------------------------------------////
#PS1='\e[0;36m\h\[\e[0;36m\] \w \[\033[00m\] $ \[\033[00m\] '
PS1='\033[01;32m\u\[\033[01;32m\]@\[\033[01;32m\]\h\[\033[00;32m\]{\[\033[01;32m\]\w\[\033[01;32m\]}\[\033[01;32m\]:\[\033[00m\] '
#PS1='\e[0;36m\W\@ \$\e[m '
#if [ `id -un` != root ]; then
#PS1="[${EGR}\u@\h${EBL} \W${NONE}]# "
#else
#PS1="[${ERD}\h${EBL} \W${NONE}]# "
#fi
#------------------------------------------////
#------------------------------------------////
clear
echo -e "${lightgreen}";figlet "Ngopi Truk";
echo "================= http://petruk-internet.blogspot.com ================"
echo -ne "${lightgreen}Today is:\t\t${red}" `date`; echo ""
echo -e "${lightgreen}Kernel Information: \t${red}" `uname -smr`
echo -ne "${lightgreen}";upinfo;echo ""
echo "Petruk Squad"
echo ""the quieter you become, the more you able to hear""
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
Tampilan
Kode program
#!/bin/bash#------------------------------------------////
# Lapbox ~/.bashrc file
# Last Modified 1 Oktober January 2019
# Modified By Ngopi Truk
# Running on Termux v0.65
#------------------------------------------////
#------------------------------------------////
# Colors:
#------------------------------------------////
if [ -x /data/data/com.termux/files/usr/libexec/termux/command-not-found ]; then
command_not_found_handle() {
/data/data/com.termux/files/usr/libexec/termux/command-not-found "$1"
}
fi
black='\e[0;30m'
blue='\e[0;34m'
green='\e[0;32m'
cyan='\e[0;36m'
red='\e[0;31m'
purple='\e[0;35m'
brown='\e[0;33m'
lightgray='\e[0;37m'
darkgray='\e[1;30m'
lightblue='\e[1;34m'
lightgreen='\e[1;32m'
lightcyan='\e[1;36m'
lightred='\e[1;31m'
lightpurple='\e[1;35m'
yellow='\e[1;33m'
white='\e[1;37m'
nc='\e[0m'
#------------------------------------------////
# Proxy:
#------------------------------------------////
#http_proxy=http://127.0.0.1:8118/
#HTTP_PROXY=$http_proxy
#export http_proxy HTTP_PROXY
#------------------------------------------////
# Aliases:
#------------------------------------------////
## make ls list by size
##alias ls='du -s */* | sort -n'
alias findbig='find . -type f -exec ls -s {} \; | sort -n -r | head -5'
alias tunes='rhythmbox'
alias ports='netstat -nape --inet'
alias opennet='lsof -i'
alias ping='ping -c 4'
alias ns='netstat -alnp --protocol=inet'
alias search='aptitude search'
alias show='aptitude show'
alias ls='ls -aF --color=always'
alias la='ls -Al'
alias lx='ls -lXB'
alias lk='ls -lSr'
alias lc='ls -lcr'
alias lu='ls -lur'
alias lr='ls -lR'
alias lt='ls -ltr'
alias lm='ls -al |more'
alias ll='ls -alF'
alias l='ls -CF'
alias k='kill -9 %'
#alias rm='rm -i'
#------------------------------------------////
# Functions and Scripts:
#------------------------------------------////
localnet ()
{
/sbin/ifconfig | awk /'inet addr/ {print $2}'
echo ""
/sbin/ifconfig | awk /'Bcast/ {print $3}'
echo ""
}
upinfo ()
{
echo -ne "${green}$HOSTNAME ${red}uptime is ${cyan} \t ";uptime | awk /'up/ {print $3,$4,$5,$6,$7,$8,$9,$10}'
}
cd()
{
if [ -n "$1" ]; then
builtin cd "$@" && ls
else
builtin cd ~ && ls
fi
}
encrypt ()
{
gpg -ac --no-options "$1"
}
decrypt ()
{
gpg --no-options "$1"
}
extract()
{
if [ -f "$1" ] ; then
case "$1" in
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.tar.Z) tar xzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.jar) unzip "$1" ;;
*.tar) tar xf "$1" ;;
*.tbz2) tar xjf "$1" ;;
*.tgz) tar xzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*) echo "'$1' cannot be extracted." ;;
esac
else
echo "'$1' is not a file."
fi
}
#------------------------------------------////
# Some original .bashrc contents:
#------------------------------------------////
# 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
# 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
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
#------------------------------------------////
# Prompt:
#------------------------------------------////
PS1='\[\033[01;32m\]\u\[\033[01;34m\]@\[\033[01;31m\]\h\[\033[00;34m\]{\[\033[01;34m\]\w\[\033[00;34m\]}\[\033[01;32m\]:\[\033[00m\]'
#------------------------------------------////
# System Information:
#------------------------------------------////
clear
echo -e "${LIGHTGRAY}";figlet "Ngopi Truk";
echo -ne "${red}Today is:\t\t${cyan}" `date`; echo ""
echo -e "${red}Kernel Information: \t${cyan}" `uname -smr`
echo -ne "${cyan}";upinfo;echo ""
echo -e "${cyan}"; cal -3
#------------------------------------------////
# Git Show Brach:
#------------------------------------------////
function color_my_prompt {
local __user_and_host="\[\033[01;32m\]\u@\h"
local __cur_location="\[\033[01;34m\]\w"
local __git_branch_color="\[\033[31m\]"
#local __git_branch="\`ruby -e \"print (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(\1) ')\"\`"
local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`'
local __prompt_tail="\[\033[35m\]$"
local __last_color="\[\033[00m\]"
export PS1="$__user_and_host $__cur_location $__git_branch_color$__git_branch$__prompt_tail$__last_color "
}
color_my_prompt
Tampilan
Kode Program
[ -z "$PS1" ] && return
# Bash completion
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
# Define a few Colours
BLACK='\e[0;30m'
BLUE='\e[0;34m'
GREEN='\e[0;32m'
CYAN='\e[0;36m'
RED='\e[0;31m'
PURPLE='\e[0;35m'
BROWN='\e[0;33m'
LIGHTGRAY='\e[0;37m'
DARKGRAY='\e[1;30m'
LIGHTBLUE='\e[1;34m'
LIGHTGREEN='\e[1;32m'
LIGHTCYAN='\e[1;36m'
LIGHTRED='\e[1;31m'
LIGHTPURPLE='\e[1;35m'
YELLOW='\e[1;33m'
WHITE='\e[1;37m'
NC='\e[0m' # No Color
# 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)"
###############
### aliases ###
###############
# General
alias df='df -h'
alias h='history'
alias sd='cd /sdcard'
alias duck='du -skc * | sort -rn'
alias nb='nano ../usr/etc/bash.bashrc'
# System info
alias cpuu="ps -e -o pcpu,cpu,nice,state,cputime,args --sort pcpu | sed '/^ 0.0 /d'"
alias memu='ps -e -o rss=,args= | sort -b -k1,1n | pr -TW$COLUMNS'
alias pg='ps aux | grep' #requires an argument
# interactive
alias cp='cp -vi'
alias mv='mv -vi'
alias rm='mv --target-directory=$HOME/.Trash/'
# Directory navigation aliases
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
# listings
alias ls='ls --color=auto'
alias lh='ls -lah' # human readable (sizes) long and all ;-)
alias lls='ls -l -h -g -F --color=auto'
alias lc='ls -aCF'
alias lsam='ls -am' # List files horizontally
alias lr='ls -lR' # recursive
alias lsx='ls -ax' # sort right to left rather then in columns
alias lss='ls -shAxSr' # sort by size
alias lt='ls -lAtrh' # sort by date and human readable
alias lm='ls -al |more' # pipe through 'more'
# chmod and permissions commands
alias mx='chmod a+x'
alias 000='chmod 000'
alias 644='chmod 644'
alias 755='chmod 755'
# WELCOME SCREEN
#######################################################
clear
echo -ne "${LIGHTGREEN}" "Hello, `whoami`. today is, "; date
echo -e "${WHITE}"; cal ;
echo -ne "${CYAN}";
echo -ne "${LIGHTPURPLE}Sysinfo:";uptime ;echo ""
# NOTES
#######################################################
# To temporarily bypass an alias, we preceed the command with a \
# EG: the ls command is aliased, but to use the normal ls command you would
# type \ls
#################
### FUNCTIONS ###
#################
function ff { find . -name $@ -print; }
function rmd { rm -fr $@; }
function osr { shutdown -r now; }
function osh { shutdown -h now; }
function mfloppy { mount /dev/fd0 /mnt/floppy; }
function umfloppy { umount /mnt/floppy; }
function mdvd { mount -t iso9660 -o ro /dev/dvd /mnt/dvd; }
function umdvd { umount /mnt/dvd; }
function mcdrom { mount -t iso9660 -o ro /dev/cdrom /mnt/cdrom; }
function umcdrom { umount /mnt/cdrom; }
function psa { ps aux $@; }
function psu { ps ux $@; }
function dub { du -sclb $@; }
function duk { du -sclk $@; }
function dum { du -sclm $@; }
function dfk { df -PTak $@; }
function dfm { df -PTam $@; }
function dfh { df -PTah $@; }
function dfi { df -PTai $@; }
# SPECIAL FUNCTIONS
#######################################################
# clock - A bash clock that can run in your terminal window.
clock ()
{
while true;do clear;echo "===========";date +"%r";echo "===========";sleep 1;done
}
netinfo ()
{
echo "--------------- Network Information ---------------"
/sbin/ifconfig | awk /'inet addr/ {print $2}'
echo ""
/sbin/ifconfig | awk /'Bcast/ {print $3}'
echo ""
/sbin/ifconfig | awk /'inet addr/ {print $4}'
# /sbin/ifconfig | awk /'HWaddr/ {print $4,$5}'
echo "---------------------------------------------------"
}
# Define a word - USAGE: define dog
define ()
{
lynx -dump "http://www.google.com/search?hl=en&q=define%3A+${1}&btnG=Google+Search" | grep -m 3 -w "*" | sed 's/;/ -/g' | cut -d- -f1 > /tmp/templookup.txt
if [[ -s /tmp/templookup.txt ]] ;then
until ! read response
do
echo "${response}"
done < /tmp/templookup.txt
else
echo "Sorry $USER, I can't find the term \"${1} \""
fi
\rm -f /tmp/templookup.txt
}
#####################################
# ##### ENVIRONMENT VARIABLES ##### #
#####################################
declare -x HISTFILE=~/.bash_history
declare -x HISTCONTROL=ignoredups
declare -x HISTFILESIZE=100000
declare -x HISTSIZE=100000
############################## ##################################
# ##### PROMPT SECTION ##### ####################################
############################## ##################################
##PS1="\[ [32m\]\u:\w > \[ [39m\]"
##PS1="\[ [31m\][\[ [32m\]\u\[ [31m\]]\[ [32m\]\w > \[ [39m\]"
#PS1="\[ [40;1;31m\][\[ [1;32m\]\u\[ [1;31m\]]\[ [49;1;32m\]\w > \[ [22;39m\]"
#PS1="\[ [1;31m\][\[ [1;32m\]\[ [47m\]\u\[ [1;31m\]\[ [49m\]]\[ [1;32m\]\w > \[ [22;39m\]"
##PS1="\[ [31m\][\[ [36m\]\u\[ [31m\]]\[ [36m\]\w > \[ [39m\]"
#PS1="\[ [32m\]\u \[ [39m\]\$\[ [32m\] \w \[ [39m\]"
###################### the above is a separate prompt which can be used instead of below. NOTE: only ONE line at a time should be uncommented. so there are 6 different prompts above!!!!!
# color_name='\[\033[ color_code m\]'
rgb_restore='\[\033[00m\]'
rgb_black='\[\033[00;30m\]'
rgb_firebrick='\[\033[00;31m\]'
rgb_red='\[\033[01;31m\]'
rgb_forest='\[\033[00;32m\]'
rgb_green='\[\033[01;32m\]'
rgb_brown='\[\033[00;33m\]'
rgb_yellow='\[\033[01;33m\]'
rgb_navy='\[\033[00;34m\]'
rgb_blue='\[\033[01;34m\]'
rgb_purple='\[\033[00;35m\]'
rgb_magenta='\[\033[01;35m\]'
rgb_cadet='\[\033[00;36m\]'
rgb_cyan='\[\033[01;36m\]'
rgb_gray='\[\033[00;37m\]'
rgb_white='\[\033[01;37m\]'
rgb_std="${rgb_white}"
if [ `id -u` -eq 0 ]
then
rgb_usr="${rgb_red}"
else
rgb_usr="${rgb_green}"
fi
[ -n "$PS1" ] && PS1="${rgb_usr}`whoami`${rgb_std} \W ${rgb_usr}\\\$${rgb_restore} "
unset rgb_restore \
rgb_black \
rgb_firebrick \
rgb_red \
rgb_forest \
rgb_green \
rgb_brown \
rgb_yellow \
rgb_navy \
rgb_blue \
rgb_purple \
rgb_magenta \
rgb_cadet \
rgb_cyan \
rgb_gray \
rgb_white \
rgb_std \
rgb_usr
Ok Saya Rasa Cukup Sekian Dulu, Semoga Bermanfaat Sekian Dan Terima Kasih.




Post a Comment
0 Comments