forked from 0k/0k-charms
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
132 lines
3.4 KiB
132 lines
3.4 KiB
#!/bin/bash
|
|
|
|
## Requires kal-script
|
|
|
|
|
|
##
|
|
## More shell configurations (prompt, functions)
|
|
##
|
|
|
|
mkdir -p /etc/prompt
|
|
|
|
cat <<EOF > /etc/prompt/prompt.1.rc
|
|
PROMPT_COMMAND=""
|
|
parse_git_branch() {
|
|
ref=\$(git symbolic-ref HEAD 2> /dev/null) || return
|
|
echo -en ' (\033[0;32m'\${ref#refs/heads/}'\033[0m)'
|
|
}
|
|
export PS1="\[\033[0;37m\][\[\033[1;30m\]\u\[\033[0;37m\]@\[\033[1;30m\]\H\[\033[0;37m\]]-[\[\033[1;34m\]\w\[\033[0;37m\]]\\\$(parse_git_branch)\n\[\033[1;37m\]\\$ \[\033[0;37m\]"
|
|
EOF
|
|
|
|
if [ -f /root/.bashrc.pre-install ]; then
|
|
cp /root/.bashrc.pre-install /root/.bashrc
|
|
else
|
|
cp /root/.bashrc /root/.bashrc.pre-install
|
|
fi
|
|
|
|
|
|
|
|
if ! type -p fzf; then
|
|
|
|
## Required to get fzf
|
|
case $(lsb_release -is) in
|
|
Debian)
|
|
case $(lsb_release -rs) in
|
|
9)
|
|
backports_list="/etc/apt/sources.list.d/backports.list"
|
|
if ! [ -e "$backports_list" ]; then
|
|
echo "deb http://ftp.debian.org/debian stretch-backports main" > \
|
|
"$backports_list"
|
|
## Update only this repo:
|
|
apt-get update -o Dir::Etc::sourcelist="sources.list.d/backports.list" \
|
|
-o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
|
|
fi
|
|
|
|
;;
|
|
esac
|
|
;;
|
|
esac
|
|
|
|
apt-get install fzf </dev/null
|
|
fi
|
|
|
|
if ! type -p fd-find; then
|
|
if apt-get install fd-find </dev/null; then
|
|
ln -sf "$(which fdfind)" /usr/local/bin/fd
|
|
else
|
|
wget https://github.com/sharkdp/fd/releases/download/v8.2.1/fd_8.2.1_amd64.deb -O /tmp/fd.deb
|
|
dpkg -i /tmp/fd.deb
|
|
fi
|
|
fi
|
|
|
|
if ! [ -e "/usr/share/doc/fzf/examples/key-bindings.bash.orig" ]; then
|
|
## Use C-f instead of C-t for file insertion
|
|
sed -r -i.orig 's/C-t/C-f/g' /usr/share/doc/fzf/examples/key-bindings.bash
|
|
fi
|
|
|
|
cat <<EOF >> /root/.bashrc
|
|
|
|
## History management
|
|
|
|
export HISTCONTROL=ignoreboth
|
|
export HISTSIZE=500000
|
|
export HISTIGNORE="&:[bf]g:exit:ls:history"
|
|
export HISTFILESIZE=
|
|
export HISTTIMEFORMAT="%Y-%m-%d %T "
|
|
|
|
shopt -s histappend
|
|
|
|
|
|
## Prompt easy management
|
|
|
|
prompt() {
|
|
prompt_name="prompt.\$1.rc"
|
|
|
|
for i in /etc/prompt ~/.prompt; do
|
|
[ -f "\$i/\$prompt_name" ] &&
|
|
. "\$i/\$prompt_name"
|
|
done
|
|
}
|
|
|
|
|
|
## Git log command
|
|
|
|
function glog() {
|
|
git log --graph --pretty=tformat:%C\(yellow\ normal\)%h%Creset\ %C\(blue\ normal\)%an%Creset\ %s\ %Cgreen%d%Creset -n 20 "\$@"
|
|
}
|
|
|
|
prompt 1
|
|
|
|
PROMPT_COMMAND='history -a' ## after prompt setting as it resets it
|
|
|
|
|
|
##
|
|
## fzf (apt-get install fzf) and fd (apt-get install fd-find)
|
|
##
|
|
|
|
if [ -e /usr/share/doc/fzf/examples/key-bindings.bash ]; then
|
|
. /usr/share/doc/fzf/examples/key-bindings.bash
|
|
fi
|
|
|
|
if [ -e /usr/share/doc/fzf/examples/completion.bash ]; then
|
|
. /usr/share/doc/fzf/examples/completion.bash
|
|
fi
|
|
|
|
#export FZF_DEFAULT_OPTS="--color 'fg:#bbccdd,fg+:#ddeeff,bg:#111820,preview-bg:#223344,border:#778899'"
|
|
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
|
|
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
|
|
|
|
|
|
EOF
|
|
|
|
cat <<EOF >> /root/.bash_profile
|
|
|
|
## XXXvlab:
|
|
## http://stackoverflow.com/questions/9652126/bashrc-profile-is-not-loaded-on-new-tmux-session-or-window-why
|
|
## Including ``.bashrc`` if it exists (tmux don't load bashrc, and bashrc
|
|
## don't load profile... so not recursive call)
|
|
if [ -f ~/.bashrc ]; then
|
|
. ~/.bashrc
|
|
fi
|
|
|
|
EOF
|