Skip to content

Instantly share code, notes, and snippets.

@jakubfiala
Last active January 13, 2021 08:32
Show Gist options
  • Save jakubfiala/0ac1608898726b587328d89ed6d531b0 to your computer and use it in GitHub Desktop.
Save jakubfiala/0ac1608898726b587328d89ed6d531b0 to your computer and use it in GitHub Desktop.
dotfiles
# ~/.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
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# 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
# 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 --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 -alF'
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
# 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
export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
[ -z "$PS1" ] && return
export CLICOLOR=1
is_git_repo() {
git rev-parse --is-inside-work-tree 2>&1
}
git_repo_name() {
if [ "$(is_git_repo)" == "true" ]; then
git config remote.origin.url 2> /dev/null \
| pcregrep -oi '(?<=git@github\.com:)(.*)(?=.git)'
else
echo ""
fi
}
git_repo_pwd() {
if [ "$(is_git_repo)" == "true" ]; then
echo "./$(git rev-parse --show-prefix 2> /dev/null | sed 's/.$//')"
else
echo ""
fi
}
parse_git_branch() {
if [ "$(is_git_repo)" == "true" ]; then
git branch 2> /dev/null \
| sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' \
| tr -d '()'
else
echo ""
fi
}
git_commit_sha() {
if [ "$(is_git_repo)" == "true" ]; then
git rev-parse --short HEAD
else
echo ""
fi
}
# iTerm tab title – repo name | position within repo | branch | current process
export PROMPT_COMMAND='echo -ne "\033]0; 🏡 $(git_repo_name :%s) 📍$(git_repo_pwd) 🌳$(parse_git_branch) ($(git_commit_sha)) 📏\007"'
# command prompt
PS1="🍺 \[\033[0;33m\]\[\033[0m\]\[\033[0;92m\]:\W\[\033[32m\]\\[\033[00m\] > \[\033[0m\]\[$(tput sgr0)\]"
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
alias starwars="telnet towel.blinkenlights.nl"
alias ableton="/Applications/Ableton\ Live\ 9\ Suite.app/Contents/MacOS/Live ; exit;"
# alias ls="ls -GFoash"
alias restartdns="sudo killall -HUP mDNSResponder"
# OSX hidden files
alias showhiddenfiles="defaults write com.apple.finder AppleShowAllFiles TRUE;killall Finder"
alias hidehiddenfiles="defaults write com.apple.finder AppleShowAllFiles FALSE;killall Finder"
# correct for being a twat
alias gut="git"
alias got="git"
# python is a long word
alias py="python3"
alias pyserver="python -m SimpleHTTPServer"
# colour for man pages
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'
# drush shortcuts
alias dca="drush cc all"
alias dcc="drush cc css-js && drush cc menu"
# git autocomplete
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
export GDRIVE_CONFIG_DIR="~/drive/"
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
export GEM_HOME="$HOME/.gems"
export PATH="$HOME/.gems/bin:$PATH"
export PATH="$HOME/Library/Python/2.7/lib/python/site-packages:$PATH"
###-begin-npm-completion-###
#
# npm command completion script
#
# Installation: npm completion >> ~/.bashrc (or ~/.zshrc)
# Or, maybe: npm completion > /usr/local/etc/bash_completion.d/npm
#
if type complete &>/dev/null; then
_npm_completion () {
local words cword
if type _get_comp_words_by_ref &>/dev/null; then
_get_comp_words_by_ref -n = -n @ -n : -w words -i cword
else
cword="$COMP_CWORD"
words=("${COMP_WORDS[@]}")
fi
local si="$IFS"
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \
COMP_LINE="$COMP_LINE" \
COMP_POINT="$COMP_POINT" \
npm completion -- "${words[@]}" \
2>/dev/null)) || return $?
IFS="$si"
if type __ltrim_colon_completions &>/dev/null; then
__ltrim_colon_completions "${words[cword]}"
fi
}
complete -o default -F _npm_completion npm
elif type compdef &>/dev/null; then
_npm_completion() {
local si=$IFS
compadd -- $(COMP_CWORD=$((CURRENT-1)) \
COMP_LINE=$BUFFER \
COMP_POINT=0 \
npm completion -- "${words[@]}" \
2>/dev/null)
IFS=$si
}
compdef _npm_completion npm
elif type compctl &>/dev/null; then
_npm_completion () {
local cword line point words si
read -Ac words
read -cn cword
let cword-=1
read -l line
read -ln point
si="$IFS"
IFS=$'\n' reply=($(COMP_CWORD="$cword" \
COMP_LINE="$line" \
COMP_POINT="$point" \
npm completion -- "${words[@]}" \
2>/dev/null)) || return $?
IFS="$si"
}
compctl -K _npm_completion npm
fi
###-end-npm-completion-###
vid_to_gif() {
filter="[0:v] setpts=0.5*PTS,fps=12,scale=$3:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse"
ffmpeg -i $1 -filter_complex $filter $2
}
export PATH="$PATH:${HOME}/code/depot_tools/"
# I DON'T CARE IF CATALINA DEPRECATED BASH I AM BOURNE AGAIN
export BASH_SILENCE_DEPRECATION_WARNING=1
# kube stuff
export KUBE_EDITOR="nano"
alias k="kubectl"
alias kgp="k get pods"
alias kedit="k edit deployment"
alias kdesc="k describe deployment"
alias kres="kubectl view-utilization namespaces -h"
source <(kubectl completion bash)
export GPG_TTY=$(tty)
[user]
name = jakubfiala
email = <my_email>
[alias]
st = status
ci = commit
cinv = commit --no-verify
br = branch
co = checkout
df = diff
lg = log --format=oneline --abbrev-commit --graph
brd = branch -D
rbs = rebase
rbsc = rebase --continue
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
pso = push origin
plo = pull origin
cia = commit -a
cp = cherry-pick
cps = cherry-pick --continue
[core]
editor = /usr/bin/nano
[status]
showUntrackedFiles = all
[push]
default = simple
[transfer]
fsckobjects = true
# A nice little github-like colorful, split diff right in the console.
# via http://owen.cymru/github-style-diff-in-terminal-with-icdiff/
[diff]
tool = icdiff
[difftool]
prompt = false
[difftool "icdiff"]
cmd = /usr/local/bin/icdiff --line-numbers $LOCAL $REMOTE
[push]
default = current
[commit]
gpgsign = true
[init]
defaultBranch = main

my dotfiles

Some of these require some dependencies, such as:

  • git
  • pcregrep
  • ffmpeg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment