diff --git a/.bash_logout b/.bash_logout new file mode 100644 index 0000000..de4f5f7 --- /dev/null +++ b/.bash_logout @@ -0,0 +1,7 @@ +# ~/.bash_logout: executed by bash(1) when login shell exits. + +# when leaving the console clear the screen to increase privacy + +if [ "$SHLVL" = 1 ]; then + [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q +fi diff --git a/.bash_profile b/.bash_profile index af35cb8..7b48336 100644 --- a/.bash_profile +++ b/.bash_profile @@ -1,2 +1,11 @@ -#!/usr/bin/env bash +# ~/.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 + [[ -f ~/.bashrc ]] && . ~/.bashrc diff --git a/.bashrc b/.bashrc index b99d65b..c2e5e00 100644 --- a/.bashrc +++ b/.bashrc @@ -1,33 +1,60 @@ -#!/usr/bin/env bash -if [ -d /etc/skel/.bashrc ] -then - source /etc/skel/.bashrc -fi +# freedesktop +# see: https://wiki.archlinux.org/index.php/XDG_Base_Directory +export XDG_CONFIG_HOME=$HOME/.config +export XDG_CACHE_HOME=$HOME/.cache +export XDG_DATA_HOME=$HOME/.local/share +export XDG_STATE_HOME=$HOME/.local/state export EDITOR=vim -export PATH=$PATH:$HOME/.local/bin:$HOME/.local/opt/node/bin + +if [ -d /etc/skel/.bashrc ] +then + source /etc/skel/.bashrc +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi + +if [ -d "$HOME/.local/opt/java/bin" ] ; then + PATH="$HOME/.local/opt/java/bin:$PATH" +fi + +if [ -d "$HOME/.local/opt/node/bin" ] ; then + PATH="$HOME/.local/opt/node/bin:$PATH" +fi + +if [ -d "$HOME/.local/opt/go/bin" ] ; then + PATH="$HOME/.local/opt/go/bin:$PATH" +fi # autocompletion if [ $(which brew) ]; then if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix)/etc/bash_completion fi +else + if [ -s /usr/share/bash-completion/completions/git ]; then + . /usr/share/bash-completion/completions/git + fi fi alias config='/usr/bin/git --git-dir=$HOME/Development/nemoinho/gitea.nehrke.info/nemoinho/dotfiles --work-tree=$HOME' alias lg='git lg' +alias lgb='git lgb' alias co='git checkout' alias push='git push' alias commit='git commit' alias gc='git commit' alias st='git status' alias gd='git diff' +alias gt='git gt' alias gdc='gd --cached' +alias c='git commit' alias markdown_pdf="docker run --rm -v \$PWD:/opt/docs auchida/markdown-pdf markdown-pdf" alias vimwiki='vim -c VimwikiIndex -c "cd %:p:h"' alias wiki='vim -c VimwikiIndex -c "cd %:p:h"' -alias mintern="xrandr | grep ' connected' | cut -d' ' -f1-3 | sed 's/\\(^[A-Z0-9]\\{1,\\}\\).*primary/--output \\1 --auto/;s/\\(^[A-Z0-9]\\{1,\\}\\).*/--output \\1 --off/' | xargs xrandr && xbacklight -set 100" -alias mextern="xrandr | grep ' connected' | cut -d' ' -f1-3 | sed 's/\\(^[A-Z0-9]\\{1,\\}\\).*primary/--output \\1 --off/;s/\\(^[A-Z0-9]\\{1,\\}\\).*/--output \\1 --auto/' | tr '\\n' ' ' | sed 's/\\([A-Z0-9]\\{1,\\}\\) --auto --output [A-Z0-9]\\{1,\\}/\\0 --right-of \\1/' | xargs xrandr && xbacklight -set 100" __git_complete config __git_main @@ -47,20 +74,25 @@ if [ -d $(dirname $GIT_PROMPT_SH) ]; then export GIT_PS1_SHOWUPSTREAM='auto' if [ -f $GIT_PROMPT_SH ]; then source $GIT_PROMPT_SH - PS1='\t \[\e]0;\u@\h: \w$(__git_ps1)\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\n\t$(__git_ps1 " (%s)") \$ ' - MY_GIT_PROMPT_COMMAND='__git_ps1 "\[\e]0;\u@\h: \w\n\t$(__git_ps1) \a\]\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\n\t" " \\\$ ";' + PS1='\t \[\e]0;\u@\h: \w$(__git_ps1)\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]: \[\033[01;34m\]\w\[\033[00m\] \t$(__git_ps1 " (%s)") \$ ' + MY_GIT_PROMPT_COMMAND='__git_ps1 "\[\e]0;\u@\h: \w \t$(__git_ps1) \a\]\[\033[01;32m\]\u@\h\[\033[00m\]: \[\033[01;34m\]\w\[\033[00m\] \t\n" "\\\$ " "(%s) ";' PROMPT_COMMAND=${MY_GIT_PROMPT_COMMAND}${PROMPT_COMMAND} fi fi -[ ! -d ~/.local/state/bash-history ] && mkdir ~/.local/state/bash-history +[ ! -d $XDG_STATE_HOME/bash/log ] && mkdir -p $XDG_STATE_HOME/bash/log export HISTTIMEFORMAT="%d/%m/%y %T " export HISTSIZE=40000 export HISTFILESIZE=50000 +export HISTFILE=$XDG_STATE_HOME/bash/bash_history -MY_HISTORY_PROMPT_COMMAND='if [ "$(id -u)" -ne 0 ]; then echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history 1)" >> ~/.local/state/bash-history/bash-history-$(date "+%Y-%m-%d").log; fi;' +MY_HISTORY_PROMPT_COMMAND='if [ "$(id -u)" -ne 0 ]; then echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history 1)" >> '$XDG_STATE_HOME'/bash/log/bash-history-$(date "+%Y-%m-%d").log; fi;' PROMPT_COMMAND=${MY_HISTORY_PROMPT_COMMAND}${PROMPT_COMMAND} +[ -s $XDG_CONFIG_HOME/broot/launcher/bash/br ] && source $XDG_CONFIG_HOME/broot/launcher/bash/br + +which fly &>/dev/null && source <(fly completion --shell bash) + #THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!! export SDKMAN_DIR="$HOME/.sdkman" [[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"