bash theme: prompt [HH:MM DD.MM.YYYY] with 256-color PS1
This commit is contained in:
commit
123ba6e815
2 changed files with 98 additions and 0 deletions
45
.bashrc
Normal file
45
.bashrc
Normal file
|
|
@ -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
|
||||
53
install.sh
Executable file
53
install.sh
Executable file
|
|
@ -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
|
||||
Loading…
Add table
Reference in a new issue