-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprompt
87 lines (70 loc) · 2.92 KB
/
prompt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
# Unless running interactively, no need to continue
[[ $- != *i* ]] && return
# ------------------------------------------------------------------------------
# Set user-defined locale
# export LANG=$(locale -uU)
###############################################################################
# Shell behavior #
###############################################################################
# Increase the history file size and set some sane defaults
export HISTSIZE=20000
export HISTFILESIZE=10000
# See https://ostechnix.com/how-to-avoid-duplicate-entries-in-bash-history-in-linux/
export HISTCONTROL=ignoredups:erasedups:ignorespace
export HISTTIMEFORMAT="%d/%m/%y %T "
bash_prompt() {
# regular colors
local K="\[\033[0;30m\]" # black
local R="\[\033[0;31m\]" # red
local G="\[\033[0;32m\]" # green
local Y="\[\033[0;33m\]" # yellow
local B="\[\033[0;34m\]" # blue
local M="\[\033[0;35m\]" # magenta
local C="\[\033[0;36m\]" # cyan
local W="\[\033[0;37m\]" # white
# emphasized (bolded) colors
local BK="\[\033[1;30m\]"
local BR="\[\033[1;31m\]"
local BG="\[\033[1;32m\]"
local BY="\[\033[1;33m\]"
local BB="\[\033[1;34m\]"
local BM="\[\033[1;35m\]"
local BC="\[\033[1;36m\]"
local BW="\[\033[1;37m\]"
# reset
local RESET="\[\033[0;37m\]"
# curl -L -o ~/.git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
GIT_PROMPT_ONLY_IN_REPO=1
if [ -f /usr/share/git/git-prompt.sh ]; then
. /usr/share/git/git-prompt.sh
elif [ -f ~/.git-prompt.sh ]; then
. ~/.git-prompt.sh
elif [ -f ~/.bash-git-prompt/gitprompt.sh ]; then
. ~/.bash-git-prompt/gitprompt.sh
fi
local _PS_COLOR=32m
[ "$(id -u)" -eq 0 ] && _PS_COLOR=31m
# If the git completion function exists, then use its built-in command prompt
if command -v __git_ps1 > /dev/null; then
export PS1="\[\e]0;\w\a\]\n\[\e[$_PS_COLOR\]\u@\h\[\033[36m\]\`__git_ps1\`\[\e[0m\] \[\e[33m\]\w\[\e[0m\]\n> ";
else
export PS1="\[\e]0;\w\a\]\n\[\e[$_PS_COLOR\]\u@\h \[\e[33m\]\w\[\e[0m\]\n> ";
fi
}
# ------------------------------------------------------------------------------
# Is bash-completion installed ?
_init_complete;
# ------------------------------------------------------------------------------
# set PS1
[ -n "$BASH" ] && bash_prompt;
# ------------------------------------------------------------------------------
if command -v shopt > /dev/null; then
# there is `setopt` in zsh, but we prefer defaults for zsh
# Check the window size after each command and, if necessary, update the values of LINES and COLUMNS.
shopt -s checkwinsize
# Append all commands to the history file; don't overwrite it at the start of every new session
shopt -s histappend
fi
# Use vi keybindings
# set -o vi