From 59de29d5164d245dda1608f5e14cf4e1c981ad3e Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 25 Jun 2024 23:09:03 +0800 Subject: Update --- bin/init/load-settings.sh | 81 ----------------------------------------------- bin/install.sh | 30 ++++++++++++------ 2 files changed, 21 insertions(+), 90 deletions(-) delete mode 100755 bin/init/load-settings.sh (limited to 'bin') 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 @@ -# trap 'exit.sh' EXIT - -export SETTING_DIR=${SETTING_DIR:=$HOME/helper} -export BIN_DIR=~/bin -export PATH=$BIN_DIR:$PATH -export TERM=xterm-256color -export XDG_CONFIG_HOME=~/.config -export XDG_STATE_HOME=~/.local/share/ -export MAIL=$HOME/Maildir -if which nvim &>/dev/null; then - export EDITOR=nvim - export VISUAL=nvim - export TIG_EDITOR=nvim - export GIT_EDITOR=nvim -else - export EDITOR=vim - export VISUAL=vim - export TIG_EDITOR=vim - export GIT_EDITOR=vim -fi - -# Get current shell -shell=$(/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 {}'; } - source ~/.fzf.${shell} -fi - -# Set zsh or bash -if [[ $- =~ i ]]; then - if [[ $shell == zsh ]]; then - setopt extended_glob - fpath=($SETTING_DIR/zsh $fpath) - alias history='history -i' - autoload compinit; compinit - - #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 -fi - -# Apply nvm -[ -e $HOME/.config/nvm/nvm.sh ] && source "$HOME/.config/nvm/nvm.sh" - -# Working DIR -[[ `pwd` == $HOME ]] && test -d ~/Downloads && cd ~/Downloads - -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} REPO=${REPO:-typebrook/helper} REMOTE=${REMOTE:-https://github.com/${REPO}.git} BRANCH=${BRANCH:-dev} -RCFILE=${RCFILE:-~/.$(basename $SHELL)rc} +COMMENT_IN_RCFILE="# $REPO: source custom shell settings" +PROFILE=profile.sh +case "$(basename $SHELL)" in + bash) RCFILE=~/.bashrc + ;; + zsh) RCFILE=~/.config/zsh/.zshrc + ;; + *) echo Current shell is not bash or zsh; exit 1; + ;; +esac + +# If ~/helper doesn't exist, do git clone if [ ! -d $SETTING_DIR ]; then - git clone --depth=1 --branch "$BRANCH" "$REMOTE" "$SETTING_DIR" || { - error "git clone of helper repo failed" - exit 1 - } + git clone --depth=1 --branch "$BRANCH" "$REMOTE" "$SETTING_DIR" || { + error "git clone of helper repo failed" + exit 1 + } fi # Write initial commands into .bashrc or .zshrc -sed -i'.bak' "\^# $REPO^, /^$/ d" $RCFILE +sed -i "\^$COMMENT_IN_RCFILE^, /^$/ d" $RCFILE cat >>$RCFILE <