aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/init/load-settings.sh
blob: c87c5c6113e29033c7014500777f1156851303d8 (plain)
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
export SETTING_DIR=${SETTING_DIR:=$HOME/settings}
export EDITOR=vim
export TERM=xterm-256color

# load custom aliases
source $SETTING_DIR/alias
[[ -d $SETTING_DIR/private ]] && for f in $SETTING_DIR/private/*; do source $f; done

# Config shell

shell=$(</proc/$$/cmdline tr -d '\0' | tr -d '-')
shell=${shell##*/}

# Add custom scripts into PATH
BIN_DIR=$HOME/bin
PATH=$PATH:$BIN_DIR
mkdir -p $BIN_DIR
find $BIN_DIR -xtype l | xargs rm 2>/dev/null || true

find $SETTING_DIR/tools -type f -executable | \
xargs realpath | xargs -I{} ln -sf {} $BIN_DIR

# Mail
MAIL=$HOME/Maildir

# sync with important git repos
(sync.sh &)

# local
PATH=$PATH:$HOME/.local/bin
# go
PATH=$PATH:$HOME/go/bin
# android-studio
PATH=$PATH:$HOME/android-studio/bin
# cargo
PATH=$PATH:$HOME/.cargo/bin
# yarn
PATH=$PATH:$HOME/.yarn/bin

# fzf
if which fzf &>/dev/null; then
  fzf_preview() { fzf --preview 'cat {}'; }
  source ~/.fzf.${shell} &>/dev/null
fi

if [[ $shell == zsh ]]; then
  setopt extended_glob
  fpath=($SETTING_DIR/zsh $fpath)
  compinit
  alias history='history -i'

  #autoload -U deer
  #zle -N deer
  #bindkey '\ek' deer
  bindkey -s '\ek' 'fzf_preview
'
elif [[ $shell == bash ]]; then
  shopt -s extglob
  HISTTIMEFORMAT='%Y-%m-%d %T '

  bind -m emacs-standard -x '"\ek": fzf_preview'
fi

# Run something after exit shell
trap 'exit.sh' EXIT

[[ `pwd` == $HOME ]] && cd ~/Downloads

true