From 2698557789044a5bb56987c79e594c4b5933fa54 Mon Sep 17 00:00:00 2001 From: Karsten Hachmeister Date: Fri, 1 Jul 2022 21:15:39 +0200 Subject: [PATCH] add basic bash environment --- .bash_profile | 2 + .bashrc | 182 ++++++++++++++++++++++++++++++++++++++++++++++++++ .profile | 35 ++++++++++ 3 files changed, 219 insertions(+) create mode 100644 .bash_profile create mode 100644 .bashrc create mode 100644 .profile diff --git a/.bash_profile b/.bash_profile new file mode 100644 index 0000000..d5f7cc9 --- /dev/null +++ b/.bash_profile @@ -0,0 +1,2 @@ +[[ -f ~/.profile ]] && . ~/.profile +[[ -f ~/.bashrc ]] && . ~/.bashrc diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..437e2e8 --- /dev/null +++ b/.bashrc @@ -0,0 +1,182 @@ +# shellcheck disable=SC2148 + +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +# use date/time for history +HISTTIMEFORMAT="%F %T: " + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=100000 +HISTFILESIZE=100000 + +# Autocorrect typos in path names when using `cd`. +shopt -s cdspell + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# Bash attempts to save all lines of a multiple-line command in the same history entry. +# This allows easy re-editing of multi-line command. +shopt -s cmdhist + +# append to the history file, don't overwrite it +shopt -s histappend + +# Case-insensitive globbing (used in pathname expansion). +shopt -s nocaseglob + +# 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 + +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 --color=auto' + alias diff='diff --color=auto' + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# alias ls/tree to exa if exists +if [[ -x $(command -v exa) ]] ; then + alias ls="exa --icons" + alias tree="ls --tree" +fi + +alias l='ls -l' +alias ll='ls -la' + +# alternative find +if [[ -x "$(command -v fdfind)" ]] ; then + alias fd='fdfind' +fi + +# view/edit commands +if [[ -x "$(command -v view)" ]] ; then + alias v='view' +fi + +if [[ -x "$(command -v hx)" ]] ; then + alias edit='hx' + alias e='edit' +fi + +# neovim +if [[ -x "$(command -v nvim)" ]] ; then + alias vim='nvim' +fi + +# silver searcher with less +if [[ -x "$(command -v ag)" ]] ; then + alias agl='ag --pager "less -RF"' +fi + +# maven/java version +if [[ -x "$(command -v mvn)" ]] ; then + alias mvn11="JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 mvn" +fi + +# kitty terminal +if [[ -x "$(command -v kitty)" ]] ; then + [[ "$TERM" == "xterm-kitty" ]] && alias ssh="kitty +kitten ssh" +fi + +# kubecolor +if [[ -x "$(command -v kubecolor)" ]] ; then + alias k="kubecolor" + alias wk="watch -c kubecolor --force-colors" + complete -o default -F __start_kubectl kubecolor + complete -o default -F __start_kubectl k + complete -o default -F __start_kubectl wk +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 + +# git completions for rgit +if [[ -x "$(command -v rgit)" ]] ; then + if [ -f /usr/share/bash-completion/completions/git ] ; then + . /usr/share/bash-completion/completions/git + complete -o bashdefault -o default -o nospace -F __git_wrap__git_main rgit + fi +fi + +# kubectl completions +if [[ -x "$(command -v kubectl)" ]] ; then + . <(kubectl completion bash) +fi + +# avp completions +if [[ -x "$(command -v avp)" ]] ; then + . <(avp completion) +fi + +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +# Fuzzy search +source /usr/share/doc/fzf/examples/key-bindings.bash + +# thefuck +eval $(thefuck --alias) + +# Only load liquidprompt in interactive shells, not from a script or from scp +[[ $- == *i* ]] && [ -f /usr/share/liquidprompt/liquidprompt ] && . /usr/share/liquidprompt/liquidprompt + +# add local changes to your bash environment in ~/.bash_local +if [ -f ~/.bash_local ]; then + . ~/.bash_local +fi diff --git a/.profile b/.profile new file mode 100644 index 0000000..b37790a --- /dev/null +++ b/.profile @@ -0,0 +1,35 @@ +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi + +# set GOPATH and add bin directory to PATH variable +export GOPATH="$HOME/.local/lib/go" + +if [ -d "$GOPATH/bin" ] ; then + PATH="$GOPATH/bin:$PATH" +fi + +# set default options for less +# i: case-insensitive; R: use ANSI-Escape sequences +export LESS=iR + +# set exa colors +export EXA_COLORS="da=32" + +# use all cores with Makefile's +export MAKEFLAGS="-j$(nproc --all)" + +# Postgres env +export PGHOST=localhost +export PGUSER=knmav