Skip to content

Commit

Permalink
dotfiles first draft
Browse files Browse the repository at this point in the history
  • Loading branch information
gnzsnz committed Dec 28, 2021
0 parents commit 5a8f48b
Show file tree
Hide file tree
Showing 7 changed files with 385 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .bash_logout
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions .bash_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# .bash_profile
# Load .bashrc and .profile if they exists

if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi

if [ -f ~/.profile ]; then
source ~/.profile
fi
234 changes: 234 additions & 0 deletions .bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
# .bashrc
#
#

# PATH
# Ensure user-installed binaries take precedence
export PATH="~/.local/bin:/usr/local/bin:/usr/local/sbin:$PATH"

# character set
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8

## pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
#
if command -v pyenv 1>/dev/null 2>&1; then
# eval "$(pyenv init -)"
eval "$(pyenv init --path)"
source $(pyenv root)/completions/pyenv.bash
eval "$(pyenv virtualenv-init -)"
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
fi
## end pyenv

# PYTHONSTARTUP
#export PYTHONSTARTUP="/Users/gonzo/.config/ptpythonstartup.py"

# gpip
gpip(){
PIP_REQUIRE_VIRTUALENV="" pip "$@"
}

gpip3(){
PIP_REQUIRE_VIRTUALENV="" pip3 "$@"
}

alias pipup='pip freeze | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U'
alias pipup3='pip3 freeze | grep -v '^\-e' | cut -d = -f 1 | xargs pip3 install -U'

# homebrew python pip
# pip should only run if there is a virtualenv currently activated
export PIP_REQUIRE_VIRTUALENV=true
# cache pip-installed packages to avoid re-downloading
export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache

# pip bash completion start
_pip_completion()
{
COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \
COMP_CWORD=$COMP_CWORD \
PIP_AUTO_COMPLETE=1 $1 ) )
}
complete -o default -F _pip_completion pip
# pip bash completion end

export JAVA_HOME=$(/usr/libexec/java_home)

# OS specific
if [[ "$OSTYPE" == "darwin"* ]]; then
# Mac OSX
#textmate
export EDITOR="/usr/local/bin/atom -w"
# Typora
alias typora="open -a typora"

# Set architecture flags
export ARCHFLAGS="-arch x86_64"

# http://natelandau.com/my-mac-osx-bash_profile/
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad

elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
# 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) 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 --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

fi
# end OS specific

### LESS ###
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# Enable syntax-highlighting in less.
# brew install source-highlight
# First, add these two lines to ~/.bashrc
if [ -f "/usr/local/bin/src-hilite-lesspipe.sh" ]; then
export LESSOPEN="|/usr/local/bin/src-hilite-lesspipe.sh %s" LESS_ADVANCED_PREPROCESSOR=1
fi

export LESS=" -R -X -F"
alias less='less -m -N -g -i -J --underline-special --SILENT'
alias more='less'
# https://unix.stackexchange.com/questions/185544/no-colored-output-in-less-for-the-ls-command
export CLICOLOR_FORCE=1

alias cp='cp -iv' # Preferred 'cp' implementation
alias mv='mv -iv' # Preferred 'mv' implementation
alias mkdir='mkdir -pv' # Preferred 'mkdir' implementation
alias ll='ls -FGlAhp' # Preferred 'ls' implementation
# some more ls aliases
#alias ll='ls -halF'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# 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

#
# bash sensible defaults
# https://github.com/mrzool/bash-sensible
if [ -f ~/.config/sensible.bash ]; then
source ~/.config/sensible.bash
fi
# end bash.sensible

# git-prompt
if [ -f "/usr/local/opt/bash-git-prompt/share/gitprompt.sh" ]; then
__GIT_PROMPT_DIR="/usr/local/opt/bash-git-prompt/share"
source "/usr/local/opt/bash-git-prompt/share/gitprompt.sh"
fi
# git-prompt

#
alias config='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'

# gpg-agent
# https://blog.chendry.org/2015/03/13/starting-gpg-agent-in-osx.html
# https://chive.ch/security/2016/04/06/gpg-on-os-x.html
# gpg-agent with pinentry-mac

if [ -S "${GPG_AGENT_INFO%%:*}" ]; then
export GPG_AGENT_INFO
else
eval $( gpg-agent --daemon )
fi
# end gpg


# homebrew bash_completion
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi

# # The next line updates PATH for the Google Cloud SDK.
# if [ -f '/Users/gonzo/bin/google-cloud-sdk/path.bash.inc' ]; then
# . '/Users/gonzo/bin/google-cloud-sdk/path.bash.inc';
# fi
#
# # The next line enables shell command completion for gcloud.
# if [ -f '/Users/gonzo/bin/google-cloud-sdk/completion.bash.inc' ]; then
# . '/Users/gonzo/bin/google-cloud-sdk/completion.bash.inc';
# fi

# pass https://www.passwordstore.org/
source /usr/local/etc/bash_completion.d/pass

#torsocks
export TORSOCKS_CONF_FILE=/Users/gonzo/.torsocks.conf

# byobu
# byobu prompt
export BYOBU_PREFIX=/usr/local
[ -r /Users/gonzo/.byobu/prompt ] && . /Users/gonzo/.byobu/prompt
#byobu-prompt#

# kitty bash completion
#source <(kitty + complete setup bash)
source /dev/stdin <<<"$(kitty + complete setup bash)"
106 changes: 106 additions & 0 deletions .config/sensible.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Sensible Bash - An attempt at saner Bash defaults
# Maintainer: mrzool <http://mrzool.cc>
# Repository: https://github.com/mrzool/bash-sensible
# Version: 0.2.2

# Unique Bash version check
if ((BASH_VERSINFO[0] < 4))
then
echo "sensible.bash: Looks like you're running an older version of Bash."
echo "sensible.bash: You need at least bash-4.0 or some options will not work correctly."
echo "sensible.bash: Keep your software up-to-date!"
fi

## GENERAL OPTIONS ##

# Prevent file overwrite on stdout redirection
# Use `>|` to force redirection to an existing file
set -o noclobber

# Update window size after every command
shopt -s checkwinsize

# Automatically trim long paths in the prompt (requires Bash 4.x)
PROMPT_DIRTRIM=2

# Enable history expansion with space
# E.g. typing !!<space> will replace the !! with your last command
bind Space:magic-space

# Turn on recursive globbing (enables ** to recurse all directories)
shopt -s globstar 2> /dev/null

# Case-insensitive globbing (used in pathname expansion)
shopt -s nocaseglob;

## SMARTER TAB-COMPLETION (Readline bindings) ##

# Perform file completion in a case insensitive fashion
bind "set completion-ignore-case on"

# Treat hyphens and underscores as equivalent
bind "set completion-map-case on"

# Display matches for ambiguous patterns at first tab press
bind "set show-all-if-ambiguous on"

# Immediately add a trailing slash when autocompleting symlinks to directories
bind "set mark-symlinked-directories on"

## SANE HISTORY DEFAULTS ##

# Append to the history file, don't overwrite it
shopt -s histappend

# Save multi-line commands as one command
shopt -s cmdhist

# Record each line as it gets issued
PROMPT_COMMAND='history -a'

# Huge history. Doesn't appear to slow things down, so why not?
HISTSIZE=500000
HISTFILESIZE=100000

# Avoid duplicate entries
HISTCONTROL="erasedups:ignoreboth"

# Don't record some commands
export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history:clear"

# Use standard ISO 8601 timestamp
# %F equivalent to %Y-%m-%d
# %T equivalent to %H:%M:%S (24-hours format)
HISTTIMEFORMAT='%F %T '

# Enable incremental history search with up/down arrows (also Readline goodness)
# Learn more about this here: http://codeinthehole.com/writing/the-most-important-command-line-tip-incremental-history-searching-with-inputrc/
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
bind '"\e[C": forward-char'
bind '"\e[D": backward-char'

## BETTER DIRECTORY NAVIGATION ##

# Prepend cd to directory names automatically
shopt -s autocd 2> /dev/null
# Correct spelling errors during tab-completion
shopt -s dirspell 2> /dev/null
# Correct spelling errors in arguments supplied to cd
shopt -s cdspell 2> /dev/null

# This defines where cd looks for targets
# Add the directories you want to have fast access to, separated by colon
# Ex: CDPATH=".:~:~/projects" will look for targets in the current working directory, in home and in the ~/projects folder
CDPATH="."

# This allows you to bookmark your favorite places across the file system
# Define a variable containing a path and you will be able to cd into it regardless of the directory you're in
shopt -s cdable_vars

# Examples:
# export dotfiles="$HOME/dotfiles"
# export projects="$HOME/projects"
# export documents="$HOME/Documents"
# export dropbox="$HOME/Dropbox"

16 changes: 16 additions & 0 deletions .gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[filter "media"]
clean = git-media-clean %f
smudge = git-media-smudge %f
[user]
name = gonzo
email = [email protected]
signingkey = 5B9513CB
[commit]
gpgsign = true
[gpg]
program = gpg
[filter "lfs"]
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#
.dotfiles
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# My dotfiles

Table of Contents
* bash
* git
* gpg
* ssh
* tor socks

bash git prompt

0 comments on commit 5a8f48b

Please sign in to comment.