Bueno, empiezo por poner mi .bashrc
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
# 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'
# Facebook
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
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.
~/.bashrc
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
#Settings
PS1="\033[1;36m\]┌─[\[\e[37;1m\]\u@\[\e[37;1m\]\H\[\033[1;36m\]]\[\033[1;36m\]─[\[\033[36;1m\]\w\[\033[1;36m\]]\n\[\033[1;36m\]└─> \[\e[0m\]"
export HISTCONTROL=ignoredups:ignorespace
export HISTSIZE=1000
export HISTFILESIZE=3000
export EDITOR="vim"
export BROWSER="/usr/bin/opera"
shopt -s checkwinsize
shopt -s histappend
#Alias
alias color="~/Scripts/color.sh"
alias ls="ls --color=auto"
alias otf2tff="~/Scripts/otf2ttf.sh"
alias limpiar="~/Scripts/limpiar.sh"
#TTYcolor
if [ "$TERM" = "linux" ]; then
echo -en "\e]P0000000" #black
echo -en "\e]P85F5F5F" #grey
echo -en "\e]P1935D73" #darked
echo -en "\e]P9973D61" #red
echo -en "\e]P25D927D" #darkgreen
echo -en "\e]PA97B292" #green
echo -en "\e]P3048992" #brown
echo -en "\e]PB6EB4BF" #yellow
echo -en "\e]P46F8CB2" #darkblue
echo -en "\e]PC819ABF" #blue
echo -en "\e]P58350A9" #darkmagenta
echo -en "\e]PD7D5D92" #magenta
echo -en "\e]P64F6784" #darkcyan
echo -en "\e]PE6F7B8E" #cyan
echo -en "\e]P7ADC6C9" #lightgrey
echo -en "\e]PFD0CCCC" #white
clear
fi
~/.vimrc
set mouse=a
set autoindent
set smartindent
set nocompatible
set number
syntax on
set ic
set hls
set incsearch
set history=500
set smarttab
set shiftwidth=4
set shortmess+=I
set nobackup
map ,n :tabnew
map ,1 :tabprevious
map ,2 :tabnext
map ,m :tabmove
map ,f :tabfind
colorscheme ir_black
set tabstop=4
set nowrap
set spelllang=es
map <f5> :NERDTreeToggle<cr>
Salu2
Gracias.
Tal parece que a nadie le gusta sacarle partido al shell.
Perdona mi ignorancia pero que es eso y para que me sirve o que ventajas me trae hacerlo o editarlo ? :xD
Saludos
Si eres de usar el shell o la consola, puedes crear funciones para controlar tu entorno, borrar archivos, obtener información de X cosa, lo que sea, la única limitación es tu imaginación.
El archivo .bashrc es un archivo que contiene comandos o configuraciones que se ejecutan cuando haces abres la consola. Los alias como su nombre lo indica son alias u otros nombres para los comandos, es decir:
alias sagi='sudo apt-get install'
Tecleando sagi en la consola es como si pusieras "sudo apt-get install", puedes automatizar todo lo que quieras.
Puedes crear tus propias funciones, yo puse algunas interesantes, como descargar una imagen de perfil de X amigo en Facebook para luego visualizarla con el visualizador (valga la redundancia) eog de GNOME.
En fin, si estás en GNU/Linux es obligado que sepas como trabajan dichos archivos.
Todavía no he tenido tiempo entre examenes y otras cosas como para ponerme más en serio a ello T_T mi bashrc "básico"
archey3
# Check for an interactive session
#[ -z "$PS1" ] && return
alias ls='ls --color=auto '
alias todo='todo.sh '
alias archey='archey3 '
alias cdakai='cd /media/Akai-Data '
alias cower='cower --color=always --target=/home/akai/build '
alias pacmans='sudo pacman-color '
alias pacman='pacman-color '
alias actualitzar='sudo pacman-color -Syyu && cower -u -dd '
alias axel='axel -n 4 -v -a '
alias sudo='sudo '
export CHROOTDIR=/opt/archroot
export PATH=$PATH:/home/akai/scripts
export EDITOR=nano
# Colour Codes
export Cyan="\[\e[m\]\[\e[0;36m\]"
export Red="\[\e[m\]\[\e[0;31m\]"
export White="\[\e[m\]\[\e[1;37m\]"
export LightCyan="\[\e[m\]\[\e[1;36m\]"
export LightRed="\[\e[m\]\[\e[1;31m\]"
# Code for a cool Prompt
function pre_prompt
{
newPWD="${PWD}"
user="whoami"
host=$(echo -n $HOSTNAME | sed -e "s/[\.].*//")
datenow=$(date "+%a, %d %b %y")
let promptsize=$(echo -n "--($user@$host ddd, DD mmm YY)---(${PWD})---" \
| wc -c | tr -d " ")
width=$(tput cols)
if [ `id -u` -eq 0 ]
then
let fillsize=${width}-${promptsize}+1
else
let fillsize=${width}-${promptsize}-1
fi
fill=""
while [ "$fillsize" -gt "0" ]
do
fill="${fill}─"
let fillsize=${fillsize}-1
done
if [ "$fillsize" -lt "0" ]
then
let cutt=3-${fillsize}
newPWD="...$(echo -n $PWD | sed -e "s/\(^.\{$cutt\}\)\(.*\)/\2/")"
fi
}
# Set prompt colour
if [ `id -u` -eq 0 ]
then
cText="${LightRed}"
cBorder="${Red}"
else
cText="${LightCyan}"
cBorder="${Cyan}"
fi
PROMPT_COMMAND=pre_prompt
# Display Prompt
PS1="${cBorder}┌─(${White}\u@\h \$(date \"+%a, %d %b %y\")${cBorder})─\${fill}─(${cText}\$newPWD\
${cBorder})────┐\n${cBorder}└─(${cText}\$(date \"+%H:%M\")${cBorder})─>${White}"
por si alguien tiene curiosidad de saber en qué resulta el archey3 o el prompt, dejo una imagen.
(http://ompldr.org/tOTlocQ) (http://ompldr.org/vOTlocQ)
PD: si, editor nano, todavía no he tenido tiempo para introducirme en el arte del vim-fu
PD2; LA versión extraña del kernel, es el resultado de estar bisectando para encontrar en qué punto ha petado el driver de las gráficas intel >,< de normal es 2.6.39-ARCH o 2.6.39-pf, dependiendo de qué kernel use.
Se ve bastante bien, yo tengo un prompt parecido, pero en vez de la fecha puse el valor de retorno del comando anterior.
┌─[0 leo@leo-945GCT-M ~]$
└─> jkasd
jkasd: orden no encontrada
┌─[127 leo@leo-945GCT-M ~]$
└─>
Algun manual o tutorial que recomienden para aprender a crea mi propio bashrc y para personalizar mi prompt :xD
@j3d1:
Busca en google sobre ello, seguro que encontrarás muchísima documentación ahí. Lo básico es que no deja de ser otro fichero en shell script
Cita de: Leo Gutiérrez. en 28 Junio 2011, 20:52 PM
Se ve bastante bien, yo tengo un prompt parecido, pero en vez de la fecha puse el valor de retorno del comando anterior.
No lo había pensado. Tengo la impresión que lo voy a incorporar.
Tan sencillo como poner "$?" y listo.
En mi caso el prompt es asi
┌─[exeu@archlinux]-[~]
└─> asdf
Dejo una captura para el que quiera ver los colores de la tty =D
Todavia le tengo que cambiar el color de las lineas a tmux u.u
(http://ompldr.org/tOWE4eQ) (http://ompldr.org/vOWE4eQ)
Salu2
https://github.com/XayOn/jabashit
Justo hoy he descubierto que había otro software (bash-it) (a raíz del cual he cambiado el nombre de estas librerias) en plan framework con plugins como el mio, tienen funcionalidades similares aunque este esta menos orientado a macosx y es dependiente de bash > 4
Tengo por ahi, en la sección configs, algo sobre lo del $?, basado en codigo e ideas de un colega.
Nos vemos.
Cita de: XayOn en 1 Julio 2011, 03:01 AM
https://github.com/XayOn/jabashit
Justo hoy he descubierto que había otro software (bash-it) (a raíz del cual he cambiado el nombre de estas librerias) en plan framework con plugins como el mio, tienen funcionalidades similares aunque este esta menos orientado a macosx y es dependiente de bash > 4
Tengo por ahi, en la sección configs, algo sobre lo del $?, basado en codigo e ideas de un colega.
Nos vemos.
¿?
Cita de: Leo Gutiérrez. en 1 Julio 2011, 06:46 AM
¿?
He posteado mi bashrc y otras configuraciones / "plugins" para sourcear desde bash con cosas utiles =)
y en algun punto en mis configs, hay una opcion para meter en el prompt manejo de erores con $?
¿Alguna pregunta más?
Como era tanto código, he posteado mi github.
Ninguna, solo que no te había entendido bien. Gracias por postear.
Ufff, bien, vim no uso desde el vamos ( para editar en modo consola uso ee(1) (http://www.freebsd.org/cgi/man.cgi?query=ee&sektion=1) & nano(1) (http://man.cx/nano(1)) ... KISS ) ....
Mi .bashrc (ignoren lo de wine, es una cosa específica de FreeBSD de 64 bits) :
fortune freebsd-tips | cowsay
alias winecfg="LD_32_LIBRARY_PATH=/compat/i386/usr/local/lib PATH=/compat/i386/usr/local/bin:$PATH /compat/i386/usr/local/bin/winecfg"
alias wine32="LD_32_LIBRARY_PATH=/compat/i386/usr/local/lib PATH=/compat/i386/usr/local/bin:$PATH /compat/i386/usr/local/bin/wine"
# prompt
if [[ $UID -eq 0 ]];then
PS1_base='[$?]\[\e[1;37m\][\[\e[1;31m\]\u\[\e[1;37m\]\[\e[1;37m\]@\h \W]\[\e[1;31m\]\$\[\e[0;0m\] '
PS2='\[\e[1;31m\]>\[\e[0;0m\] '
else
PS1_base='[$?]\[\e[1;37m\][\u@\h \W]\$\[\e[0;0m\] '
PS2='\[\e[1;37m\]>\[\e[0;0m\] '
fi
set_prompt(){
error_val=$?
if [[ $error_val -eq 0 ]] ;then
str_error='\[\e[0;32m\]'
else
str_error='\[\e[1;31m\]'
fi
PS1="$str_error$PS1_base"
}
PROMPT_COMMAND='set_prompt'
Mi .profile :
# $FreeBSD: src/share/skel/dot.profile,v 1.23.2.1.6.1 2010/12/21 17:09:25 kensmith Exp $
#
# .profile - Bourne Shell startup script for login shells
#
# see also sh(1), environ(7).
#
# remove /usr/games if you want
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:$HOME/Software/bin; export PATH
# Setting TERM is normally done through /etc/ttys. Do only override
# if you're sure that you'll never log in via telnet or xterm or a
# serial line.
# Use cons25l1 for iso-* fonts
# TERM=cons25; export TERM
BLOCKSIZE=K; export BLOCKSIZE
EDITOR=vi; export EDITOR
PAGER=more; export PAGER
# set ENV to a file invoked each time sh is started for interactive use.
ENV=$HOME/.shrc; export ENV
if [ -x /usr/games/fortune ] ; then /usr/games/fortune freebsd-tips ; fi
########################################################
# set compilers to Clang
CC=/usr/local/bin/clang ; export CC
CXX=/usr/local/bin/clang++ ; export CXX
CPATH=/usr/include:/usr/local/include ; export CPATH
########################################################
# Locale
LC_ALL=en_US.UTF-8 ; export LC_ALL
En términos generales no automatizo mucho ya que lo que suelo hacer siempre (tareas de mantenimiento de ports y demás), las hago siempre "a mano" cuando no automatizo con portmaster
Realmente no tengo una librería de *scripts* para hacer cosas, ya que si bien paso un buen tiempo en la consola, pocas cosas son tan complejas y frecuentes como para crearles alias y funciones. (aparte de que no soy bueno para scripting, es más, antes hacía las cosas que hoy hago por scripts en C#)
Normalmente escribo todo en el momento ~
Saludos.
Cita de: vertex@Symphony en 2 Julio 2011, 01:38 AM
Ufff, bien, vim no uso desde el vamos ( para editar en modo consola uso ee(1) (http://www.freebsd.org/cgi/man.cgi?query=ee&sektion=1) & nano(1) (http://man.cx/nano(1)) ... KISS ) ....
Mi .bashrc (ignoren lo de wine, es una cosa específica de FreeBSD de 64 bits) :
fortune freebsd-tips | cowsay
alias winecfg="LD_32_LIBRARY_PATH=/compat/i386/usr/local/lib PATH=/compat/i386/usr/local/bin:$PATH /compat/i386/usr/local/bin/winecfg"
alias wine32="LD_32_LIBRARY_PATH=/compat/i386/usr/local/lib PATH=/compat/i386/usr/local/bin:$PATH /compat/i386/usr/local/bin/wine"
# prompt
if [[ $UID -eq 0 ]];then
PS1_base='[$?]\[\e[1;37m\][\[\e[1;31m\]\u\[\e[1;37m\]\[\e[1;37m\]@\h \W]\[\e[1;31m\]\$\[\e[0;0m\] '
PS2='\[\e[1;31m\]>\[\e[0;0m\] '
else
PS1_base='[$?]\[\e[1;37m\][\u@\h \W]\$\[\e[0;0m\] '
PS2='\[\e[1;37m\]>\[\e[0;0m\] '
fi
set_prompt(){
error_val=$?
if [[ $error_val -eq 0 ]] ;then
str_error='\[\e[0;32m\]'
else
str_error='\[\e[1;31m\]'
fi
PS1="$str_error$PS1_base"
}
PROMPT_COMMAND='set_prompt'
Mi .profile :
# $FreeBSD: src/share/skel/dot.profile,v 1.23.2.1.6.1 2010/12/21 17:09:25 kensmith Exp $
#
# .profile - Bourne Shell startup script for login shells
#
# see also sh(1), environ(7).
#
# remove /usr/games if you want
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:$HOME/Software/bin; export PATH
# Setting TERM is normally done through /etc/ttys. Do only override
# if you're sure that you'll never log in via telnet or xterm or a
# serial line.
# Use cons25l1 for iso-* fonts
# TERM=cons25; export TERM
BLOCKSIZE=K; export BLOCKSIZE
EDITOR=vi; export EDITOR
PAGER=more; export PAGER
# set ENV to a file invoked each time sh is started for interactive use.
ENV=$HOME/.shrc; export ENV
if [ -x /usr/games/fortune ] ; then /usr/games/fortune freebsd-tips ; fi
########################################################
# set compilers to Clang
CC=/usr/local/bin/clang ; export CC
CXX=/usr/local/bin/clang++ ; export CXX
CPATH=/usr/include:/usr/local/include ; export CPATH
########################################################
# Locale
LC_ALL=en_US.UTF-8 ; export LC_ALL
En términos generales no automatizo mucho ya que lo que suelo hacer siempre (tareas de mantenimiento de ports y demás), las hago siempre "a mano" cuando no automatizo con portmaster
Realmente no tengo una librería de *scripts* para hacer cosas, ya que si bien paso un buen tiempo en la consola, pocas cosas son tan complejas y frecuentes como para crearles alias y funciones. (aparte de que no soy bueno para scripting, es más, antes hacía las cosas que hoy hago por scripts en C#)
Normalmente escribo todo en el momento ~
Saludos.
Nice, la chorradita de las fortunes me gusta ^^ Creo que me apunto a ello! =D
Jaja, ya veo tu compilador seteado a CLANG por ahi =)
jajajajajaj lo de fortune es una idea MUY buena, ¡Saludos! Cuando pueda cuelgo mis scripts.
Cita de: Leo Gutiérrez. en 26 Junio 2011, 11:26 AM
function mktar() { tar cvf "${1%%/}.tar" "${1%%/}/"; }
function mktgz() { tar cvzf "${1%%/}.tar.gz" "${1%%/}/"; }
function mktbz() { tar cvjf "${1%%/}.tar.bz2" "${1%%/}/"; }
Leo me has vuelto reloco por saber que narices significa "1%%/" y saber como funciona esta función, ¿me lo puedes explicar?
Gracias :)
Cita de: P-Joe en 31 Agosto 2011, 18:53 PM
Leo me has vuelto reloco por saber que narices significa "1%%/" y saber como funciona esta función, ¿me lo puedes explicar?
Gracias :)
$1 es el primer parametro, esta haciendole string manipulation.
http://www.thegeekstuff.com/2010/07/bash-string-manipulation/
Citaralias cls='clear'
Amor a windows dos?
Citaralias cd..='cd ..'
Muchas ganas de hacer las cosas rapido que el espacio es un estorbo?
@morenochico → Para gustos, colores ... Leo es moderador de Scripting y siempre está con cosas en batch, es esperable que se acomode algunas cosas de bash a costumbres de Windows.
Para ser un groso en una área, tenés que saber deconstruirte y dejar las costumbres de lado ... por que el humano es un animal de costumbres, y seamos sinceros ... todos pasamos por un Windows.
Para ser groso en otros sistemas tenés que saber desarmar esas costumbres y poder adaptar fácilmente la cabeza a "otro paradigma"
En realidad, toda la computación es así, néh ..
Bueno, reinstalé y terminé con esto :
.cshrc
cat .cshrc
# $FreeBSD: stable/9/share/skel/dot.cshrc 170119 2007-05-29 22:07:57Z dougb $
#
# .cshrc - csh resource script, read at beginning of execution by each shell
#
# see also csh(1), environ(7).
#
alias h history 25
alias j jobs -l
alias la ls -a
alias lf ls -FA
alias ll ls -lA
# A righteous umask
umask 22
set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/Software/bin /usr/local/kde4/bin )
setenv EDITOR ee
setenv PAGER more
setenv BLOCKSIZE K
setenv LANG en_US.UTF-8
setenv __GL_SHADER_DISK_CACHE 1
setenv CC /usr/bin/clang
setenv CXX /usr/bin/clang++
setenv CPATH /usr/include:/usr/local/include
if ($?prompt) then
# An interactive shell -- set some stuff up
set filec
set history = 100
set savehist = 100
set mail = (/var/mail/$USER)
if ( $?tcsh ) then
bindkey "^W" backward-delete-word
bindkey -k up history-search-backward
bindkey -k down history-search-forward
endif
endif
(el .cshrc tradicional de FreeBSD con dos cambios)
Lo de wine lo volé por que ando usando un FreeBSD de 32 bits (y no necesito armar el workaround de la "jaula" de 32 bits )
La verdad no soy gran fan de personalizar los .*rc ... normalmente me armo scripts para las cosas que hago seguido, más que armar funciones o alias, como por ejemplo :
#!/bin/csh
if ( "`qdbus org.kde.kwin /KWin org.kde.KWin.compositingActive`" == "true" ) then
qdbus org.kde.kwin /KWin org.kde.KWin.toggleCompositing
endif
$*
if ("`qdbus org.kde.kwin /KWin org.kde.KWin.compositingActive`" == "false") then
qdbus org.kde.kwin /KWin org.kde.KWin.toggleCompositing
endif
exit
Y todo va derechito a $HOME/Software/bin
Saludos.
P.S → El .profile es similar x'3
[Alex] :
Pienso lo mismo que tu 99.99% hemos pasado por windows, yo tambien tengo costumbres de win en linux, uso office 2003 en mandriva, worpad en suse, asi como utilerias like linux en xp ... pero eso es otra historia.
En su momento procuraba las mismas constumbres tanto en linux com win pero me canse luego de al ir probando los diferentes sabores de linux, asi que intento adaptarme al mundo y no que el mundo se adapte a mi.
Cita de: XayOn en 9 Noviembre 2011, 16:03 PM
$1 es el primer parametro, esta haciendole string manipulation.
http://www.thegeekstuff.com/2010/07/bash-string-manipulation/
Muchas gracias por el link! Saludos.
Cita de: Exe U. en 29 Junio 2011, 17:52 PM
En mi caso el prompt es asi
┌─[exeu@archlinux]-[~]
└─> asdf
Dejo una captura para el que quiera ver los colores de la tty =D
Todavia le tengo que cambiar el color de las lineas a tmux u.u
(http://ompldr.org/tOWE4eQ) (http://ompldr.org/vOWE4eQ)
Salu2
ArchLinux rulez!!!
Acabo de enchular mi prompt:
PS1="\[$(tput setaf 6)\]\w\[$(tput setaf 1)@$(tput setaf 3)Debian$(tput setaf 1) ~~> $(tput setaf 2)\]"
y pues mi aliases no tiene nada del otro mundo:
alias www="cd /var/www"
alias casa="cd /home/jaavier"
alias f5="sudo apt-get update &&sudo apt-get upgrade"
alias c_alias="kate .bash_aliases"
Saludos, Javier.
.bashrc
export DISPLAY=:1
LOCKFILE="/tmp/.X1-lock"
PS1='\[\e[1;32m\][\u@\h \W]\$\[\e[0m\]'
setxkbmap es
alias pacman='pacman-color'
alias python='python2.7'
alias ls='ls --color'
if [ -f $LOCKFILE ]; then
echo -e ' \033[36m Bash inicializado... \033[0m '
else
X :1 &
openbox &
gnome-terminal --maximize &
google-chrome &
PYTHONPATH=/usr/lib/python2.7/site-packages/
setxkbmap es
fi
*aclaro: esta "idiotez" es por que solo uso las Xs para iniciar un explorador grafico y un emulador de terminal "gnome-terminal". [eso lo explica todo :) ]
############################################
.vimrc
syntax on
colorscheme eclipse
jeje bastate simploncito :P
Saludos,
alguien tiene idea de como puedo poner a titilar (aparecer y desaparecer) parte del String de prompt?
Por ejemplo:
Atencion! Solo personal autorizado. ~$
la idea es que el string "Atencion!" quede titilando/intermitente o como le quieran llamar. Yo lo había hecho alguna vez en ubuntu 6.* pero ya se me olvidó.
Agradezco sus comentarios.
Con la variable PS1 ... en este hilo tenés muchos ejemplos de como cambiarla.
Jugá con eso y si te sale alguna duda, postee nomás.
Pues actualmente tengo configurado lo siguiente:
.bash_aliases
alias cd..='cd ..'
alias la='ls -la'
alias ll='ls -l'
alias pingg='ping google.com'
alias update='sudo apt-get update'
alias upgrade='sudo apt-get upgrade'
alias aptinsall='sudo apt-get install'
alias aptsearch='sudo apt-cache search'
alias :q='exit'
.bashrc
# User settings
screenfetch-dev
#PS1='\[\e[0;34m\][\W]\[\e[m\] ' Prompt en formato [dirActual]
#PS1='[\u@\h \W]\$ ' Prompt en formato [usr@host dirActual]
PS1='\n\e[0;37m\]┌─\e[1;34m\][\u@\h] - \e[0;37m\][\D{%d/%m/%y} - \t]\e[1;34m\] - [\w]\n\e[0;37m\]└─> \e[1;34m\]\$ \e[0;0m\]'
El prompt queda de la siguiente forma:
┌─[user@host] - [dd/mm/yy - HH:mm:ss] - [~]
└─> $
Y el .vimrc
1 set number
2 set wrap
3 set incsearch
4 set hlsearch
5 set expandtab
6 set autoindent
7 set wildmenu
8 set textwidth=80
9 set tabstop=8
10
11 "Activar uso del mouse
12 set mouse=a
13
14 "Tecla para mostrar/ocultar NERDTree
15 map <F2> :NERDTreeToggle<cr>
16
17 "Tema
18 colorscheme desert
19
20 "Movimiento entre ventanas
21 map <C-J> <C-W>j<C-W>_
22 map <C-K> <C-W>k<C-W>_
23 map <C-L> <C-W>l<C-W>_
24 map <C-H> <C-W>h<C-W>_
25
26 "Movimiento entre pestañas
27 map <S-H> gT
28 map <S-L> gt
SalU2!
Dark Side
Uso bastante la shell pero nunca me habia parado a configurarla, soy un mal linuxero...
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
export PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
alias ls='ls --color=auto'
export LANG=en_US.UTF-8
export EDITOR="nano"
export synclient VertEdgeScroll=1
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1500
HISTFILESIZE=3000
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups
HISTCONTROL=ignoredups
HISTIGNORE=":htop*:ls*:su*:history*:pacman*:exit*"
#PS1='[\u@\h \W]\$ '
#PS1='\[\033[0;41m\] \u@\h\[\033[01;36m\]\W \$ \[\033[00m\] '
#PS1='\[\e[1;32m\][\u\[\e[m\]@\[\e[1;33m\]\h\[\e[1;34m\] \w]\[\e[1;36m\] \$\[\e[1;37m\] '
#PS1='┌──[\u@\h][\w][\t]\n└──[\$] '
#PS1='┌─[\u][\A][\w]\n└─[\$] '
PS1='\[\e[1;34m\]┌─ \e[1;32m\u\e[m@\e[1;33m\h\e[1;34m [\e[m\t\e[1;34m] [\e[m\w\e[1;34m] \n └─ $ \[\e[m\]'
#PS1='\[\033[1;32m\]\u@\h\[\033[1;36m\] \W \$\[\033[00m\] '
# 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 [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls -lh --color=auto'
alias ll='ls -lh --color=auto'
alias dir='ls -lh --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
setxkbmap -layout "latam" -option "grp:alt_shift_toggle"
set completion-ignore-case on
#siv -t -c4
alsi -a -u c1=blue c2=blue
Me gustaría aumentar el margen en la terminal de gnome, debido a que por defecto no tiene márgenes.
A lo que me refiero es a aumentar el espacio entre el borde de la ventana y el texto de entrada/salida de la consola.
Por ejemplo:
=[X][-][ ]=============Mi Terminal==================
| |
| $> echo "Hay margen arriba, a la izquierda y a |
| la derecha." |
| |
| |
| |
====================================================
Si alguien tiene idea de como hacer esto le agradezco su ayuda.
Un saludo.
# .bashrc
# User specific aliases and functions
Ose nada de nada
Hola a todos, aqui traigo un script que me gustaria que revisaran y obvio que acepto sugerencias en cuanto al codigo. El objetivo es que haga una salva de las trazas del squid (access.log) en una carpeta llamada salvas ubicada en la raiz. Si puede ser mejorado, no se lo callen por favor.
#!/bin/bash
#INFORMACION DEL SCRIPT:
#ESTE SCRIPT SIRVE PARA HACER UNA SALVA DEL ACCESS.LOG DEL SQUID.
#VARIABLES
DIA=`date +%d`
MES=`date +%m`
YEAR=`date +%y`
HORA=`date +%H%M`
ARCHIVO=trazas-$DIA$MES$YEAR$HORA.log
#DETENER SQUID
service squid stop
echo "Squid detenido esperando 2 segundos para continuar"
#ESPERAMOS POR SI ACASO
sleep 2s
#MOVER EL ARCVHIVO DE LOS LOG's
echo "Moviendo el archivo de las trazas para /salvas/"
mv /var/log/squid/access.log /salvas/$ARCHIVO
echo "listo"
#CREACION DEL ARCHIVO NUEVO
echo "Creando el nuevo archivo en blanco"
touch /var/log/squid/access.log
echo "Listo"
#PERMISO DE ESCRITURA AL NUEVO ARCHIVO
echo "Asigando permisos al nuevo archivo"
chmod 777 /var/log/squid/access.log
echo "listo"
#INICIAMOS EL SQUID
echo "Iniciando el squid"
service squid start
echo "Listo, copia realizada con exito"
#ESPERAMOS POR SI ACASO
sleep 5s
#SALIMOS
exit 0
muy interesante realmente estoy empezando a usar kali linux bueno no soy programador ni nada estoy estudiando otra cosa nada relacionado con informática pero encuentro interesante todo esto tengo un problema con eso de que no se reconoce un comando eso de la modificacion .bashrc podria aydarme ?
#msfpayload -h
bash: msfpayload : no se encontro la orden
es lo que me aparece espero puedan orientar mese que esto ya lo e colocado en un tema pero al leer un poco de tu proyecto me resulta interesante saber si puede solucionar mi problema y si no igualmente gracias
.zshrc
#{{{ ZSH Modules
autoload -U compinit promptinit zcalc zsh-mime-setup
autoload -U colors && colors
autoload -Uz vcs_info
compinit
promptinit
zsh-mime-setup
#}}}
#{{{ Options
# See `man zshoptions`
setopt CORRECT
setopt GLOB_COMPLETE
setopt RM_STAR_WAIT
setopt ZLE
setopt VI
setopt NO_HUP
setopt IGNORE_EOF
setopt NO_BEEP
setopt NUMERIC_GLOB_SORT
setopt EXTENDED_GLOB
setopt RC_EXPAND_PARAM
setopt APPEND_HISTORY
setopt COMPLETE_IN_WORD
setopt prompt_subst
setopt nohashdirs
setopt nohashcmds
unsetopt FLOW_CONTROL
unsetopt LIST_AMBIGUOUS
# History options
setopt EXTENDED_HISTORY
setopt SHARE_HISTORY
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_REDUCE_BLANKS
setopt HIST_IGNORE_SPACE
setopt HIST_NO_STORE
setopt HIST_VERIFY
setopt HIST_SAVE_NO_DUPS
setopt HIST_EXPIRE_DUPS_FIRST
setopt HIST_FIND_NO_DUPS
#}}}
#{{{ Variables
export EDITOR=vim
export PAGER=less
export JAVA_HOME="/usr"
export _JAVA_AWT_WM_NONREPARENTING=1
export KEYTIMEOUT=1 # Reduce vi-mode lag
export ANDROID_HOME="/opt/android-sdk"
export ANDROID_SWT="/usr/share/java"
export ANDROID_TOOLS="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"
export PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/opt/opencascade/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:$ANDROID_TOOLS"
declare -U path
# History
HISTFILE=~/.history
SAVEHIST=1000
HISTSIZE=1000
#}}}
#{{{ Aliases
alias x='startx'
alias p='ping 8.8.8.8'
alias ls='ls --color'
alias vi='/usr/bin/vim'
alias vim='nvim'
alias emacs='emacs -nw'
alias am='alsamixer' alsamixer='alsamixer -g -c 0'
#}}}
#{{{ Completion
# See `man zshcompsys
zstyle ':completion::complete:*' use-cache 1
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*:default' list-prompt '%S%M matches%s'
zstyle ':completion:*:default' menu 'select=0'
zstyle ':completion:*' file-sort modification reverse
zstyle ':completion:*' list-colors "=(#b) #([0-9]#)*=36=31"
zstyle ':completion:*:manuals' separate-sections true
zstyle ':completion:*:corrections' format '%B%d (errors %e)%b'
zstyle ':completion::*:(rm|vi):*' ignore-line true
zstyle ':completion:*' ignore-parents parent pwd
zstyle ':completion::approximate*:*' prefix-needed false
#}}}
#{{{ Key bindings
# Special keys works properly
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
bindkey '\e[A' up-line-or-history
bindkey '\e[B' down-line-or-history
bindkey '\eOA' up-line-or-history
bindkey '\eOB' down-line-or-history
bindkey '\e[C' forward-char
bindkey '\e[D' backward-char
bindkey '\eOC' forward-char
bindkey '\eOD' backward-char
#}}}
#{{{ Prompt
zstyle ':vcs_info:*' stagedstr '%F{28}^'
zstyle ':vcs_info:*' unstagedstr '%F{11}^'
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{11}%r'
zstyle ':vcs_info:*' enable git svn
precmd()
{
if [[ -z $(git ls-files --other --exclude-standard 2> /dev/null) ]] {
zstyle ':vcs_info:*' formats ' [%F{green}%b%c%u%F{normal}]'
} else {
zstyle ':vcs_info:*' formats ' [%F{green}%b%c%u%F{red}^%F{normal}]'
}
vcs_info
}
PROMPT='%{$fg[blue]%}%B%n%b%{$reset_color%}@%{$fg[magenta]%}%B%M%b%{$reset_color%} %1~ ${vcs_info_msg_0_}%{$reset_color%}%# '
#}}}
#{{{ Vi-mode
# From `oh-my-zsh` vi-mode plugin
# Ensures that $terminfo values are valid and updates editor information when
# the keymap changes.
function zle-keymap-select zle-line-init zle-line-finish {
# The terminal must be in application mode when ZLE is active for $terminfo
# values to be valid.
if (( ${+terminfo[smkx]} )); then
printf '%s' ${terminfo[smkx]}
fi
if (( ${+terminfo[rmkx]} )); then
printf '%s' ${terminfo[rmkx]}
fi
zle reset-prompt
zle -R
}
# Ensure that the prompt is redrawn when the terminal size changes.
TRAPWINCH() {
if [[ -o zle ]]; then
zle reset-prompt
zle -R
fi
}
zle -N zle-line-init
zle -N zle-line-finish
zle -N zle-keymap-select
zle -N edit-command-line
bindkey -v
# Avoid dropping keystrokes after ESC hit
bindkey -as '\e' ''
# allow v to edit the command line
# autoload -Uz edit-command-line
# bindkey -M vicmd 'v' edit-command-line
# allow ctrl-p, ctrl-n, ctrl-r for navigate history (standard behaviour)
bindkey '^P' up-history
bindkey '^N' down-history
bindkey '^r' history-incremental-search-backward
# Incrementar search for / and ?
bindkey -M vicmd "/" history-incremental-search-backward
bindkey -M vicmd "?" history-incremental-search-forward
# allow ctrl-h, ctrl-w, ctrl-? for char and word deletion (standard behaviour)
bindkey '^?' backward-delete-char
bindkey '^h' backward-delete-char
bindkey '^w' backward-kill-word
# Some extra vim like bindings
bindkey -a 'gg' beginning-of-buffer-or-history
bindkey -a 'G' end-of-buffer-or-history
bindkey -a 'u' undo
bindkey -a '^R' redo
# Mode indicator right prompt
function zle-line-init zle-keymap-select
{
RPS1="${${KEYMAP/vicmd/}/(main|viins)/-- INSERT --}"
RPS2=$RPS1
zle reset-prompt
}
# Allow Copy/Paste with the system clipboard
# behave as expected with vim commands ( y/p/d/c/s )
[[ -n $DISPLAY ]] && (( $+commands[xclip] )) && {
function cutbuffer() {
zle .$WIDGET
echo $CUTBUFFER | xclip -selection clipboard
}
zle_cut_widgets=(
vi-backward-delete-char
vi-change
vi-change-eol
vi-change-whole-line
vi-delete
vi-delete-char
vi-kill-eol
vi-substitute
vi-yank
vi-yank-eol
)
for widget in $zle_cut_widgets
do
zle -N $widget cutbuffer
done
function putbuffer() {
zle copy-region-as-kill "$(xclip -selection clipboard -o)"
zle .$WIDGET
}
zle_put_widgets=(
vi-put-after
vi-put-before
)
for widget in $zle_put_widgets
do
zle -N $widget putbuffer
done
}
#}}}
#{{{ Misc
# Deactivate Software flow control
stty -ixon
# Set proper terminal for SCREEN and TMUX
if [[ -z $TMUX ]]; then
if [ -e /usr/share/terminfo/x/xterm+256color ]; then
export TERM='xterm-256color'
else
export TERM='xterm'
fi
else
if [ -e /usr/share/terminfo/s/screen-256color ]; then
# export TERM='screen-256color'
export TERM='xterm-256color'
else
export TERM='screen'
fi
fi
# Autorun TMUX (Only when X11 is running)
# if [[ (-e /tmp/.X0-lock) ]]; then
# if [[ -n $TMUX ]]; then
# # Tmux running, do nothing
# else
# tmux -2
# fi
# fi
#}}}
#{{{ First Init
# Auto start X11 and Wifi connection
if [[ ! (-e /tmp/.X0-lock) ]]; then
# ~/.wifi.sh
./.ether.sh
startx
fi
#}}}
# vim:fdm=marker
.nvimrc
"{{{ VIM-PLUG
call plug#begin('~/.vim/plugged')
Plug 'wellle/targets.vim'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-repeat'
Plug 'michaeljsmith/vim-indent-object'
Plug 'scrooloose/syntastic'
Plug 'scrooloose/nerdtree'
Plug 'vim-scripts/taglist.vim'
Plug 'kien/ctrlp.vim'
Plug 'thanthese/Tortoise-Typing'
Plug 'mbbill/undotree'
Plug 'alx741/vinfo'
Plug 'godlygeek/tabular'
Plug 'bruno-/vim-man'
Plug 'altercation/vim-colors-solarized'
Plug 'junegunn/goyo.vim'
Plug 'jceb/vim-orgmode'
Plug 'EinfachToll/DidYouMean'
Plug 'tommcdo/vim-exchange'
Plug 'vitalk/vim-simple-todo'
Plug 'powerman/vim-plugin-viewdoc'
" On-demand loading
Plug 'scrooloose/syntastic', { 'on': 'SyntasticCheck' }
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'vim-scripts/taglist.vim', { 'on': 'TlistToggle' }
Plug 'thanthese/Tortoise-Typing', { 'on': 'TortoiseTyping' }
Plug 'mbbill/undotree', { 'on': 'UndotreeToggle' }
Plug 'alx741/vinfo', { 'on': 'Vinfo' }
Plug 'godlygeek/tabular', { 'on': 'Tabularize' }
Plug 'bruno-/vim-man', { 'on': 'Man' }
Plug 'junegunn/goyo.vim', { 'on': 'Goyo' }
call plug#end()
"}}}
"{{{ Auto Commands
" Reset format options when filetypes are loaded
autocmd FileType * set formatoptions=tcrql
" Trigger StyleMarks
autocmd VimEnter,BufWinEnter,BufWinLeave * call StyleMarks()
"}}}
"{{{ Maps
" Get raid of vim 'exclusivity' madness
" All movements are now inclusive
" onoremap h vh
" onoremap l vl
" onoremap b vb
" onoremap B vB
" onoremap F vF
" onoremap T vT
" onoremap ^ v^
" onoremap g^ vg^
" onoremap + v+
" onoremap g+ vg+
" onoremap ( v(
" onoremap ` v`
" Move with visual lines
nnoremap j gj
nnoremap k gk
nnoremap J gJ
nnoremap 0 g0
nnoremap ^ g^
nnoremap $ g$
" Search for visual selected area
vnoremap // y/<C-R>"<CR>
" Terminal mode leaving
tnoremap <esc> <C-\><C-n>
" Toggle folds
nnoremap <space> za
" Remove highlights using escape (this prevent using especial keys mappings!)
nnoremap <silent><esc> :noh<CR><esc>
"""" LEADER mappings
" Remove trailing white spaces ( \w )
map <silent><leader>f :call Format() <CR>
" Toggle spelling ( \s )
nnoremap <leader>s :call ToggleSpell() <cr>
" Trigger TagList plugin ( \t )
nnoremap <leader>t :TlistToggle <cr>
" Trigger UndoTree plugin ( \u )
nnoremap <leader>u :UndotreeToggle <cr>
" Trigger NerdTree plugin ( \n )
nnoremap <leader>n :NERDTreeToggle <cr>
" Trigger Ctags program for the current directory
nnoremap <silent><leader>c :!ctags -R . <cr>
"}}}
"{{{ Options and Configurations
" Status line
set statusline=[%n]\ %t\ [%{strlen(&fenc)?&fenc:'none'},\ %{&ff}]
set statusline+=\ [ft=%Y]\ %r\ %m
set statusline+=%=%c:%l/%L\ %P
" Color scheme
colors solarized
" Set various options
syntax on
syntax spell toplevel
set t_CO=16
set lazyredraw
set textwidth=80
set linebreak
set timeoutlen=1000 ttimeoutlen=0
" set cursorline
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set smarttab
set showcmd
set completeopt-=preview
set completeopt+=longest
set number
set showmatch
set hlsearch
set incsearch
set ignorecase
set smartcase
set backspace=2
set autoindent
set cindent
set ruler
set autoread
set nojoinspaces
set background=light
set wrapscan
set laststatus=2
set wildmenu
set wildmode=longest,list,full
set wildignore=*.o,*.class
set hidden
set foldenable
set foldmethod=syntax
set foldnestmax=2
set foldlevel=3
let c_no_comment_fold=1
" Formatting options:
" * Auto wrap text using textwidth
" * Auto wrap comments using textwidth
" * Auto insert comment leader while inserting
" * Auto formatting of paragraphs
" * Don't auto brake lines
set formatoptions=tcrql
" Config the backup system
set backup
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set backupskip=/tmp/*,/private/tmp/*
set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set writebackup
"}}}
"{{{ Plugins configuration
" Syntastic
let $PYTHONPATH='/usr/lib/python3.4/site-packages'
let g:syntastic_mode_map = {
\ 'mode' : 'passive',
\ 'active_filetypes' : [],
\ 'passive_filetypes' : [] }
" Targets
" let g:targets_aiAI = 'aIAi'
"}}}
"{{{ Misc
" Set SDCC paths
set path+=/usr/share/sdcc/include/pic14,/usr/share/sdcc/include/pic16
set path+=/usr/share/sdcc/non-free/include/pic14,/usr/share/sdcc/non-free/include/pic16
" Sudo Write
command W w !sudo tee % >/dev/null
"}}}
"{{{ Personal functions
" Help files tags jump
" [g , ]g
nmap [g <Plug>unimpairedHelpTagPrevious
nmap ]g <Plug>unimpairedHelpTagNext
nnoremap <silent> <Plug>unimpairedHelpTagPrevious :call <SID>HelpTag(1)<CR>
nnoremap <silent> <Plug>unimpairedHelpTagNext :call <SID>HelpTag(0)<CR>
function! s:HelpTag(reverse)
call search('|\S\+|', a:reverse ? 'bW' : 'W')
endfunction
" Format document
"
" * Removes trailing white spaces
" * Removes blank lines at the end of the file
" * Replaces tabs with spaces
" * Re-Indent
"
" * If: C, CPP, PHP or JAVA code: format using 'astyle'
" * Style: allman
" * Braces in the first column
" * Spaces between operators
"
" * Leaves 'formatprg' option clean so `gq` can be used with the default
" behavior
function! Format()
silent! execute 'norm! mz'
if &ft ==? 'c' || &ft ==? 'cpp' || &ft ==? 'php'
set formatprg=astyle\ --mode=c\ --style=allman\ -j\ -p\ -f\ -xe\ -xC80\ -H
silent! execute 'norm! gggqG'
elseif &ft ==? 'java'
set formatprg=astyle\ --mode=java\ --style=allman\ -j\ -p\ -f\ -xe\ -xC80\ -H
silent! execute 'norm! gggqG'
endif
silent! execute '%s/\s\+$//ge'
silent! execute 'g/\v^$\n*%$/norm! dd'
silent! execute 'retab'
silent! execute 'gg=G'
silent! execute 'norm! `z'
set formatprg=
endfunction
" Alternate between { NOSPELL, EN, ES } spelling
function! ToggleSpell()
if &spell ==? 0
set spelllang=en
set spell
echom "Spell [EN]"
elseif &spell ==? 1
if &spelllang ==? 'en'
set spelllang=es
echom "Spell [ES]"
elseif &spelllang ==? 'es'
set spelllang=en
set nospell
echom "NO Spell"
endif
endif
endfunction
" Marks over length lines and trailing white spaces as errors
function! StyleMarks()
highlight OverLength ctermbg=blue ctermfg=white
call matchadd('OverLength', '\%81v.\+', 100)
highlight Trailing ctermbg=blue ctermfg=white
call matchadd('Trailing', '\s\+$', 100)
highlight Debugme ctermbg=red ctermfg=white
call matchadd('Debugme', 'debugme', 100)
call matchadd('Debugme', 'DEBUGME', 100)
endfunction
"}}}
" vim:fdm=marker
.tmux.conf
# Set the current working directory based on the current pane's current
# working directory (if set; if not, use the pane's starting directory)
# when creating # new windows and splits.
bind-key c new-window -c '#{pane_current_path}'
bind-key '"' split-window -c '#{pane_current_path}'
bind-key % split-window -h -c '#{pane_current_path}'
# use UTF8
set -g utf8
set-window-option -g utf8 on
# Index start from 1 (insted of 0)
set -g base-index 1
set -g status-keys vi
set -g history-limit 10000
setw -g mode-keys vi
setw -g mode-mouse off
# make tmux display things in 256 colors
set -g default-terminal "screen-256color"
# set scrollback history to 10000 (10k)
set -g history-limit 10000
# set Ctrl-s as the default prefix key combination
# and unbind C-b to free it up
set -g prefix C-s
unbind C-b
# use send-prefix to pass C-a through to application
bind C-s send-prefix
# shorten command delay
set -sg escape-time 1
# map Vi movement keys as pane movement keys
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# map Vi selectio/copy keys
bind-key -t vi-copy 'v' begin-selection # Begin selection in copy mode.
bind-key -t vi-copy 'C-v' rectangle-toggle # Begin selection in copy mode.
bind-key -t vi-copy 'y' copy-selection # Yank selection in copy mode
# resize panes using PREFIX H, J, K, L
bind-key H resize-pane -L 5
bind-key J resize-pane -D 5
bind-key K resize-pane -U 5
bind-key L resize-pane -R 5
#### COLOR (Solarized light)
#
## default statusbar colors
set-option -g status-bg white #base2
set-option -g status-fg yellow #yellow
set-option -g status-attr default
#
## default window title colors
set-window-option -g window-status-fg brightyellow #base00
set-window-option -g window-status-bg default
##set-window-option -g window-status-attr dim
#
## active window title colors
set-window-option -g window-status-current-fg brightred #orange
set-window-option -g window-status-current-bg default
##set-window-option -g window-status-current-attr bright
#
## pane border
set-option -g pane-border-fg white #base2
set-option -g pane-active-border-fg brightcyan #base1
#
## message text
set-option -g message-bg white #base2
set-option -g message-fg brightred #orange
#
## pane number display
set-option -g display-panes-active-colour blue #blue
set-option -g display-panes-colour brightred #orange
#
## clock
set-window-option -g clock-mode-colour green #green
# ----------------------
# Status Bar
# -----------------------
set -g status-right '#(~/.tmuxbar.sh)'
set-option -g status on # turn the status bar on
set -g status-utf8 on # set utf-8 for the status bar
set -g status-interval 15 # set update frequency (default 15 seconds)
set -g status-justify centre # center window list for clarity
# set-option -g status off # Hide tmux bar by default
bind-key a set -g status # Toggle tmux bar visibility
# set-option -g status-position top # position the status bar at top of screen
# visual notification of activity in other windows
# setw -g monitor-activity on
# set -g visual-activity on
#######################
# Tmux Plugin manager
#######################
# List of plugins
# Supports `github_username/repo` or full git repo URLs
set -g @tpm_plugins ' \
tmux-plugins/tpm \
tmux-plugins/tmux-sensible \
tmux-plugins/tmux-resurrect \
tmux-plugins/tmux-yank \
'
# Other examples:
# github_username/plugin_name \
# git@github.com/user/plugin \
# git@bitbucket.com/user/plugin \
# Initializes TMUX plugin manager.
# Keep this line at the very bottom of tmux.conf.
run-shell '~/.tmux/plugins/tpm/tpm'
.ratpoisonrc
#{{{ Bindigs
# Escape
escape C-g
# Abort with ESC
bind Escape abort
# Only window
unbind q
bind o only
# Start graphical terminal emulator instance
bind c exec gnome-terminal
# Give temporally control to DWM
bind W tmpwm dwm
# Close current window
bind Q delete
unbind C-k
# Vi keys
bind j focusdown
bind h focusleft
bind k focusup
bind l focusright
bind J exchangedown
bind H exchangeleft
bind K exchangeup
bind L exchangeright
# Vi splits
unbind S
bind s vsplit
bind v hsplit
#}}}
# Banish the mouse pointer in every window change
addhook key banish
# Put cursor where it was previously
warp on
# Don't convert cursor in a box while waiting commands
set waitcursor 0
# Messages config
msgwait 2
startup_message off
set fgcolor black
set bgcolor papaya whip
# More informative date and time
bind a exec ratpoison -c "echo $( acpi -b | awk '{ print $3, $4 }' | tr -d ',' ) || $( date "+%F %r" )"
# If there is more than 1 screen, give focus to the second one
nextscreen
# vim:fdm=marker
Me han fascinado muchos ficheros de configuracion, buen post. Saludos cordiales desde Ecuador!
Ya es algo viejo el post pero igual y alguien le sirve :D
Dotfiles: https://github.com/qwartz2/dotfiles (https://github.com/qwartz2/dotfiles)
VIM
Tengo la config. de vim dividida en varios archivos, solo por tener un poco mas organizado nada especial.
~/
.vimrc
.vim/
|- vimrc/
|- basic.vim
|- plugins.vim
|- colors/
|- hybrid.vim
*hybrid.vim es el esquema de colores que utilizo para vim
~/.vimrc
source ~/.vim/vimrc/basic.vim
source ~/.vim/vimrc/plugins.vim
~/.vim/vimrc/basic.vim
"
" Basic Config. of VIM
" Author - @qwartz_
"
" -----------------------
" General
" -----------------------
"/*
set encoding=utf8
set nocompatible
set history=1000
" set colorcolumn=80
"*/
"/* Not Backup
set noswapfile
set nobackup
"*/
"/* Indented
set autoindent
set expandtab
set shiftwidth=4
set softtabstop=4
"*/
"/* Folding
set foldmethod=marker
set foldmarker=/*,*/
"*/
" -----------------------
" Interface
" -----------------------
"/* Basic
set background=dark
colorscheme hybrid
syntax on
set number
"*/
"/* More
set relativenumber
set cursorline
set cursorcolumn
set showmatch " opening and closing parentheses
set mouse=a
set ruler
set laststatus=2 " status bar
set wildmenu " autocomplete bar
set t_Co=256
"*/
" -----------------------
" Basic Mapping
" -----------------------
let mapleader=","
"/* change column numbers
nmap <F5> :set invrelativenumber<CR>
imap <F5> <ESC>:set invrelativenumber<CR>a
"*/
"/* resize panels
nmap h :vertical res +2<CR>
nmap l :vertical res -2<CR>
nmap j :res +2<CR>
nmap k :res -2<CR>
"*/
"/* split window
nmap <Leader>h :split<CR>
nmap <Leader>v :vsplit<CR>
"*/
~/.vim/vimrc/plugins.vim
" Plugins
" Author - @qwartz_
"
" -----------------------
" Plugins
" -----------------------
call plug#begin('~/.vim/plugged')
"/* list plugins
" Uncomment the plugins you want to install!
" Basic;
Plug 'jiangmiao/auto-pairs'
Plug 'vim-scripts/AutoComplPop'
Plug 'scrooloose/nerdtree'
"
" More;
"Plug 'ervandew/supertab'
" ----> Snippets <----
"Plug 'garbas/vim-snipmate'
"Plug 'MarcWeber/vim-addon-mw-utils'
"Plug 'tomtom/tlib_vim'
"Plug 'garbas/vim-snipmate'
"Plug 'honza/vim-snippets'
"*/
call plug#end()
" -----------------------
" Config. Plugins
" -----------------------
"/* NERDTree
nmap <Leader>nt :NERDTreeToggle<CR>
let NERDTreeQuitOnOpen=1
let NERDTreeWinSize=20
"*/
*Para instalar plugins utilizo: vim-plug (https://github.com/junegunn/vim-plug)