From 123ba6e8152c64adaea75a7934c6a07042abaa49 Mon Sep 17 00:00:00 2001 From: dosnav Date: Wed, 10 Jun 2026 08:33:08 +0300 Subject: [PATCH] bash theme: prompt [HH:MM DD.MM.YYYY] with 256-color PS1 --- .bashrc | 45 +++++++++++++++++++++++++++++++++++++++++++++ install.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 .bashrc create mode 100755 install.sh diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..87be4a1 --- /dev/null +++ b/.bashrc @@ -0,0 +1,45 @@ +# ~/.bashrc + +if [ -z "$PS1" ]; then + [[ $- != *i* ]] && return +fi + +HISTCONTROL=ignoreboth +shopt -s histappend +HISTSIZE=1000 +HISTFILESIZE=2000 +shopt -s checkwinsize + +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# ---- theme ---- +PS1='\[\033[38;5;47m\][\A $(date +%d.%m.%Y)]\n[\[\033[38;5;$(if [ $EUID -eq 0 ]; then echo 199; else echo 69; fi)m\]\u\[\033[38;5;47m\]@\h \w:\$] \[\033[0m\]' +# --------------- + +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..3fe76cd --- /dev/null +++ b/install.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +set -e + +REPO_DIR="$(cd "$(dirname "$0")" && pwd)" +BASH_SRC="$REPO_DIR/.bashrc" + +install_user() { + local target="$1" + if [ -z "$target" ]; then + target="$HOME" + fi + if [ -f "$target/.bashrc" ] && [ ! -f "$target/.bashrc.bak" ]; then + cp "$target/.bashrc" "$target/.bashrc.bak" + echo "backup: $target/.bashrc -> $target/.bashrc.bak" + fi + cp "$BASH_SRC" "$target/.bashrc" + echo "installed: $target/.bashrc" + + if command -v chsh >/dev/null 2>&1; then + local shell_path + shell_path="$(command -v bash)" + if [ "$SHELL" != "$shell_path" ]; then + echo "change default shell to $shell_path? [y/N]" + read -r ans + if [ "$ans" = "y" ] || [ "$ans" = "Y" ]; then + chsh -s "$shell_path" + echo "default shell changed to bash" + fi + fi + fi +} + +install_system() { + if [ ! -f /etc/skel/.bashrc.bak ] && [ -f /etc/skel/.bashrc ]; then + cp /etc/skel/.bashrc /etc/skel/.bashrc.bak + echo "backup: /etc/skel/.bashrc -> /etc/skel/.bashrc.bak" + fi + cp "$BASH_SRC" /etc/skel/.bashrc + echo "installed: /etc/skel/.bashrc" +} + +case "${1:-user}" in + user) + install_user "${2:-$HOME}" + ;; + system) + install_system + ;; + *) + echo "usage: $0 [user|system] [target_dir]" + exit 1 + ;; +esac