Last active
November 15, 2022 10:23
-
-
Save cknd/751fd05c29b1324eb5ec8fa168444394 to your computer and use it in GitHub Desktop.
some cobbled-together dotfiles, mostly to add the git branch to the bash prompt and to make history infinite, cross-session and searchable by arrow-up prefix completion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1) set CUDA paths even if this bash session isnt running interactively | |
export CUDA_HOME="/usr/local/cuda" | |
export PATH="$CUDA_HOME/bin:$PATH" | |
export LD_LIBRARY_PATH="$CUDA_HOME/lib64:$LD_LIBRARY_PATH" | |
export CPATH="$CUDA_HOME/include:$CPATH" | |
export LIBRARY_PATH="$CUDA_HOME/lib64:$LIBRARY_PATH" | |
export TF_MIN_GPU_MULTIPROCESSOR_COUNT='3' | |
export CUDA_VISIBLE_DEVICES='0' | |
# 2) If not running interactively, don't do most of the other things | |
case $- in | |
*i*) ;; | |
*) return;; | |
esac | |
# 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 | |
export LESS=RS # for scroll wheel support in git paging. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=565699 | |
# set a fancy prompt (non-color, unless we know we "want" color) | |
case "$TERM" in | |
xterm-color|*-256color) color_prompt=yes;; | |
esac | |
# git colors | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
#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[31m\]$(parse_git_branch)\[\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 | |
# some more ls aliases | |
alias ll='ls -alF' | |
alias la='ls -A' | |
alias l='ls -CF' | |
# 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 | |
## make history infinite, instantly updating and cross-session | |
# https://unix.stackexchange.com/a/18443 | |
HISTCONTROL=ignoredups | |
shopt -s histappend | |
# https://ss64.com/bash/history.html | |
PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND" | |
HISTSIZE= | |
HISTFILESIZE= | |
## some git shortcuts | |
alias g='git' | |
alias gs='git status' | |
alias ga='git add' | |
alias gd='git diff' | |
alias gp='git pull' | |
alias gc='git checkout' | |
alias gl='git log' | |
alias gb="git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'" | |
# alias gg="git log --graph --oneline --decorate --all" | |
alias gg="git log --topo-order --date=iso --graph --full-history --pretty=format:'%x08%x09%C(red)%h %C(cyan)%ad%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08%x08 %C(bold blue)%aN%C(reset)%C(bold yellow)%d %C(reset)%s'" | |
# shortcut for markdown -> pdf | |
pandocpdf() { | |
pandoc $1.md -o $1.pdf | |
okular $1.pdf --unique & | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Press up-arrow for previous matching command from history | |
"\e[A":history-search-backward | |
# Press down-arrow for next matching command from history | |
"\e[B":history-search-forward | |
## Move cursor by one word with Alt-arrows | |
"\e[1;3D": backward-word | |
"\e[1;3C": forward-word | |
## Move to beginning/end of line with ctrl-arrows | |
"\e[1;5C": end-of-line | |
"\e[1;5D": beginning-of-line | |
## no idea | |
"\e[3~": delete-char | |
"\e[2~": quoted-insert | |
#set input-meta on | |
#set output-meta on | |
#set completion-ignore-case on | |
#set show-all-if-ambiguous on | |
#TAB: menu-complete | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment