Repository navigation
Expand file tree
/
Copy pathprofile
More file actions
112 lines (97 loc) · 2.91 KB
/
Copy pathprofile
File metadata and controls
112 lines (97 loc) · 2.91 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# trap 'exit.sh' EXIT
# 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 EDITOR=vim
export SYSTEMD_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
# Use process substitution, not a pipe: in bash, `cmd | while` runs the loop in a subshell
while read rcfile; do source $rcfile; done < <(find $HELPER_DIR/bin -not -executable -name '*rc')
while read dir; do PATH+=:${dir}; done < <(find $HELPER_DIR/bin -mindepth 1 -type d)
# }}}
# 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 ]] && return 0
# cd to working directory to adjacent pane
if [ -n "$TMUX_PANE" ]; then
up=$(tmux display-message -p -t '{up}' '#{pane_current_path}')
left=$(tmux display-message -p -t '{left}' '#{pane_current_path}')
dir=${up:-${left}}
[ -n "$dir" ] && cd $dir
fi
# Start X11 session on tty1 (autologin via getty@tty1 override, see make xinit)
if [ -z "$DISPLAY" ] && [ "$(tty)" = /dev/tty1 ] && which startx &>/dev/null; then
exec startx
fi
# attch to tmux session if exists
if which tmux &>/dev/null && [ -z $HERDR_ENV ]; then
test -z "$TMUX" && tmux attach
fi
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=$?
if [ -n "$_PS1_SIMPLE" ]; then
PS1="$_PS1_SIMPLE"
return
fi
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
# }}}
# claude code {{{
export CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN=1
#}}}
# for setting <C-W> in ~/.inputrc {{{
stty werase undef
# }}}
true