Visualizando mejor los comandos que ejecutamos desde la terminal

Genial este prompt que simplificara bastante la separacion del output por pantalla cuando ejecutemos varios comandos. Para usarlo creamos el fichero “.bash_ps1″ en nuestro directorio home, con el siguiente contenido:

# Fill with minuses

# (this is recalculated every time the prompt is shown in function prompt_command):

fill=”— ”
reset_style=’\[\033[00m\]‘

status_style=$reset_style’\[\033[0;90m\]‘ # grey color; use 0;37m for lighter color

prompt_style=$reset_style

command_style=$reset_style’\[\033[1;29m\]‘ # bold black

# Prompt variable:

PS1=”$status_style”‘$fill \t\n’”$prompt_style”‘${debian_chroot:+($debian_chroot)}\u@\h:\w\$’”$command_style ”

# Reset colour for command output

# (this one is invoked every time before a command is executed):

trap ‘echo -ne “\e[0m"' DEBUG

function prompt_command {

# create a $fill of all screen width minus the time string and a space:

let fillsize=${COLUMNS}-9

fill=""

while [ "$fillsize" -gt "0" ]

do

fill=”-${fill}” # fill with underscores to work on

let fillsize=${fillsize}-1

done

# If this is an xterm set the title to user@host:dir

case “$TERM” in

xterm*|rxvt*)

bname=`basename “${PWD/$HOME/~}”`

echo -ne “\033]0;${bname}: ${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007″

;;

*)

;;

esac

}

PROMPT_COMMAND=prompt_command

O lo descargamos desde aqui. Ahora añadimos al fichero ~/.bashrc   lo siguiente:

if [ -f "$HOME/.bash_ps1" ]; then
. “$HOME/.bash_ps1″
fi

Via | LifeHacker | Usemos Linux

Advertisement

12 Respuestas a “Visualizando mejor los comandos que ejecutamos desde la terminal”


  1. 1 luis octubre 1, 2011 a las 9:56 am

    ¿Has visto alguna vez un fichero .bash_profile en linux? Eso es para MacOSX. En Linux hay que insertarlo en .bashrc.

    Saludos.

  2. 5 Antc octubre 1, 2011 a las 5:57 pm

    bash: “/home/antc/.bash_ps1″: No existe el fichero o el directorio

    Eso es lo que me dice la terminal cuando la ejecuto a ver si me hechas una manilla, pinta muy interesante este promp

    • 6 Christopher octubre 1, 2011 a las 6:16 pm

      en tu .bashrc escribe lo que dice que escribas

      if [ -f "$HOME/.bash_ps1" ]; then
      . “$HOME/.bash_ps1″
      fi

      Borra las comillas dobles que estan y sustituyelas por otras escritas desde el teclado, wordpress le da formato a las comillas y la terminal las interpreta como otro caracter distinto.

  3. 7 Antc octubre 1, 2011 a las 10:28 pm

    No me aparece al inicio lo de last login pero ya me funciona. Mil gracias, muy estupido yo que siendo “programador” no me he dado cuenta de eso XD.

  4. 9 t.a.c. octubre 3, 2011 a las 8:37 am

    Yo uso prompt de colores por el mismo motivo.

  5. 10 josemi octubre 3, 2011 a las 4:58 pm

    Me podéis ayudar para ponerlo también en Guake??


Deja un comentario

Fill in your details below or click an icon to log in:

Logo de WordPress.com

You are commenting using your WordPress.com account. Log Out / Cambiar )

Twitter picture

You are commenting using your Twitter account. Log Out / Cambiar )

Facebook photo

You are commenting using your Facebook account. Log Out / Cambiar )

Connecting to %s





The next version of Ubuntu is coming soon




¿Es compatible tu equipo con Ubuntu?


( Muchos fondos de pantalla, aqui )

DESCARGATE SCIFI LIFE

365 Dias de Soledad
Me debes los sueños, las promesas y las noches rotas. Me debes la paz, la sonrisa y la esperanza robadas. Me debes la sangre, las lágrimas y el sudor vertido. Me debes las noches vacías, los abrazos anhelados. Me debes un beso de ajenjo de tu amarga boca.

The Ubuntu Counter Project - user number # 11961
Geo Visitors Map

 

octubre 2011
L M X J V S D
« sep   nov »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Blog Stats

  • 20,386,276 hits

Seguir

Get every new post delivered to your Inbox.

Únete a otros 620 seguidores