From 59de29d5164d245dda1608f5e14cf4e1c981ad3e Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 25 Jun 2024 23:09:03 +0800 Subject: Update --- Makefile | 3 ++ bin/init/load-settings.sh | 81 --------------------------------------------- bin/install.sh | 30 ++++++++++++----- profile.sh | 78 +++++++++++++++++++++++++++++++++++++++++++ vim/init/keymaps.vim | 4 +-- vim/lua/configs/conform.lua | 2 ++ vim/lua/mappings.lua | 8 ----- vim/lua/options.lua | 2 ++ vim/lua/plugins/init.lua | 1 + 9 files changed, 109 insertions(+), 100 deletions(-) delete mode 100755 bin/init/load-settings.sh create mode 100755 profile.sh diff --git a/Makefile b/Makefile index e8c87a8..ba4f2b5 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ .ONESHELL: .PHONY: * +help: + @echo Use make all for git tig vim settings + all: git tig vim gpg mkdir -p ~/git 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 </dev/null; then + export EDITOR=nvim +else + export EDITOR=vim +fi +export VISUAL=$EDITOR +export TIG_EDITOR=$EDITOR +export GIT_EDITOR=$EDITOR + +# 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/vim/init/keymaps.vim b/vim/init/keymaps.vim index 14d813b..f789ceb 100644 --- a/vim/init/keymaps.vim +++ b/vim/init/keymaps.vim @@ -78,9 +78,9 @@ vnoremap , :terminal map pp :setlocal paste! " Switch CDW to root git directory -nnoremap cg :execute 'cd' fnameescape(fnamemodify(finddir('.git', escape(expand('%:p:h'), ' ') . ';'), ':h')):pwd +nnoremap cdg :execute 'cd' fnameescape(fnamemodify(finddir('.git', escape(expand('%:p:h'), ' ') . ';'), ':h')):pwd " Switch CWD to the directory of the open buffer -map cd :cd %:p:h:pwd +nnoremap cd :cd %:p:h:pwd " Move one line up and down nnoremap ddp diff --git a/vim/lua/configs/conform.lua b/vim/lua/configs/conform.lua index 1b6683b..411336e 100644 --- a/vim/lua/configs/conform.lua +++ b/vim/lua/configs/conform.lua @@ -5,6 +5,8 @@ local options = { html = { "prettier" }, markdown = { "prettier" }, sh = {"shfmt"}, + bash = {"shfmt"}, + zsh = {"shfmt"}, }, -- format_on_save = { diff --git a/vim/lua/mappings.lua b/vim/lua/mappings.lua index fd58297..401c0f8 100644 --- a/vim/lua/mappings.lua +++ b/vim/lua/mappings.lua @@ -24,14 +24,6 @@ end, { desc = "format files" }) vim.keymap.set("n", "ds", vim.diagnostic.setloclist, { desc = "lsp diagnostic loclist" }) -- tabufline -vim.keymap.set("n", "", function() - require("nvchad.tabufline").next() -end, { desc = "buffer goto next" }) - -vim.keymap.set("n", "", function() - require("nvchad.tabufline").prev() -end, { desc = "buffer goto prev" }) - vim.keymap.set("n", "x", function() require("nvchad.tabufline").close_buffer() end, { desc = "buffer close" }) diff --git a/vim/lua/options.lua b/vim/lua/options.lua index f9e6e7e..c16ae64 100644 --- a/vim/lua/options.lua +++ b/vim/lua/options.lua @@ -18,3 +18,5 @@ o.completeopt = 'menuone,noselect' -- NOTE: You should make sure your terminal supports this o.termguicolors = true + +o.whichwrap = "b,s" diff --git a/vim/lua/plugins/init.lua b/vim/lua/plugins/init.lua index 12f74f8..8c49369 100644 --- a/vim/lua/plugins/init.lua +++ b/vim/lua/plugins/init.lua @@ -30,6 +30,7 @@ return { { "stevearc/conform.nvim", + lazy = false, -- event = 'BufWritePre', -- uncomment for format on save config = function() require "configs.conform" -- cgit v1.2.3-70-g09d2