##nano ~/.bashrc ##Pegar: get_git_repo_branch() { if git rev-parse --show-toplevel &>/dev/null; then repo=$(basename "$(git rev-parse --show-toplevel)") branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) echo " ${repo}(${branch})" fi } # Colores en bold BOLDGREEN="\[\e[1;32m\]" # verde bold BOLDBLUE="\[\e[1;34m\]" # azul bold BOLDORANGE="\[\e[1;38;5;214m\]" # naranja bold (256-color) BOLDCYAN="\[\e[1;36m\]" # azul claro bold (cian) RESET="\[\e[0m\]" # reset # Prompt: # Línea 1: usuario@maquina (verde bold) : directorio (azul bold) + repo(branch) (naranja bold) # Línea 2: # # PS1="${BOLDCYAN}[\D{%m-%d} \A] ${RESET}${BOLDGREEN}\u@\h${RESET}:${BOLDBLUE}\w${RESET}\$(rb=\$(get_git_repo_branch); [ -n \"\$rb\" ] && echo \"${BOLDORANGE}\${rb}${RESET}\")\n# " PS1="${BOLDCYAN}[\D{%m-%d} \A] ${RESET}${BOLDGREEN}\u@\h${RESET}:${BOLDBLUE}\w${RESET}\$(rb=\$(get_git_repo_branch); [ -n \"\$rb\" ] && echo \"${BOLDORANGE}\${rb}${RESET}\")\n# " #Protección contra add . confirm_git_add() { # Detect if argument = "add ." if [[ "$@" == "add ." ]]; then echo -e "\033[1;33mAre you sure you want to run an 'add .'? (y/n):\033[0m" read -n 1 respuesta echo if [[ $respuesta == "y" || $respuesta == "Y" ]]; then command git add . else echo "Canceled" fi else command git "$@" fi } alias git='confirm_git_add' ##Fin pegar ##. ~/.bashrc