Configuración en debian 7.
Lo que he añadido al .bashrc (usuario normal).
Código: bash

El archivo You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login al que hago mención.
Código: bash

Cambios en el archivo anterior para el usuario root.
Código: bash

Funciones que tenía en el .bashrc pero que saque a archivos separados para que no se cargará tanto el fichero.
Geolocalización de IP.
Código: bash
Escanear la red en busca de hosts vivos (CDIR es la ip de red con máscara del tipo /24).
Código: bash
Subir un archivo a esa web, con opción de comprimirlo para evitar que bloquee extensiones no permitidas.
Código: bash
Archivo .xinitrc completo.
Código: bash
El archivo data_xsetroot al que hago referencia lo genera este script que se ejecuta en `cron' cada 10 minutos.
Código: bash

Archivo de configuración de dwm config.h completo.
Código: c
Escritorio limpio.
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
(Clickear en la imagen para agrandar.)
Escritorio ocupado.
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
(Clickear en la imagen para agrandar.)
Archivo .inputrc
Código: bash
Configuración de vim vimrc
Código: vim
Lo que he añadido al .bashrc (usuario normal).
# Info que se muestra al abrir la shell.
. /home/user/scripts/info.sh
# Alias.
alias srm='shred --remove --zero --force' # Borrado seguro del fichero.
alias ssrm='wipe -rcfq' # Borrado seguro de ficheros y también admite directorios.
alias pastebinit='pastebinit -b http://paste.debian.net' # Pastear código en esa web.
alias pastebincl='pastebincl --guest --expire=1H --name=:B' # Pastear código en pastebin, con parámetros.
alias sprunge="curl -F 'sprunge=<-' http://sprunge.us" # Pastear código en esa web.
# Seteos de variables.
export PS1='${debian_chroot:+($debian_chroot)}\[\e[0;32m\][ STAT:\[\e[0m\] $?\[\e[0;32m\] TERM:\[\e[0m\] pts/\l\[\e[0;32m\] PSHELL:\[\e[0m\] $$\[\e[0;32m\] JOBS:\[\e[0m\] \j\[\e[0;32m\](\[\e[0m\]$!\[\e[0;32m\]) ][ \d\[\e[0;32m\] \t ]\[\e[0m\]\n\[\e[0;32m\]\u\[\e[0;31m\]\342\230\242\[\e[0;32m\]\h \[\e[0;34m\]\W\[\e[0;31m\]\$\[\e[0m\] '
export HISTTIMEFORMAT='%F %T ' # Para ver la fecha de ejecución en `history'.
#export HISTIGNORE='pwd*:ls*:date*:vi*:vim*' # Estos comandos no se logearan.
#export HISTCONTROL="$HISTCONTROL:ignorespace" # Añadir que no logee comandos precedidos por espacios. Por defecto ya esta 'ignoreboth' que ignora los espacios y los comandos duplicados.
#export HISTSIZE=5 # 10 lineas de historial.
shopt -s histappend # Si tienes muchas terminales abiertas, habrá solo un historial entre todas esas terminal.
PROMPT_COMMAND='echo -e "\e[0;32m[ `ls -1 | wc -l` `ls -l | grep ^d | wc -l` `ls -a1 | grep ^[.][^.] | wc -l` ]\e[0m"' # Se ejecuta al final de cada comando introducido.

El archivo You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login al que hago mención.
#!/bin/bash
rojo='\e[0;31m'
verde='\e[0;32m'
normal='\e[0m'
capacidad=`df --human-readable | grep -w "rootfs" | awk '{print $4}'`
ultimo_acc=`last | grep -w "down" | sed -n '1p' | awk '{print $1" en "$2" a "$3" "$5" "$4" "$6" +"$9}'`
echo -e "\n+-----------------------------------------------+"
echo -e "|${rojo}Debian GNU/Linux${normal} ${verde}`cat /etc/debian_version`${normal}"
echo -e "|${rojo}Espacio libre / ${normal}: ${verde}$capacidad${normal}"
echo -e "|${rojo}Last${normal}: ${verde}$ultimo_acc${normal}"
echo -e "+-----------------------------------------------+"

Cambios en el archivo anterior para el usuario root.
# Funciones.
warning(){
echo -n "Seguro ? [s/n] "
read
if [ "$REPLY" == "s" ]; then
killall wpa_supplicant /usr/bin/python
shred -fuz /etc/wicd/manager-settings.conf /etc/wicd/wireless-settings.conf
shred -fuz /var/log/syslog
shred -fuz /lib/data_e/.encfs6.xml /home/user/.ip.log
shred -fuz /home/user/.irssi/config*
fi
}
# Función para copia de seguridad
backup(){
rsync --verbose --recursive --delete --delete-excluded --links --perms --times --group --owner --files-from=/home/user/scripts/file_backup_rsync --exclude-from=/home/user/scripts/file_backup_rsync_exclude / /media/iomega/Debian_backup/
}
# Seteos de variables.
export PS1='${debian_chroot:+($debian_chroot)}\[\e[0;31m\][ STAT:\[\e[0m\] $?\[\e[0;31m\] TERM:\[\e[0m\] pts/\l\[\e[0;31m\] PSHELL:\[\e[0m\] $$\[\e[0;31m\] JOBS:\[\e[0m\] \j\[\e[0;31m\](\[\e[0m\]$!\[\e[0;31m\]) ][ \d\[\e[0;31m\] \t ]\[\e[0m\]\n\[\e[0;31m\]\u\[\e[0;32m\]\342\230\242\[\e[0;31m\]\h \[\e[0;34m\]\W\[\e[0;32m\]\$\[\e[0m\] '
Funciones que tenía en el .bashrc pero que saque a archivos separados para que no se cargará tanto el fichero.
Geolocalización de IP.
#!/bin/bash
if [[ $# == 1 && "$1" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then
curl "http://api.hostip.info/get_html.php?ip=${1}"
exit 0
fi
if [[ $# == 2 && "$2" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then
if [ "$1" == "-c" ]; then
curl "http://api.hostip.info/country.php?ip=${2}"
echo
exit 0
elif [ "$1" == "-p" ]; then
curl "http://api.hostip.info/get_html.php?ip=${2}&position=true"
exit 0
elif [ "$1" == "-xml" ]; then
curl "http://api.hostip.info/?ip=${2}"
exit 0
elif [ "$1" == "-json" ]; then
curl "http://api.hostip.info/get_json.php?ip=${2}"
echo
exit 0
elif [ "$1" == "-pjson" ]; then
curl "http://api.hostip.info/get_json.php?ip=${2}&position=true"
echo
exit 0
fi
fi
printf "Uso: geoip <OPTION> <IP>
Por defecto muestra país con código, ciudad con código,
y la propia IP. Solo admite una opción a la vez.\n
-json Muestra la salida en formato json.
-c Visualizamos solo el código del país.
-p Muestra además la latitud y longitud.
-pjson Lo mismo que \"-p\" pero en formato json.
-xml Muestra toda la info en formato xml.\n\n"
exit 1
Escanear la red en busca de hosts vivos (CDIR es la ip de red con máscara del tipo /24).
#!/bin/bash
if [ $# -ne 1 ]; then
printf "Uso: escanear CDIR\n"
echo
exit 1
else
fping -a -g "$1" 2> /dev/null
echo
fi
exit 0
Subir un archivo a esa web, con opción de comprimirlo para evitar que bloquee extensiones no permitidas.
#!/bin/bash
if [[ $# -eq 2 && "$1" == "--zip" ]]; then
7z -tzip a "$2".zip "$2"
curl -F "file=@${2}.zip" https://anonfiles.com/api?plain
shred --zero --force --remove "$2".zip
echo
elif [ $# -eq 1 ]; then
curl -F "file=@${1}" https://anonfiles.com/api?plain
echo
else
printf "Uso: anonfiles file.zip\n\
--zip Comprime el archivo antes de enviarlo.\n"
echo
exit 1
fi
exit 0
Archivo .xinitrc completo.
#!/bin/bash
exec setxkbmap es &
xset r rate 200 40
#. ~/scripts/random_wallpaper.sh
urxvt -geometry 128x25 -cr '#CCCCCC' -bg '#080808' -fg '#CCCCCC' -fn "xft:Bitstream Vera Sans Mono:pixelsize=14" -pe default,matcher,tabbed &
iceweasel &
volumen()
{
STAT="`amixer get PCM | echo $?`"
if [ $STAT -ne 0 ]; then
echo "Mute"
else
echo "`amixer get PCM | awk '/Front\ Left:/ {print $5}' | sed 's/^\[\(.*\)\]$/\1/'`"
fi
}
red()
{
# Interfaz valida solo para wifi wlanX.
ESTADO="`/sbin/iwgetid`"
if [ "$ESTADO" != "" ]; then
ESSID="`/sbin/iwgetid --raw`"
INTERFAZ="`/sbin/iwgetid | awk '{print $1}'`"
SENAL="`/sbin/iwconfig 2> /dev/null | sed -n "/${INTERFAZ}/{n;n;n;n;n;p;}" | awk -F'=' '{printf $NF}' | sed 's/\s//g'`"
BITR="`/sbin/iwconfig 2> /dev/null | sed -n "/${INTERFAZ}/{n;n;p;}" | sed -E 's/^[^=]+=([.0-9]+)\s.*/\1Mb\/s/'`"
MI_MAC="`/sbin/ifconfig | grep $INTERFAZ | awk '{print $5}' | cut -c1-8`" # Mac de mi tarjeta, solo tres primeros pares.
AP="`/sbin/iwgetid --raw --ap | cut -c1-8`" # Mac del AP, solo tres primeros pares.
IP_EXT="`cat ~/scripts/data_xsetroot | sed -n '4p'`" # Contiene la ip externa, solo tres primeros octetos.
HOSTS="`cat ~/scripts/data_xsetroot | sed -n '2p'`" # Contiene el número de equipos conectados a nuestra red
echo "$ESSID($AP) $SENAL $BITR $INTERFAZ($MI_MAC) $IP_EXT $HOSTS"
else
echo "Sin conexion"
fi
}
temp(){
GRADOS=`sensors | sed -E -n '/Adapter: PCI adapter/{n;p;}' | sed -E 's/^.*\+([^ ]+)\s+$/\1/'`;
echo "$GRADOS";
}
#cancion()
#{
# if [ "`mocp --info | wc -l`" -ne 0 ]; then
# TITULO_B="`mocp -Q %song`"
# ARTISTA_B="`mocp -Q %artist`"
## TOTAL="`mocp -i|awk '/TotalTime/ {print $2}'`"
# echo "$ARTISTA_B - $TITULO_B"
# else
# echo "Musica OFF"
# fi
#}
while true;
do
xsetroot -name "[ `volumen` ][ `temp` ][ `red` ]`date +"[ %a %d %b %Y %T ]"`"
sleep 5
done &
exec /usr/local/bin/dwm
El archivo data_xsetroot al que hago referencia lo genera este script que se ejecuta en `cron' cada 10 minutos.
#!/bin/bash
ESTADO="`/sbin/iwgetid`"
if [ "$ESTADO" != "" ]; then
INTERFAZ="`/sbin/iwgetid | awk '{print $1}'`"
IP_PRIV="`/sbin/ifconfig $INTERFAZ | grep "inet addr" | awk '{printf $2}' | cut --delimiter=':' --fields=2`" # Saca la ip privada.
NETMASK="`/sbin/ifconfig $INTERFAZ | grep "Mask" | awk -F':' '{printf $NF}'`" # Saca la máscara de nuestra red.
CDIR="`ipcalc $IP_PRIV $NETMASK | grep -w "Network:" | awk '{printf $2}'`" # Calcula la red en la que estamos, con la máscara en notación cdir.
ALIVE="`fping -a -g $CDIR 2> /dev/null | wc -l`" # Escanea los hosts de la red.
sed -i "2s/^.*$/${ALIVE}/" ~/scripts/data_xsetroot # Escribe la info a ese fichero.
IP_EXT="`curl --user-agent "Mozilla/4.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" --connect-timeout 20 --max-time 30 --retry 3 --retry-delay 2 --retry-max-time 30 --silent --stderr /dev/null ifconfig.me/ip`" # Obtenemos la ip pública.
IP_TRUNK="`echo $IP_EXT | awk -F'.' '{printf $1"."$2"."$3 }'`" # Cortamos el último octeto de la ip pública.
if [ "$IP_TRUNK" != ".." ]; then
sed -i "4s/^.*$/${IP_TRUNK}/" ~/scripts/data_xsetroot
else
sed -i "4s/^.*$/NO_IP/" ~/scripts/data_xsetroot
fi
ESSID_LOG="`/sbin/iwgetid --raw`" # Sacamos el essid de la red.
AP_LOG="`/sbin/iwgetid --raw --ap`" # Sacamos la mac del ap.
echo "`date +'[ %a %d %b %Y %T ]'` $ESSID_LOG $AP_LOG $IP_EXT $ALIVE" >> ~/.ip.log # Enviamos info estadística a ese fichero.
else
exit
fi
Archivo de configuración de dwm config.h completo.
/* See LICENSE file for copyright and license details. */
/* appearance */
static const char font[] = "-*-terminus-medium-r-*-*-12-*-*-*-*-*-*-*"; //Instalas xfonts-terminus para que tenga efecto.
static const char normbordercolor[] = "#FF0000"; //cccccc_rojo_ventanas en las que no estamos.
static const char normbgcolor[] = "#000000"; //cccccc_negro_fondo barra.
static const char normfgcolor[] = "#FFFF00"; //000000_amarillo_letras barra sin ejecutar nada.
static const char selbordercolor[] = "#00FF00"; //0066ff_verde_ventana en la que estamos.
static const char selbgcolor[] = "#545454"; //0066ff_gris_fondo barra al ejecutar terminal
static const char selfgcolor[] = "#FFFF00"; //ffffff_amarillo_letras barra al ejecutar terminal
static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int snap = 32; /* snap pixel */
static const Bool showbar = True; /* False means no bar */
static const Bool topbar = True; /* False means bottom bar */
/***k133***
const unsigned int pst = 1;
***k133***/
/* tagging */
static const char *tags[] = { "I", "II", "III", "IV", "V" };
static const Rule rules[] = {
/* class instance title tags mask isfloating monitor */
{ NULL, NULL, NULL, 0, False, -1 },
};
/* layout(s) */
static const float mfact = 0.5; /* factor of master area size [0.05..0.95] */
static const int nmaster = 1; /* number of clients in master area */
static const Bool resizehints = True; /* True means respect size hints in tiled resizals */
static const Layout layouts[] = {
/* symbol arrange function */
/* first entry is default */
{ "[F]", NULL }, /* no layout function means floating behavior */
{ "[T]", tile },
{ "[M]", monocle },
};
/* key definitions */
#define MODKEY Mod4Mask /*antes= Mod1Mask que es el alt, ahora esta la de windows*/
#define TAGKEYS(KEY,TAG) \
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/bash", "-c", cmd, NULL } } //***k133*** sh * bash
/* commands */
static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
static const char *termcmd[] = { "urxvt", "-geometry", "128x25", "-cr", "#CCCCCC", "-bg", "#080808", "-fg", "#CCCCCC", "-fn", "xft:Bitstream Vera Sans Mono:pixelsize=14", "-pe", "default,matcher,tabbed", NULL };
// static const char *lockmonitor[] = { "xlock", NULL };
static Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
// { MODKEY|ShiftMask, XK_z, spawn, {.v = lockmonitor } },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
TAGKEYS( XK_4, 3)
TAGKEYS( XK_5, 4)
TAGKEYS( XK_6, 5)
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
{ MODKEY|ShiftMask, XK_q, quit, {0} },
/***k133***
/usr/include/X11/keysymdef.h
{ MODKEY, XK_Right, view, {.ui = pst = pst << 1} },
{ MODKEY, XK_Left, view, {.ui = pst = pst >> 1} },
{ MODKEY, XK_Up, view, {.ui = 0} },
{ MODKEY, XK_Down, view, {.ui = 4} }, */
};
/* button definitions */
/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static Button buttons[] = {
/* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
// { ClkTagBar, 0, Button1, view, {0} },
// { ClkTagBar, 0, Button3, toggleview, {0} },
// { ClkTagBar, MODKEY, Button1, tag, {0} },
// { ClkTagBar, MODKEY, Button3, toggletag, {0} },
};
Escritorio limpio.
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
(Clickear en la imagen para agrandar.)
Escritorio ocupado.
You are not allowed to view links. You are not allowed to view links. Register or Login or You are not allowed to view links. Register or Login
(Clickear en la imagen para agrandar.)
Archivo .inputrc
set editing-mode vi
Configuración de vim vimrc
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
syntax on
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
" au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
" filetype plugin indent on
"endif
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
set showcmd " Show (partial) command in status line.
"set showmatch
"set ignorecase
"set smartcase
set incsearch " Incremental search
"set autowrite
"set hidden
"set mouse=a
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
set fileencoding=utf-8
set encoding=utf-8
set termencoding=utf-8
"set autoindent
set number " Numero de línea
set history=1000 " Recordar más lineas.
set tabstop=2 " Espacio para tabulador.
set shiftwidth=2 " Número de espacios que insertará el '>'
set expandtab " Los tabs los pasa a espacios.
set hlsearch " Resaltar búsquedas.
set textwidth=0 " No poner limite en ancho.
"set nowrap
" Corrección ortográfica.
" Descomentar la lineas para que la corrección solo se haga en ficheros con esas extensiones.
"augroup filetypedetect
"au BufNewFile,BufRead *.tex set spell
"au BufNewFile,BufRead *.txt set spell
"augroup END
set spell spelllang=es,en
set spellfile=/etc/vim/spell/es.utf-8.add
set printdevice=pdf " Para imprimir a pdf
set printoptions=syntax:y,paper:A4,left:5pc,right:5pc,top:5pc,bottom:5pc " Parámetros de impresión.
set printheader=%=%N " Cabecera en las hojas
set printfont=Monospace:h10
set printexpr=PrintFile(v:fname_in)
function! PrintFile(fname)
call system("lp " . (&printdevice == '' ? '' : ' -s -d' . &printdevice) . ' ' . a:fname)
call delete(a:fname)
return v:shell_error
endfunc
" Seteos especiales para archivos de programación.
autocmd FileType c,sh,sql,py,pl,html,php,xml setlocal cindent nospell autoindent
" Snippets
autocmd FileType c inoremap {<cr> {<cr><cr>}<up><tab>
autocmd FileType c inoremap print printf("",);<left><left><left><left>
" Uso de pliegues por indentación
set foldmethod=indent " Para pliegues con {{{,}}} poner marker.
"Si logs de los comandos introducidos
set viminfo=
"Esquema de resalto de sintaxis personalizado.
colorscheme elflord_mod

