Búsqueda de sitios web

Cómo darle un toque navideño a su terminal y shell de Linux


Es la época más maravillosa del año cuando el mundo está de humor navideño. Es la temporada más feliz de todas. En este artículo, mostraremos algunos trucos de Linux sencillos y divertidos para celebrar la temporada.

Le mostraremos cómo navidad su terminal y shell. Al final de esta guía, aprenderá cómo personalizar el indicador de shell utilizando variables Bash y caracteres de escape.

En Bash, es posible agregar emojis, cambiar colores, agregar estilos de fuente, así como ejecutar comandos que se ejecutan cada vez que se dibuja el mensaje, como para mostrar su rama git.

Lea también: Cómo personalizar los colores y el contenido de Bash en el indicador de terminal de Linux

Para personalizar el indicador de shell de Linux para que se adapte a esta temporada festiva navideña, debe realizar algunos cambios en su archivo ~/.bashrc.

vim ~/.bashrc

Agregue lo siguiente al final de su archivo ~/.bashrc.

print the git branch name if in a git project
parse_git_branch() {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)//'
}
set the input prompt symbol
ARROW="❯"
define text formatting
PROMPT_BOLD="$(tput bold)"
PROMPT_UNDERLINE="$(tput smul)"
PROMPT_FG_GREEN="$(tput setaf 2)"
PROMPT_FG_CYAN="$(tput setaf 6)"
PROMPT_FG_YELLOW="$(tput setaf 3)"
PROMPT_FG_MAGENTA="$(tput setaf 5)"
PROMPT_RESET="$(tput sgr0)"
save each section prompt section in variable
PROMPT_SECTION_SHELL="\[$PROMPT_BOLD$PROMPT_FG_GREEN\]\s\[$PROMPT_RESET\]"
PROMPT_SECTION_DIRECTORY="\[$PROMPT_UNDERLINE$PROMPT_FG_CYAN\]\W\[$PROMPT_RESET\]"
PROMPT_SECTION_GIT_BRANCH="\[$PROMPT_FG_YELLOW\]\`parse_git_branch\`\[$PROMPT_RESET\]"
PROMPT_SECTION_ARROW="\[$PROMPT_FG_MAGENTA\]$ARROW\[$PROMPT_RESET\]"
set the prompt string using each section variable
PS1="
🎄 $PROMPT_SECTION_SHELL ❄️  $PROMPT_SECTION_DIRECTORY 🎁 $PROMPT_SECTION_GIT_BRANCH 🌟
$PROMPT_SECTION_ARROW "

Guarde el archivo y ciérrelo.

Para que los cambios comiencen a funcionar, puede cerrar y volver a abrir la ventana de su terminal, o generar el ~/.bashrc usando el siguiente comando.

source ~/.bashrc

Este artículo apareció originalmente en el sitio web de ryanwhocodes.

¡Eso es todo! En este artículo, mostramos cómo personalizar su terminal y shell en Linux. Mostramos cómo personalizar el indicador de shell usando variables Bash y caracteres de escape. Si tiene alguna pregunta o comentario, comuníquese con el formulario de comentarios a continuación.