aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/init/load-settings.sh81
-rwxr-xr-xbin/install.sh30
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
3export SETTING_DIR=${SETTING_DIR:=$HOME/helper}
4export BIN_DIR=~/bin
5export PATH=$BIN_DIR:$PATH
6export TERM=xterm-256color
7export XDG_CONFIG_HOME=~/.config
8export XDG_STATE_HOME=~/.local/share/
9export MAIL=$HOME/Maildir
10if which nvim &>/dev/null; then
11 export EDITOR=nvim
12 export VISUAL=nvim
13 export TIG_EDITOR=nvim
14 export GIT_EDITOR=nvim
15else
16 export EDITOR=vim
17 export VISUAL=vim
18 export TIG_EDITOR=vim
19 export GIT_EDITOR=vim
20fi
21
22# Get current shell
23shell=$(</proc/$$/cmdline sed -E 's/(.)-.+$/\1/' | tr -d '[\0\-]')
24export shell=${shell##*/}
25
26# load custom aliases
27source $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
31find $SETTING_DIR/bin -not -executable -name '*rc' | while read rcfile; do source $rcfile; done
32
33# local
34PATH=$PATH:$HOME/.local/bin
35# go
36PATH=$PATH:$HOME/go/bin
37# android-studio
38PATH=$PATH:$HOME/android-studio/bin
39# cargo
40PATH=$PATH:$HOME/.cargo/bin
41# yarn
42PATH=$PATH:$HOME/.yarn/bin
43# gem
44PATH=$PATH:$HOME/.local/share/gem/ruby/3.0.0/bin
45
46# fzf
47if 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}
53fi
54
55# Set zsh or bash
56if [[ $- =~ 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
73fi
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
81true
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}
7REPO=${REPO:-typebrook/helper} 7REPO=${REPO:-typebrook/helper}
8REMOTE=${REMOTE:-https://github.com/${REPO}.git} 8REMOTE=${REMOTE:-https://github.com/${REPO}.git}
9BRANCH=${BRANCH:-dev} 9BRANCH=${BRANCH:-dev}
10RCFILE=${RCFILE:-~/.$(basename $SHELL)rc} 10COMMENT_IN_RCFILE="# $REPO: source custom shell settings"
11PROFILE=profile.sh
11 12
13case "$(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 ;;
20esac
21
22# If ~/helper doesn't exist, do git clone
12if [ ! -d $SETTING_DIR ]; then 23if [ ! -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 }
17fi 28fi
18 29
19# Write initial commands into .bashrc or .zshrc 30# Write initial commands into .bashrc or .zshrc
20sed -i'.bak' "\^# $REPO^, /^$/ d" $RCFILE 31sed -i "\^$COMMENT_IN_RCFILE^, /^$/ d" $RCFILE
21cat >>$RCFILE <<EOF 32cat >>$RCFILE <<EOF
22 33
23# $REPO 34$COMMENT_IN_RCFILE
24export SETTING_DIR=$SETTING_DIR 35export SETTING_DIR=$SETTING_DIR
25source \$SETTING_DIR/bin/init/load-settings.sh 36source \$SETTING_DIR/$PROFILE
37
26EOF 38EOF
27 39
40echo Add profile into $RCFILE
28cd "$SETTING_DIR" || exit 1 41cd "$SETTING_DIR" || exit 1
29make 42make
30EOF