Código
export HISTCONTROL=erasedups HISTIGNORE="fg*:bg*:history*:exit*" shopt -s cdspell shopt -s histappend shopt -s cmdhist # save multi-line commands in history as single line shopt -s mailwarn # Cargar variables personales if [ -f ~/.bash_variables ]; then . ~/.bash_variables fi # Cargar alias if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi # Cargar funciones if [ -f ~/.bash_functions ]; then . ~/.bash_functions fi # Check for an interactive session [ -z "$PS1" ] && return export HISTSIZE=30000 export HISTCONTROL=ignoredups # no duplicate lines in the history. PS1='┌─[$? \u@\h \w]\$\n└─> ' PS2="New line [`date +"%H:%M:%S"`] : " setxkbmap -layout latam complete -cf sudo complete -cf man export escritorio=/home/leo/Desktop export PATH=$PATH:/usr/local/bin export EDITOR="vim" myname="Leonardo Gutiérrez Ramírez";
.bash_aliases
Código
# Mis alias personales. alias ls='ls --color=auto' alias cls='clear' alias cd..='cd ..' alias cd.='pwd' alias ocultos='ls -a1 | grep -i "^[.]"' alias cdesk='cd $HOME/Escritorio' alias folds='ls -d1 */' alias myip='curl icanhazip.com' alias cd-='cd -' alias dwn='cd ~/Descargas' alias files='ls -1F | grep -v ".*/$"' alias pdf='evince' alias _total='du -hsx' alias rm='rm -i' alias l1='ls -1' alias xterm='xterm -font -*-fixed-medium-r-*-*-15-*-*-*-*-*-iso8859-* -geometry 120x88' alias img='eog .' alias ungz='tar zxvf' alias s='ls -1 | grep -i' alias lf='leafpad' alias up='source ~/.bashrc;' #alias pas='sudo pacman-color -S' #alias pacman='pacman' alias grep='grep --color=auto' alias ls='ls --color=auto' alias cdwin='cd /media/windows/' alias rmsecure='bash /usr/local/bin/rmsecure.sh' alias unins='bash /usr/local/bin/unins.sh' alias modins='bash /usr/local/bin/modins.sh' alias _c='bash /usr/local/bin/_c.sh' alias sc='bash /usr/local/bin/sc.sh' alias dn='. /usr/local/bin/dn.sh $1' #alias comando='bash /usr/local/bin/comando.sh; source ~/.bashrc' alias abs='evince /media/descargas/bash/abs-guide.pdf&' alias ttouch='bash /usr/local/bin/ttouch' #alias cdprompt='. /usr/local/bin/cdprompt.sh' alias usb='. /usr/local/bin/usb' alias wiki='perl /usr/local/bin/wiki' #alias t='thunar .' alias pc='pcmanfm .' alias mq='/etc/rc.d/mysqld start' alias v='vim' alias nocomment='egrep -v "^\s*(#|$)"' alias findcontent='grep -HURi' alias cdp='cd "$(ls -d */ | dmenu -l $(ls -d */ | wc -l) -nb "#100" -nf "#b9c0af" -sb "#000" -sf "#afff2f" -i)"' alias ~='cd ~' #alias remove='pacman -R' alias vi='vim' alias :q='exit' alias txtmsn='find ./.purple/logs/msn/leorocko13\@hotmail.com/ -type f -exec cat {} \; | grep -i "$1"' alias emp='cd ~/escuela/administracion/empresa_miercoles/' alias galias='cat ~/.bash_aliases' alias mathematica='mathematica -noSplashscreen' alias cdn='cd ~/NetBeansProjects/' alias logmysql='mysql -u root -plein23 agencia' alias tablas='mysql -u root -plein23 agencia -e "show tables \G" | grep -v "^\*" | sed "s/.*:\s\(.*\)/\1/"' alias soft='cd /media/descargas/Software/' alias mkx='sudo chmod +x $1' alias t='todo' # Apagado y reiniciado: alias reboot='sudo reboot' alias poweroff='sudo poweroff' # Ping a google, útil para checar conexión alias pingg='ping -c 4 google.com' # alias windows linux alias move='mv' alias copy='cp' alias muro='fbcmd mywall' alias estado='fbcmd status $1' alias restado='fbcmd restatus $1' alias notices='fbcmd notices' alias mutuo='fbcmd mutual $1' alias amiwhix='cat ~/.amigos' alias fbon='fbcmd finfo online_presence =all | grep -v "offline" | grep -v "^NAME.*ONLINE_PRESENCE$"' # instalar programa alias sagi='sudo apt-get install' alias th='thunar'
.bash_functions
Código
function ebash { elegido=`ls -1 ~/.bash* | dmenu -l $(ls -1 ~/.bash* | wc -l)` [ -z "$elegido" ] && return vim "$elegido" } function sch { [ ! -d "$HOME/escuela" ] && { echo -e "No existe la carpeta escuela" return; } lines=`find ~/escuela -maxdepth 1 -type d | grep -v "^\.$" | wc -l` cd `find ~/escuela -maxdepth 1 -type d | grep -v "^\.$" | sort | dmenu -l $lines` } # Function para ver los registros de determinada tabla. function verr() { : #BD=$(cat ~/.bash_variables | grep -i "^BD" | cut -f2 -d '=') #n_tablas=$(mysql -u root -plein23 $BD -e "show tables \G" | grep -v "^\*" | wc -l); #mysql -u root -plein23 $BD -e "select * from `mysql -u root -plein23 $BD -e 'show tables' | dmenu -l ${n_tablas}`" | more } # Funcion que cambia la BD definida en el archivo ~/.bashrc function changebd() { : #n_tablas=$(mysql -u root -plein23 agencia -e "show databases \G" | grep -vi "^\*" | sed "s/.*:\s\(.*\)$/\1/g" | wc -l) #BD=$(mysql -u root -plein23 agencia -e "show databases \G" | grep -vi "^\*" | sed "s/.*:\s\(.*\)$/\1/g" | dmenu -l ${n_tablas}) #sed -i "s/^BD=\(.*\)/BD=$BD/" ~/.bash_variables #source ~/.bash_variables } function hacerx() { read -p "Name : " name touch "$name"; sudo chmod +xwr "$name"; } function cddev() { elegido=`cat << EOF | dmenu -l 3 cpps perl bash EOF ` cd /media/descargas/$elegido } function extract() { local c e i (($#)) || return for i; do c='' e=1 if [[ ! -r $i ]]; then echo "$0: file is unreadable: \`$i'" >&2 continue fi case $i in #*.t@(gz|lz|xz|b@(2|z?(2))|a@(z|r?(.@(Z|bz?(2)|gz|lzma|xz))))) #c='bsdtar xvf';; *.7z) c='7z x';; *.Z) c='uncompress';; *.bz2) c='bunzip2';; *.exe) c='cabextract';; *.tar.gz) c='tar xzf';; *.tgz) c='tar zxvf';; *.gz) c='gunzip';; *.rar) c='unrar x';; *.xz) c='unxz';; *.zip) c='unzip';; *) echo "$0: unrecognized file extension: \`$i'" >&2 continue;; esac command $c "$i" e=$? done return $e } function on() { ping -c 1 www.google.com &> /dev/null || { echo -e "\E[31;47mOFFLINE"; sudo dhcpcd tput sgr0; } && { echo -e "\E[31;47mONLINE"; notify-send "ONLINE" tput sgr0; } } function my() { sudo chown -R ${USER} "$1" } function cdl() { cd "$1" ls -1 } function enc() { if [ $# -ne 1 ] then echo -e "`basename $0` file"; exit 1; fi gpg -c "$1" && rm -rvf "$1" } function dec() { if [ $# -ne 1 ] then echo -e "`basename $0` file"; exit 1; fi gpg "$1" && rm -rvf "$1" } function exes() { echo -e "\e[1;31mNúmero de ejecutables : $(find . -maxdepth 1 -type f -iname "*.exe" -print | wc -l)" find . -maxdepth 1 -type f -iname "*.exe" -print tput sgr0 } function f() { cat<<EOF>/tmp/factorial.bc define factorial(n) { i = 1; p = 1; while(i <= n) { p *= i++ } return (p); } n = read(); print n, "! = ", factorial(n), "\n"; quit; EOF echo -e "$1" | bc -ql /tmp/factorial.bc rm -f /tmp/factorial.bc } function dictionary(){ curl -s -A 'Mozilla/4.0' 'http://www.google.com/search?q=define%3A+'$1 | html2text -ascii -nobs -style compact -width 500 | grep "*" | head -n 5 } function mktar() { tar cvf "${1%%/}.tar" "${1%%/}/"; } function mktgz() { tar cvzf "${1%%/}.tar.gz" "${1%%/}/"; } function mktbz() { tar cvjf "${1%%/}.tar.bz2" "${1%%/}/"; } function hgg() { if [ $# -lt 1 ] || [ $# -gt 1 ]; then echo "search bash history" echo "usage: mg [search pattern]" else history | grep -i $1 | grep -v hg fi } function ask() { echo -n "$@" '[y/n] ' ; read ans case "$ans" in y*|Y*) return 0 ;; *) return 1 ;; esac } function box() { t="$1xxxx";c=${2:-#}; echo ${t//?/$c}; echo "$c $1 $c"; echo ${t//?/$c}; } function translate() { wget -qO- "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=$1&langpair=%7C${2:-en}" | sed 's/.*{"translatedText":"\([^"]*\)".*/\1\n/'; } function fp() { find . -type f -iname "$1" -print } function c() { echo -e "$*" | bc -l } # Creates an archive from given directory function mktar() { tar cvf "${1%%/}.tar" "${1%%/}/"; } function mktgz() { tar cvzf "${1%%/}.tar.gz" "${1%%/}/"; } function mktbz() { tar cvjf "${1%%/}.tar.bz2" "${1%%/}/"; } # recursively fix dir/file permissions on a given directory function fix() { if [ -d $1 ]; then find $1 -type d -exec chmod 755 {} \; find $1 -type f -exec chmod 644 {} \; else echo "$1 is not a directory." fi } function safeedit() { cp -vi $1 ${1}.backup && vim $1 } function kk() { read -p "Nombre de archivo > " name cp -vi ~/Escritorio/pl.pl /media/descargas/perl/$name } # Ver foto de perfil de un amigo en facebook localmente, con eog function verfoto() { fbcmd allinfo "$1" | grep "pic_big" | grep "jpg$" | awk '{print $2}' | xargs wget -O "${1}.jpg" eog "${1}.jpg" rm -rvf "${1}.jpg" } function isprime () { perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/' } function cd2iso { dd if=/dev/cdrom of=$1 bs=2048 conv=sync,notrunc } function fbfriends() { fbcmd friends | sed "s/\([0-9]*\)\s\(.*\)/\2/g" | grep -v "^ID.*" 2>&1 | tee ~/.amigos } # Función para imprimir un archivo en pantalla function csg() { cat `ls -1 | grep -i "$1" | dmenu -l $(ls -1 | grep -i "$1" | wc -l)` | more }
Saludos.