-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile
More file actions
88 lines (76 loc) · 2.16 KB
/
profile
File metadata and controls
88 lines (76 loc) · 2.16 KB
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
# trap 'exit.sh' EXIT
# attch to tmux session if exists {{{
if which tmux &>/dev/null; then
test -z "$TMUX" && tmux attach
fi
# }}}
# Global Env {{{
export PATH=~/.local/bin:$PATH
export HELPER_DIR=${HELPER_DIR:=$HOME/helper}
export TERM=xterm-256color
export XDG_CONFIG_HOME=~/.config
export XDG_STATE_HOME=~/.local/share/
export MAIL=$HOME/Mail
export EDITOR=vim
export VISUAL=$EDITOR
export TIG_EDITOR=$EDITOR
export GIT_EDITOR=$EDITOR
# }}}
# IM for GUI {{{
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
# }}}
# Custom Helper features {{{
# Get current shell
shell=$(</proc/$$/cmdline sed -E 's/(.)-.+$/\1/' | tr -d '[\0\-]')
export shell=${shell##*/}
# load custom aliases
source $HELPER_DIR/alias
# sourcr rc files in private/ and bin/
[[ -d $HELPER_DIR/private ]] && for f in $HELPER_DIR/private/*; do source $f; done
find $HELPER_DIR/bin -not -executable -name '*rc' | while read rcfile; do source $rcfile; done
find $HELPER_DIR/bin -mindepth 1 -type d | while read dir; do PATH+=:${dir}; done
# }}}
# fzf {{{
if which fzf &>/dev/null; then
export FZF_COMPLETION_OPTS='--bind=ctrl-c:print-query'
export FZF_CTRL_T_OPTS='--no-multi --bind=ctrl-c:print-query'
export FZF_CTRL_R_OPTS='--bind=ctrl-c:print-query'
fzf_preview() { fzf --preview 'cat {}'; }
[ -f ~/.fzf.${shell} ] && source ~/.fzf.${shell}
fi
# }}}
# Set config for interactive mode {{{
[[ ! $- =~ i ]] && exit 0
if [[ $shell == zsh ]]; then
setopt extended_glob interactive_comments
fpath=($HELPER_DIR/zsh $fpath)
alias history='history -i'
autoload compinit; compinit
#autoload -U deer
#zle -N deer
#bindkey '\ek' deer
bindkey -s '\ek' 'fzf_preview'
bindkey -s '' 'fg || vl'
fi
if [[ $shell == bash ]]; then
shopt -s extglob
HISTTIMEFORMAT='%Y-%m-%d %T '
bind -m emacs-standard -x '"\ek": fzf_preview'
_precmd() {
local exit_code=$?
local jobcount=$(jobs | wc -l)
local jobstring=""
[ "$jobcount" -gt 0 ] && jobstring="($jobcount)"
if [ $exit_code -eq 0 ]; then
PS1="\[\e[1;32m\]\h\[\e[0;1;36m\] \W\[\e[0m\]${jobstring} "
else
PS1="\[\e[1;41;30m\]\h\[\e[0;1;36m\] \W\[\e[0m\]${jobstring} "
fi
}
PROMPT_COMMAND=_precmd
fi
# }}}
true