diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/init/load-settings.sh | 81 | ||||
-rwxr-xr-x | bin/install.sh | 30 |
2 files changed, 21 insertions, 90 deletions
diff --git a/bin/init/load-settings.sh b/bin/init/load-settings.sh deleted file mode 100755 index cf1273a..0000000 --- a/bin/init/load-settings.sh +++ /dev/null | |||
@@ -1,81 +0,0 @@ | |||
1 | # trap 'exit.sh' EXIT | ||
2 | |||
3 | export SETTING_DIR=${SETTING_DIR:=$HOME/helper} | ||
4 | export BIN_DIR=~/bin | ||
5 | export PATH=$BIN_DIR:$PATH | ||
6 | export TERM=xterm-256color | ||
7 | export XDG_CONFIG_HOME=~/.config | ||
8 | export XDG_STATE_HOME=~/.local/share/ | ||
9 | export MAIL=$HOME/Maildir | ||
10 | if which nvim &>/dev/null; then | ||
11 | export EDITOR=nvim | ||
12 | export VISUAL=nvim | ||
13 | export TIG_EDITOR=nvim | ||
14 | export GIT_EDITOR=nvim | ||
15 | else | ||
16 | export EDITOR=vim | ||
17 | export VISUAL=vim | ||
18 | export TIG_EDITOR=vim | ||
19 | export GIT_EDITOR=vim | ||
20 | fi | ||
21 | |||
22 | # Get current shell | ||
23 | shell=$(</proc/$$/cmdline sed -E 's/(.)-.+$/\1/' | tr -d '[\0\-]') | ||
24 | export shell=${shell##*/} | ||
25 | |||
26 | # load custom aliases | ||
27 | source $SETTING_DIR/alias | ||
28 | |||
29 | # sourcr rc files in private/ and bin/ | ||
30 | [[ -d $SETTING_DIR/private ]] && for f in $SETTING_DIR/private/*; do source $f; done | ||
31 | find $SETTING_DIR/bin -not -executable -name '*rc' | while read rcfile; do source $rcfile; done | ||
32 | |||
33 | # local | ||
34 | PATH=$PATH:$HOME/.local/bin | ||
35 | # go | ||
36 | PATH=$PATH:$HOME/go/bin | ||
37 | # android-studio | ||
38 | PATH=$PATH:$HOME/android-studio/bin | ||
39 | # cargo | ||
40 | PATH=$PATH:$HOME/.cargo/bin | ||
41 | # yarn | ||
42 | PATH=$PATH:$HOME/.yarn/bin | ||
43 | # gem | ||
44 | PATH=$PATH:$HOME/.local/share/gem/ruby/3.0.0/bin | ||
45 | |||
46 | # fzf | ||
47 | if which fzf &>/dev/null; then | ||
48 | export FZF_COMPLETION_OPTS='--bind=ctrl-c:print-query' | ||
49 | export FZF_CTRL_T_OPTS='--no-multi --bind=ctrl-c:print-query' | ||
50 | export FZF_CTRL_R_OPTS='--bind=ctrl-c:print-query' | ||
51 | fzf_preview() { fzf --preview 'cat {}'; } | ||
52 | source ~/.fzf.${shell} | ||
53 | fi | ||
54 | |||
55 | # Set zsh or bash | ||
56 | if [[ $- =~ i ]]; then | ||
57 | if [[ $shell == zsh ]]; then | ||
58 | setopt extended_glob | ||
59 | fpath=($SETTING_DIR/zsh $fpath) | ||
60 | alias history='history -i' | ||
61 | autoload compinit; compinit | ||
62 | |||
63 | #autoload -U deer | ||
64 | #zle -N deer | ||
65 | #bindkey '\ek' deer | ||
66 | bindkey -s '\ek' 'fzf_preview ' | ||
67 | elif [[ $shell == bash ]]; then | ||
68 | shopt -s extglob | ||
69 | HISTTIMEFORMAT='%Y-%m-%d %T ' | ||
70 | |||
71 | bind -m emacs-standard -x '"\ek": fzf_preview' | ||
72 | fi | ||
73 | fi | ||
74 | |||
75 | # Apply nvm | ||
76 | [ -e $HOME/.config/nvm/nvm.sh ] && source "$HOME/.config/nvm/nvm.sh" | ||
77 | |||
78 | # Working DIR | ||
79 | [[ `pwd` == $HOME ]] && test -d ~/Downloads && cd ~/Downloads | ||
80 | |||
81 | true | ||
diff --git a/bin/install.sh b/bin/install.sh index cfc13d3..94f23e5 100755 --- a/bin/install.sh +++ b/bin/install.sh | |||
@@ -7,24 +7,36 @@ SETTING_DIR=${SETTING_DIR:-~/helper} | |||
7 | REPO=${REPO:-typebrook/helper} | 7 | REPO=${REPO:-typebrook/helper} |
8 | REMOTE=${REMOTE:-https://github.com/${REPO}.git} | 8 | REMOTE=${REMOTE:-https://github.com/${REPO}.git} |
9 | BRANCH=${BRANCH:-dev} | 9 | BRANCH=${BRANCH:-dev} |
10 | RCFILE=${RCFILE:-~/.$(basename $SHELL)rc} | 10 | COMMENT_IN_RCFILE="# $REPO: source custom shell settings" |
11 | PROFILE=profile.sh | ||
11 | 12 | ||
13 | case "$(basename $SHELL)" in | ||
14 | bash) RCFILE=~/.bashrc | ||
15 | ;; | ||
16 | zsh) RCFILE=~/.config/zsh/.zshrc | ||
17 | ;; | ||
18 | *) echo Current shell is not bash or zsh; exit 1; | ||
19 | ;; | ||
20 | esac | ||
21 | |||
22 | # If ~/helper doesn't exist, do git clone | ||
12 | if [ ! -d $SETTING_DIR ]; then | 23 | if [ ! -d $SETTING_DIR ]; then |
13 | git clone --depth=1 --branch "$BRANCH" "$REMOTE" "$SETTING_DIR" || { | 24 | git clone --depth=1 --branch "$BRANCH" "$REMOTE" "$SETTING_DIR" || { |
14 | error "git clone of helper repo failed" | 25 | error "git clone of helper repo failed" |
15 | exit 1 | 26 | exit 1 |
16 | } | 27 | } |
17 | fi | 28 | fi |
18 | 29 | ||
19 | # Write initial commands into .bashrc or .zshrc | 30 | # Write initial commands into .bashrc or .zshrc |
20 | sed -i'.bak' "\^# $REPO^, /^$/ d" $RCFILE | 31 | sed -i "\^$COMMENT_IN_RCFILE^, /^$/ d" $RCFILE |
21 | cat >>$RCFILE <<EOF | 32 | cat >>$RCFILE <<EOF |
22 | 33 | ||
23 | # $REPO | 34 | $COMMENT_IN_RCFILE |
24 | export SETTING_DIR=$SETTING_DIR | 35 | export SETTING_DIR=$SETTING_DIR |
25 | source \$SETTING_DIR/bin/init/load-settings.sh | 36 | source \$SETTING_DIR/$PROFILE |
37 | |||
26 | EOF | 38 | EOF |
27 | 39 | ||
40 | echo Add profile into $RCFILE | ||
28 | cd "$SETTING_DIR" || exit 1 | 41 | cd "$SETTING_DIR" || exit 1 |
29 | make | 42 | make |
30 | EOF | ||