summaryrefslogtreecommitdiff
path: root/.bashrc
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2020-02-16 13:23:56 -0500
committerluxagraf <sng@luxagraf.net>2020-02-16 13:23:56 -0500
commitcd507c92f617d4a8a3f7bb0b43e425491ef7184d (patch)
tree42144ef0f35b91e7955f570c5ecc4bcec3c4d780 /.bashrc
initial commit of dotfiles
Diffstat (limited to '.bashrc')
-rw-r--r--.bashrc351
1 files changed, 351 insertions, 0 deletions
diff --git a/.bashrc b/.bashrc
new file mode 100644
index 0000000..beddc2f
--- /dev/null
+++ b/.bashrc
@@ -0,0 +1,351 @@
+#basics
+stty -ixon
+#export BROWSER="firefox-developer-edition"
+export BROWSER="qutebrowser"
+#export BROWSER="vivaldi-stable"
+export EDITOR="nvim"
+export NOTES_DIR="$HOME/notes"
+export TERM="screen-256color"
+export GREP_COLOR='00;38;5;166'
+# my scripts on PATH
+export PATH=/usr/local/bin:$PATH
+export PATH=$PATH:$HOME/bin
+export PATH=$PATH:$HOME/bin/bash-scripts
+export PATH=$PATH:$HOME/.gem/ruby/2.6.0/bin
+export QT_QPA_PLATFORM=wayland
+export QT_QPA_PLATFORMTHEME=gtk3
+export XDG_SESSION_TYPE=wayland
+export GDK_BACKEND=wayland
+
+# Alias definitions
+if [ -f ~/.aliases ]; then
+ . ~/.aliases
+fi
+#make bash better
+bind "set completion-ignore-case on"
+bind "set completion-map-case on"
+bind "set show-all-if-ambiguous on"
+
+# 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'
+# Automatically trim long paths in the prompt (requires Bash 4.x)
+PROMPT_DIRTRIM=2
+
+# 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"
+
+# Useful timestamp format
+HISTTIMEFORMAT='%F %T '
+
+#Better, faster directory navigation
+shopt -s autocd
+shopt -s cdable_vars
+
+# Don't use ~ to define your home here, it won't work.
+export wir="$HOME/writing/wired"
+export reg="$HOME/writing/register"
+export ars="$HOME/writing/ars-technica/"
+export l="$HOME/writing/luxagraf/"
+export lux="$HOME/Sites/luxagraf"
+export d="$HOME/documents"
+export rec="$HOME/documents/recipes"
+
+CDPATH=".:~/writing:~/sites:~/documents"
+
+# Correct minor errors in the spelling of a directory
+shopt -s cdspell
+shopt -s dirspell
+
+# colorized man pages
+man() {
+ env \
+ LESS_TERMCAP_md=$(printf "\e[1;31m") \
+ LESS_TERMCAP_me=$(printf "\e[0m") \
+ LESS_TERMCAP_se=$(printf "\e[0m") \
+ LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
+ LESS_TERMCAP_ue=$(printf "\e[0m") \
+ LESS_TERMCAP_us=$(printf "\e[1;32m") \
+ man "$@"
+}
+
+# Git custom prompt
+export GITAWAREPROMPT=~/bin/git-aware-prompt
+source "${GITAWAREPROMPT}/main.sh"
+export PS1="\[\033[33;1m\]\[\033[m\]\$(pwd-prompt.bash) \[$txtred\]\$git_dirty\[$txtrst\]$ "
+
+# Complete all the things
+source ~/bin/pass-completion.bash
+
+
+# get a forecast:
+function fore(){
+ ~/./bin/weather-2.3/weather -f ${1:-30606}
+}
+
+
+#search any folder like you're in nvalt:
+function nv() {
+ find ${2:-~/notes} -maxdepth ${3:-1} -type f -print0 | xargs -0 grep -li $1
+}
+# same thing, but context
+function nvl(){
+ find ${2:-.} -maxdepth ${3:-1} -type f -print0 | xargs -0 grep -i -n -E $1 | less -R
+}
+
+#find in "notes" which might be in any of half a dozen folders
+function fnt(){
+ find ~/notes ~/documents/bookmarks ~/documents/reading\ notes -type f -maxdepth 2 -print0 | xargs -0 grep -$2i $1
+}
+
+#fuzzy find
+function f() {
+ find ${2:-.} -name \*$1\*
+}
+
+
+
+function tolux() {
+ scp $3 $1 lxf:/home/lxf/$2
+}
+
+function frlux() {
+ scp $3 lxf:/home/lxf/$1 $2
+}
+
+function maketar() { tar cvzf "${1%%/}.tar.gz" "${1%%/}/"; }
+function extract() # Handy Extract Program
+{
+ if [ -f $1 ] ; then
+ case $1 in
+ *.tar.bz2) tar xvjf $1 ;;
+ *.tar.gz) tar xvzf $1 ;;
+ *.bz2) bunzip2 $1 ;;
+ *.rar) unrar x $1 ;;
+ *.gz) gunzip $1 ;;
+ *.tar) tar xvf $1 ;;
+ *.tbz2) tar xvjf $1 ;;
+ *.tgz) tar xvzf $1 ;;
+ *.zip) unzip $1 ;;
+ *.Z) uncompress $1 ;;
+ *.7z) 7z x $1 ;;
+ *) echo "'$1' cannot be extracted via >extract<" ;;
+ esac
+ else
+ echo "'$1' is not a valid file!"
+ fi
+}
+
+
+# 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
+
+# Create a new directory and enter it
+function md() {
+ mkdir -p "$@" && cd "$@"
+}
+
+# Encode webm:
+function webm() {
+ ffmpeg -i $1 -c:v libvpx -quality good -cpu-used 0 -b:v 7000k -qmin 10 -qmax 42 -maxrate 500k -bufsize 2500k -threads 8 -vf scale=-1:720 -c:a libvorbis -b:a 192k -f webm $1.webm
+}
+# encode ogg v:
+function ogv() {
+ ffmpeg -i $1 -codec:v libtheora -qscale:v 4 -s hd720 $1.ogv
+}
+function lamer() {
+ cd $1
+ for f in *
+ do
+ temp=$f
+ new=${temp%.*}
+ lame $f $new.mp3 -h -V 0 --vbr-new --verbose
+ done
+ cd -
+}
+
+# Start an HTTP server from a directory, optionally specifying the port
+function server() {
+ local port="${1:-8000}"
+ # Set the default Content-Type to `text/plain` instead of `application/octet-stream`
+ # And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
+ python3 -c $'from http import server\nmap = server.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nserver.test();' "$port"
+}
+
+
+# Start an HTTP server from a directory, optionally specifying the port
+function server2() {
+ local port="${1:-8000}"
+ # Set the default Content-Type to `text/plain` instead of `application/octet-stream`
+ # And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files)
+ python -c $'from BaseHTTPServer import BaseHTTPRequestHandler \nmap = BaseHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nserver.test();' "$port"
+}
+
+
+export DISABLE_AUTO_TITLE=”true”
+
+function smartresize() {
+ mogrify -path $3 -filter Triangle -define filter:support=2 -thumbnail $2 -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB $1
+}
+
+
+# words, they make me happy and I want to read them all page by page
+function d() {
+ sdcv "$1" | less
+}
+function book() {
+ local url
+ url=$(cat .config/qutebrowser/bookmarks/urls | fzf | cut -d ' ' -f 1) && qutebrowser "$url"
+}
+function timer(){
+ seconds="$((60*$1))"
+ date1=$((`date +%s` + $seconds));
+ while [ "$date1" -ge `date +%s` ]; do
+ echo -ne "$(date -u --date @$(($date1 - `date +%s`)) +%H:%M:%S)\r";
+ sleep 0.1
+ done
+ mpv ~/bin/clap.mp3 &>/dev/null
+}
+
+function markdone(){
+ echo '\n@done' >> "$1"
+ mkdir -p ~/gtd/done/$(date '+%Y-%m-%d')
+ mv "$1" ~/gtd/done/$(date '+%Y-%m-%d')
+ clear
+ @td
+}
+
+fd() {
+ local dir
+ dir=$(find ${1:-.} -path '*/\.*' -prune \
+ -o -type d -print 2> /dev/null | fzf +m) &&
+ cd "$dir"
+}
+
+if [[ "$OSTYPE" == "darwin"* ]]; then
+
+ # OSX-SPECIFIC SETTINGS
+
+ # enable programmable completion
+ if [ -f $(brew --prefix)/etc/bash_completion ]; then
+ . $(brew --prefix)/etc/bash_completion
+ fi
+
+ # get git completion working with my aliases
+ # Add git completion to aliases
+ __git_complete g __git_main
+ __git_complete gc _git_commit
+ __git_complete ga _git_add
+
+ # activates colors
+ export CLICOLOR=1
+
+ # ls custom colors
+ export LSCOLORS=ExFxBxDxCxegedabagacad
+
+ # Fix Python error 'unknown locale: UTF-8'
+ export LC_ALL=en_US.UTF-8
+ export LANG=en_US.UTF-8
+
+
+ # add homebrew bin folder to PATH
+ export PATH="/usr/local/bin:$PATH"
+
+ # Add Calibre command line tools
+ export PATH=$PATH:/Applications/calibre.app/Contents/MacOS
+elif [[ "$OSTYPE" == "linux-gnu" ]]; then
+
+ # LINUX-SPECIFIC SETTINGS
+
+ # set variable identifying the chroot you work in
+ 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
+ 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
+
+ # enable programmable completion features
+ 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
+
+ # Add RVM to PATH for scripting
+ export PATH="$PATH:$HOME/.rvm/bin"
+
+fi
+
+if ! pgrep -u $USER ssh-agent > /dev/null; then
+ ssh-agent > ~/.ssh-agent-thing
+fi
+if [[ "$SSH_AGENT_PID" == "" ]]; then
+ eval $(<~/.ssh-agent-thing)
+fi
+ssh-add -l >/dev/null || alias ssh='ssh-add -l >/dev/null || ssh-add && unalias ssh; ssh'
+
+#export WINEPREFIX=$HOME/.config/wine/
+#export WINEARCH=win32
+
+
+#PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"