From fa032ec43e52c1480cf63df98fcd5d7435bf1b02 Mon Sep 17 00:00:00 2001 From: Tri Vo Khac Date: Wed, 24 May 2023 14:12:02 +0700 Subject: [PATCH] chore: refactor scripts --- zsh/.config/zsh/.zprofile | 1 + zsh/.config/zsh/.zshrc | 15 +++++++-------- zsh/.config/zsh/zsh-exports | 9 ++++++--- zsh/.config/zsh/zsh-prompt | 2 +- zsh/.zshenv | 4 +++- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/zsh/.config/zsh/.zprofile b/zsh/.config/zsh/.zprofile index 923ace1..36a0f23 100644 --- a/zsh/.config/zsh/.zprofile +++ b/zsh/.config/zsh/.zprofile @@ -1,3 +1,4 @@ # Set PATH, MANPATH, etc., for Homebrew. [ -f /opt/homebrew/bin/brew ] && eval "$(/opt/homebrew/bin/brew shellenv)" command -v fnm > /dev/null 2>&1 && eval "$(fnm env --use-on-cd)" +command -v zoxide > /dev/null 2>&1 && eval "$(zoxide init zsh)" diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index bc17ada..b8f4403 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -1,7 +1,4 @@ #!/bin/sh -export ZDOTDIR=$HOME/.config/zsh -HISTFILE=~/.zsh_history -setopt appendhistory # some useful options (man zshoptions) setopt autocd extendedglob nomatch menucomplete @@ -9,6 +6,13 @@ setopt interactive_comments stty stop undef # Disable ctrl-s to freeze terminal. zle_highlight=('paste:none') +# history +setopt appendhistory +setopt INC_APPEND_HISTORY # Immediately append commands to history file. +setopt HIST_IGNORE_ALL_DUPS # Never add duplicate entries. +setopt HIST_IGNORE_SPACE # Ignore commands that start with a space. +setopt HIST_REDUCE_BLANKS # Remove unnecessary blank lines. + # beeping is annoying unsetopt BEEP unsetopt PROMPT_SP @@ -61,8 +65,3 @@ compinit # Edit line in vim with ctrl-e: autoload edit-command-line; zle -N edit-command-line # bindkey '^e' edit-command-line - -# Environment variables set everywhere -export EDITOR="micro" -export PAGE="bat" -export VISUAL="micro" diff --git a/zsh/.config/zsh/zsh-exports b/zsh/.config/zsh/zsh-exports index c20fe85..ee871b6 100644 --- a/zsh/.config/zsh/zsh-exports +++ b/zsh/.config/zsh/zsh-exports @@ -1,8 +1,11 @@ #!/bin/sh -# HISTFILE="$XDG_DATA_HOME"/zsh/history + HISTSIZE=1000000 -SAVEHIST=1000000 + export PATH="$HOME/.local/bin":$PATH export MANWIDTH=999 +export HISTFILE="$ZDOTDIR"/.zsh_history -eval "$(zoxide init zsh)" +export EDITOR="micro" +export PAGE="bat" +export VISUAL="micro" \ No newline at end of file diff --git a/zsh/.config/zsh/zsh-prompt b/zsh/.config/zsh/zsh-prompt index d231405..a582614 100644 --- a/zsh/.config/zsh/zsh-prompt +++ b/zsh/.config/zsh/zsh-prompt @@ -4,6 +4,6 @@ STARSHIP_HOME=$HOME/.config/starship [ ! -d "$STARSHIP_HOME" ] && mkdir -p "$STARSHIP_HOME" [ ! -f "$STARSHIP_HOME/starship.toml" ] && touch "$STARSHIP_HOME/starship.toml" -export STARSHIP_CONFIG=$STARSHIP_HOME/starship.toml +export STARSHIP_CONFIG="$STARSHIP_HOME"/starship.toml eval "$(starship init zsh)" diff --git a/zsh/.zshenv b/zsh/.zshenv index a57e5ed..95a8577 100644 --- a/zsh/.zshenv +++ b/zsh/.zshenv @@ -1,2 +1,4 @@ -export ZDOTDIR=~/.config/zsh +export XDG_CONFIG_HOME="${HOME}/.config" +export ZDOTDIR="${XDG_CONFIG_HOME}/zsh" + [[ -f $ZDOTDIR/.zshenv ]] && . $ZDOTDIR/.zshenv