diff options
Diffstat (limited to 'bin/init/load-settings.sh')
-rwxr-xr-x | bin/init/load-settings.sh | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/bin/init/load-settings.sh b/bin/init/load-settings.sh new file mode 100755 index 0000000..fcd6494 --- /dev/null +++ b/bin/init/load-settings.sh | |||
@@ -0,0 +1,70 @@ | |||
1 | trap 'exit.sh' EXIT | ||
2 | |||
3 | export SETTING_DIR=${SETTING_DIR:=$HOME/helper} | ||
4 | export EDITOR=vim | ||
5 | export TERM=xterm-256color | ||
6 | export XDG_CONFIG_HOME=~/.config | ||
7 | |||
8 | # Get current shell | ||
9 | export shell=$(</proc/$$/cmdline sed -E 's/(.)-.+$/\1/' | tr -d '[\0\-]') | ||
10 | shell=${shell##*/} | ||
11 | |||
12 | # load custom aliases | ||
13 | source $SETTING_DIR/alias | ||
14 | [[ -d $SETTING_DIR/private ]] && for f in $SETTING_DIR/private/*; do source $f; done | ||
15 | |||
16 | # Add custom scripts into PATH | ||
17 | BIN_DIR=$HOME/bin | ||
18 | PATH=$BIN_DIR:$PATH | ||
19 | mkdir -p $BIN_DIR | ||
20 | find $BIN_DIR -xtype l -exec rm {} + 2>/dev/null | ||
21 | find $SETTING_DIR/bin -type f -executable -exec realpath {} + | \ | ||
22 | xargs -I{} ln -sf {} $BIN_DIR | ||
23 | |||
24 | |||
25 | MAIL=$HOME/Maildir | ||
26 | |||
27 | # sync with important git repos | ||
28 | setsid sync.sh | ||
29 | |||
30 | # local | ||
31 | PATH=$PATH:$HOME/.local/bin | ||
32 | # go | ||
33 | PATH=$PATH:$HOME/go/bin | ||
34 | # android-studio | ||
35 | PATH=$PATH:$HOME/android-studio/bin | ||
36 | # cargo | ||
37 | PATH=$PATH:$HOME/.cargo/bin | ||
38 | # yarn | ||
39 | PATH=$PATH:$HOME/.yarn/bin | ||
40 | |||
41 | # fzf | ||
42 | if which fzf &>/dev/null; then | ||
43 | fzf_preview() { fzf --preview 'cat {}'; } | ||
44 | source ~/.fzf.${shell} &>/dev/null | ||
45 | fi | ||
46 | |||
47 | # Set zsh or bash | ||
48 | if [[ $- =~ i ]]; then | ||
49 | if [[ $shell == zsh ]]; then | ||
50 | setopt extended_glob | ||
51 | fpath=($SETTING_DIR/zsh $fpath) | ||
52 | alias history='history -i' | ||
53 | autoload compinit; compinit | ||
54 | |||
55 | #autoload -U deer | ||
56 | #zle -N deer | ||
57 | #bindkey '\ek' deer | ||
58 | bindkey -s '\ek' 'fzf_preview ' | ||
59 | elif [[ $shell == bash ]]; then | ||
60 | shopt -s extglob | ||
61 | HISTTIMEFORMAT='%Y-%m-%d %T ' | ||
62 | |||
63 | bind -m emacs-standard -x '"\ek": fzf_preview' | ||
64 | fi | ||
65 | fi | ||
66 | |||
67 | # Working DIR | ||
68 | [[ `pwd` == $HOME ]] && cd ~/Downloads | ||
69 | |||
70 | true | ||