summaryrefslogtreecommitdiffstats
path: root/bashrc
blob: 3081691740f0a79e79fb679ddc2453e01b2fb14b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# ~/.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

# Use vi if not vim
case "$(command -v vim)" in
  */vim) VIM=vim ;;
  *)     VIM=vi  ;;
esac

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# 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=20000

# use colorls if it's installed, plain old ls otherwise
if command -v colorls > /dev/null ; then
  LS='colorls'
else
  LS='ls'
fi

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

PS1="\h:\w \u$ "

# Alias definitions.
if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
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

# source funcs and completion
for f in ~/.bash_completion.d/*; do source $f; done
for f in ~/.bash_functions.d/*; do source $f; done

# use GPG to encrypt files
secret () {
        output=~/Downloads/"${1}".$(date +%s).enc
        gpg --encrypt --armor --output ${output} -r matt@matthewlemon.com "${1}" && echo "${1} -> ${output}"
}

reveal () {
        output=$(echo "${1}" | rev | cut -c16- | rev)
        gpg --decrypt --output ${output} "${1}" && echo "${1} -> ${output}"
}

# journal funcs
todj () {
	CMD=cat
	if [[ $1 = "-vim" ]]; then
		CMD=vim
	fi
	$CMD $(find /home/lemon/Notes/journal -name "*$(date '+%Y-%m-%d')*")
}

tj () {
	if [[ -z $1 ]]; then
		echo "Please give me your message in quotes."
	fi
	echo $1 | _tj
}

tjclip () {
	if [[ -z $1 ]]; then
		echo "Please give me your message in quotes."
	fi
	echo "$1: $(xclip -o -selection clipboard)." | _tj
}

# GPG agent settings (https://github.com/hammerheadlemon/YubiKey-Guide)
# See Replace Agents section

export GPG_TTY="$(tty)"
#export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
#gpgconf --launch gpg-agent

# FZF
export FZF_DEFAULT_COMMAND='ag  -g ""'
export FZF_CTRL_T_COMMAND=$FZF_DEFAULT_COMMAND
export FZF_ALT_C_COMMAND=$FZF_DEFAULT_COMMAND
export FZF_DEFAULT_OPTS='--color info:108,prompt:109,spinner:108,pointer:168,marker:168'

#set TERM
export TERM="xterm-256color" 

[ -f ~/.fzf.bash ] && source ~/.fzf.bash

EDITOR=/usr/local/bin/vim