.bashrc
· 6.3 KiB · Bash
Eredeti
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth:erasedups
# append to the history file, don't overwrite it
shopt -s histappend cmdhist lithist
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=100000
HISTFILESIZE=500000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
blue="\033[0;34m"
nocolor="\033[0m"
day=$(date +%A)
case $day in
Monday)
hari="Senin"
;;
Tuesday)
hari="Selasa"
;;
Wednesday)
hari="Rabu"
;;
Thursday)
hari="Kamis"
;;
Friday)
hari="Jum'at"
;;
Saturday)
hari="Sabtu"
;;
Sunday)
hari="Ahad"
;;
*)
hari="Tidak diketahui"
;;
esac
month=$(date +%B)
case $month in
January)
bulan="Januari"
;;
February)
bulan="Februari"
;;
March)
bulan="Maret"
;;
April)
bulan="April"
;;
May)
bulan="Mei"
;;
June)
bulan="Juni"
;;
July)
bulan="Juli"
;;
August)
bulan="Agustus"
;;
September)
bulan="September"
;;
October)
bulan="Oktober"
;;
November)
bulan="November"
;;
December)
bulan="Desember"
;;
*)
bulan="Tidak diketahui"
;;
esac
#PS1='\[\e[38;5;160m\][\[\e[38;5;39m\]\D{%A, %d %B %Y}\[\e[0;1m\] - \[\e[38;5;184m\]\t\[\e[0;38;5;160m\]]\[\e[0m\]'
#HISTTIMEFORMAT=`echo -e ${blue}[${hari}, %d ${bulan} %Y - %T] $nocolor `
HISTTIMEFORMAT=`echo -e "\e[38;5;160m[\e[38;5;39m${hari}, %d ${bulan} %Y \e[0;1m - \e[38;5;184m %T\e[0;38;5;160m]\e[0m " `
HISTIGNORE="ls:ll:pwd:bg:fg:history:tree"
# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls -lah --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
#alias grep='grep --color=auto'
#alias fgrep='fgrep --color=auto'
#alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
#alias ll='ls -l'
#alias la='ls -A'
#alias l='ls -CF'
alias sudo="sudo "
alias ls="ls -lah --color=auto"
alias treeall="tree -ugsh --du"
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
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
##-----------------------------------------------------
## synth-shell-prompt.sh
if [ -f /home/$USER/.config/shell-prompt.sh ] && [ -n "$( echo $- | grep i )" ]; then
source /home/$USER/.config/shell-prompt.sh
else
wget https://gist.darto.id/dartokloning/def50cb1b3024c3b8683960c873caf34/download/HEAD/shell-prompt.sh -P /home/$USER/.config
source /home/$USER/.config/shell-prompt.sh
fi
if [ -f /usr/bin/vivid ]; then
#export LS_COLORS="$(vivid generate snazzy)"
##---------------------------------------------------------
## change LS_COLORS with random theme generated by vivid
##---------------------------------------------------------
# Define the list of items
themes=("alabaster_dark" "ayu" "catppuccin-frappe" "catppuccin-latte" "dracula" "iceberg-dark" "jellybeans" "lava" "molokai" "nord" "one-dark" "one-light" "rose-pine" "rose-pine-dawn" "snazzy" "solarized-dark" "tokyonight-moon" "zenburn")
# Get the current date in YYYYMMDD format
current_date=$(date +%Y%m%d)
# Use the date as a seed for the random number generator
RANDOM=$current_date
# Get a random index based on the number of items
random_index=$((RANDOM % ${#themes[@]}))
theme_now=${themes[$random_index]}
export LS_COLORS="$(vivid generate $theme_now)"
else
wget https://github.com/sharkdp/vivid/releases/download/v0.10.1/vivid_0.10.1_amd64.deb
sudo dpkg -i vivid_0.10.1_amd64.deb
rm vivid_0.10.1_amd64.deb
source /home/$USER/.bashrc
fi
| 1 | # ~/.bashrc: executed by bash(1) for non-login shells. |
| 2 | # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) |
| 3 | # for examples |
| 4 | |
| 5 | # If not running interactively, don't do anything |
| 6 | case $- in |
| 7 | *i*) ;; |
| 8 | *) return;; |
| 9 | esac |
| 10 | |
| 11 | # don't put duplicate lines or lines starting with space in the history. |
| 12 | # See bash(1) for more options |
| 13 | HISTCONTROL=ignoreboth:erasedups |
| 14 | |
| 15 | # append to the history file, don't overwrite it |
| 16 | shopt -s histappend cmdhist lithist |
| 17 | |
| 18 | # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) |
| 19 | HISTSIZE=100000 |
| 20 | HISTFILESIZE=500000 |
| 21 | |
| 22 | # check the window size after each command and, if necessary, |
| 23 | # update the values of LINES and COLUMNS. |
| 24 | shopt -s checkwinsize |
| 25 | |
| 26 | # If set, the pattern "**" used in a pathname expansion context will |
| 27 | # match all files and zero or more directories and subdirectories. |
| 28 | #shopt -s globstar |
| 29 | |
| 30 | blue="\033[0;34m" |
| 31 | nocolor="\033[0m" |
| 32 | |
| 33 | day=$(date +%A) |
| 34 | case $day in |
| 35 | Monday) |
| 36 | hari="Senin" |
| 37 | ;; |
| 38 | Tuesday) |
| 39 | hari="Selasa" |
| 40 | ;; |
| 41 | Wednesday) |
| 42 | hari="Rabu" |
| 43 | ;; |
| 44 | Thursday) |
| 45 | hari="Kamis" |
| 46 | ;; |
| 47 | Friday) |
| 48 | hari="Jum'at" |
| 49 | ;; |
| 50 | Saturday) |
| 51 | hari="Sabtu" |
| 52 | ;; |
| 53 | Sunday) |
| 54 | hari="Ahad" |
| 55 | ;; |
| 56 | *) |
| 57 | hari="Tidak diketahui" |
| 58 | ;; |
| 59 | esac |
| 60 | |
| 61 | month=$(date +%B) |
| 62 | case $month in |
| 63 | January) |
| 64 | bulan="Januari" |
| 65 | ;; |
| 66 | February) |
| 67 | bulan="Februari" |
| 68 | ;; |
| 69 | March) |
| 70 | bulan="Maret" |
| 71 | ;; |
| 72 | April) |
| 73 | bulan="April" |
| 74 | ;; |
| 75 | May) |
| 76 | bulan="Mei" |
| 77 | ;; |
| 78 | June) |
| 79 | bulan="Juni" |
| 80 | ;; |
| 81 | July) |
| 82 | bulan="Juli" |
| 83 | ;; |
| 84 | August) |
| 85 | bulan="Agustus" |
| 86 | ;; |
| 87 | September) |
| 88 | bulan="September" |
| 89 | ;; |
| 90 | October) |
| 91 | bulan="Oktober" |
| 92 | ;; |
| 93 | November) |
| 94 | bulan="November" |
| 95 | ;; |
| 96 | December) |
| 97 | bulan="Desember" |
| 98 | ;; |
| 99 | *) |
| 100 | bulan="Tidak diketahui" |
| 101 | ;; |
| 102 | esac |
| 103 | |
| 104 | #PS1='\[\e[38;5;160m\][\[\e[38;5;39m\]\D{%A, %d %B %Y}\[\e[0;1m\] - \[\e[38;5;184m\]\t\[\e[0;38;5;160m\]]\[\e[0m\]' |
| 105 | |
| 106 | #HISTTIMEFORMAT=`echo -e ${blue}[${hari}, %d ${bulan} %Y - %T] $nocolor ` |
| 107 | HISTTIMEFORMAT=`echo -e "\e[38;5;160m[\e[38;5;39m${hari}, %d ${bulan} %Y \e[0;1m - \e[38;5;184m %T\e[0;38;5;160m]\e[0m " ` |
| 108 | HISTIGNORE="ls:ll:pwd:bg:fg:history:tree" |
| 109 | |
| 110 | # make less more friendly for non-text input files, see lesspipe(1) |
| 111 | #[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" |
| 112 | |
| 113 | # set variable identifying the chroot you work in (used in the prompt below) |
| 114 | if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then |
| 115 | debian_chroot=$(cat /etc/debian_chroot) |
| 116 | fi |
| 117 | |
| 118 | # set a fancy prompt (non-color, unless we know we "want" color) |
| 119 | case "$TERM" in |
| 120 | xterm-color|*-256color) color_prompt=yes;; |
| 121 | esac |
| 122 | |
| 123 | # uncomment for a colored prompt, if the terminal has the capability; turned |
| 124 | # off by default to not distract the user: the focus in a terminal window |
| 125 | # should be on the output of commands, not on the prompt |
| 126 | #force_color_prompt=yes |
| 127 | |
| 128 | if [ -n "$force_color_prompt" ]; then |
| 129 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then |
| 130 | # We have color support; assume it's compliant with Ecma-48 |
| 131 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such |
| 132 | # a case would tend to support setf rather than setaf.) |
| 133 | color_prompt=yes |
| 134 | else |
| 135 | color_prompt= |
| 136 | fi |
| 137 | fi |
| 138 | |
| 139 | if [ "$color_prompt" = yes ]; then |
| 140 | PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' |
| 141 | else |
| 142 | PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' |
| 143 | fi |
| 144 | unset color_prompt force_color_prompt |
| 145 | |
| 146 | # If this is an xterm set the title to user@host:dir |
| 147 | case "$TERM" in |
| 148 | xterm*|rxvt*) |
| 149 | PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" |
| 150 | ;; |
| 151 | *) |
| 152 | ;; |
| 153 | esac |
| 154 | |
| 155 | # enable color support of ls and also add handy aliases |
| 156 | if [ -x /usr/bin/dircolors ]; then |
| 157 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" |
| 158 | alias ls='ls -lah --color=auto' |
| 159 | #alias dir='dir --color=auto' |
| 160 | #alias vdir='vdir --color=auto' |
| 161 | |
| 162 | #alias grep='grep --color=auto' |
| 163 | #alias fgrep='fgrep --color=auto' |
| 164 | #alias egrep='egrep --color=auto' |
| 165 | fi |
| 166 | |
| 167 | # colored GCC warnings and errors |
| 168 | #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' |
| 169 | |
| 170 | # some more ls aliases |
| 171 | #alias ll='ls -l' |
| 172 | #alias la='ls -A' |
| 173 | #alias l='ls -CF' |
| 174 | alias sudo="sudo " |
| 175 | alias ls="ls -lah --color=auto" |
| 176 | alias treeall="tree -ugsh --du" |
| 177 | |
| 178 | # Alias definitions. |
| 179 | # You may want to put all your additions into a separate file like |
| 180 | # ~/.bash_aliases, instead of adding them here directly. |
| 181 | # See /usr/share/doc/bash-doc/examples in the bash-doc package. |
| 182 | |
| 183 | if [ -f ~/.bash_aliases ]; then |
| 184 | . ~/.bash_aliases |
| 185 | fi |
| 186 | |
| 187 | # enable programmable completion features (you don't need to enable |
| 188 | # this, if it's already enabled in /etc/bash.bashrc and /etc/profile |
| 189 | # sources /etc/bash.bashrc). |
| 190 | if ! shopt -oq posix; then |
| 191 | if [ -f /usr/share/bash-completion/bash_completion ]; then |
| 192 | . /usr/share/bash-completion/bash_completion |
| 193 | elif [ -f /etc/bash_completion ]; then |
| 194 | . /etc/bash_completion |
| 195 | fi |
| 196 | fi |
| 197 | |
| 198 | ##----------------------------------------------------- |
| 199 | ## synth-shell-prompt.sh |
| 200 | if [ -f /home/$USER/.config/shell-prompt.sh ] && [ -n "$( echo $- | grep i )" ]; then |
| 201 | source /home/$USER/.config/shell-prompt.sh |
| 202 | else |
| 203 | wget https://gist.darto.id/dartokloning/def50cb1b3024c3b8683960c873caf34/download/HEAD/shell-prompt.sh -P /home/$USER/.config |
| 204 | source /home/$USER/.config/shell-prompt.sh |
| 205 | fi |
| 206 | |
| 207 | if [ -f /usr/bin/vivid ]; then |
| 208 | #export LS_COLORS="$(vivid generate snazzy)" |
| 209 | |
| 210 | ##--------------------------------------------------------- |
| 211 | ## change LS_COLORS with random theme generated by vivid |
| 212 | ##--------------------------------------------------------- |
| 213 | |
| 214 | # Define the list of items |
| 215 | themes=("alabaster_dark" "ayu" "catppuccin-frappe" "catppuccin-latte" "dracula" "iceberg-dark" "jellybeans" "lava" "molokai" "nord" "one-dark" "one-light" "rose-pine" "rose-pine-dawn" "snazzy" "solarized-dark" "tokyonight-moon" "zenburn") |
| 216 | |
| 217 | # Get the current date in YYYYMMDD format |
| 218 | current_date=$(date +%Y%m%d) |
| 219 | |
| 220 | # Use the date as a seed for the random number generator |
| 221 | RANDOM=$current_date |
| 222 | |
| 223 | # Get a random index based on the number of items |
| 224 | random_index=$((RANDOM % ${#themes[@]})) |
| 225 | theme_now=${themes[$random_index]} |
| 226 | |
| 227 | export LS_COLORS="$(vivid generate $theme_now)" |
| 228 | |
| 229 | else |
| 230 | |
| 231 | wget https://github.com/sharkdp/vivid/releases/download/v0.10.1/vivid_0.10.1_amd64.deb |
| 232 | sudo dpkg -i vivid_0.10.1_amd64.deb |
| 233 | rm vivid_0.10.1_amd64.deb |
| 234 | source /home/$USER/.bashrc |
| 235 | |
| 236 | fi |