Refactored to make `zsh` support as seamless as `bash`
This commit is contained in:
parent
42d570d673
commit
0c569629bc
|
@ -1,27 +1,8 @@
|
||||||
# ~/.bashrc: executed by bash(1) for non-login shells.
|
# ~/.bashrc: executed by bash(1) for non-login shells.
|
||||||
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
|
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
|
||||||
# for examples
|
# for examples
|
||||||
|
[ -z ${DBG_SZSHRC} ] || echo "Entered .bashrc"
|
||||||
|
|
||||||
# If not running interactively, don't do anything
|
[[ -r ~/.sz.shrc ]] && source ~/.sz.shrc
|
||||||
case $- in
|
|
||||||
*i*) echo "Welcome $USER to $(hostname)";;
|
|
||||||
*) return;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ -d ~/.sz.shrc.d ]; then
|
[ -z ${DBG_SZSHRC} ] || echo "Exiting .bashrc"
|
||||||
script_source=("$(find ~/.sz.shrc.d -maxdepth 1 -type d -name "$(ps -p$$ -ho comm).pre")")
|
|
||||||
script_source+=("$(find ~/.sz.shrc.d -maxdepth 0 -type d)")
|
|
||||||
script_source+=("$(find ~/.sz.shrc.d -maxdepth 1 -type d -name "$(ps -p$$ -ho comm).post")")
|
|
||||||
for script_src in ${script_source[@]}; do
|
|
||||||
scripts=$(find $script_src -maxdepth 1 -type f -not -name "*.off" -not -name "*.swp" | sort)
|
|
||||||
for script_name in $scripts; do
|
|
||||||
if [ -r $script_name ]; then
|
|
||||||
[ -z ${DBG_SZSHRC} ] || echo "Sourcing $script_name..."
|
|
||||||
. $script_name
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
unset scripts
|
|
||||||
unset script_name
|
|
||||||
done
|
|
||||||
unset script_source
|
|
||||||
fi
|
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
# If not running interactively, don't do anything
|
||||||
|
[ -z ${DBG_SZSHRC} ] || echo "Entered .sz.shrc"
|
||||||
|
|
||||||
|
case $- in
|
||||||
|
*i*) echo "Welcome $USER to $(hostname)";;
|
||||||
|
*) return;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -d ~/.sz.shrc.d ]; then
|
||||||
|
script_source=("$(find ~/.sz.shrc.d -maxdepth 1 -type d -name "$(ps -p$$ -ho comm).pre")")
|
||||||
|
script_source+=("$(find ~/.sz.shrc.d -maxdepth 0 -type d)")
|
||||||
|
script_source+=("$(find ~/.sz.shrc.d -maxdepth 1 -type d -name "$(ps -p$$ -ho comm).post")")
|
||||||
|
[ -z ${DBG_SZSHRC} ] || echo "Working with (${script_source[@]})..."
|
||||||
|
for script_src in ${script_source[@]}; do
|
||||||
|
scripts=($(find $script_src -maxdepth 1 -type f -not -name "*.off" -not -name "*.swp" | sort))
|
||||||
|
#[ -z ${DBG_SZSHRC} ] || echo "Within $script_src, will review (${scripts[@]})..."
|
||||||
|
for script_name in ${scripts[@]}; do
|
||||||
|
[ -z ${DBG_SZSHRC} ] || echo "Checking $script_name..."
|
||||||
|
if [ -r $script_name ]; then
|
||||||
|
[ -z ${DBG_SZSHRC} ] || echo "Sourcing $script_name..."
|
||||||
|
. $script_name
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
unset scripts
|
||||||
|
unset script_name
|
||||||
|
done
|
||||||
|
unset script_source
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -z ${DBG_SZSHRC} ] || echo "Exiting .sz.shrc"
|
|
@ -1,5 +1,10 @@
|
||||||
alias sudo="/usr/bin/sudo "
|
alias sudo="/usr/bin/sudo "
|
||||||
|
|
||||||
|
# some more ls aliases
|
||||||
|
alias ll='ls -alF'
|
||||||
|
alias la='ls -A'
|
||||||
|
alias l='ls -CF'
|
||||||
|
|
||||||
alias lessr="less --raw-control-chars "
|
alias lessr="less --raw-control-chars "
|
||||||
|
|
||||||
alias sz-edshrc="ed ~/.sz.shrc.d ; exec $SHELL"
|
alias sz-edshrc="ed ~/.sz.shrc.d ; exec $SHELL"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
PREFERED_VI=$(type -fP nvim vim | head -1)
|
PREFERED_VI=$(which-command nvim vim | head -1)
|
||||||
if [[ -z "$PREFERED_VI" ]]; then
|
if [[ -z "$PREFERED_VI" ]]; then
|
||||||
PREFERED_VI=$(type -fP vi | head -1)
|
PREFERED_VI=$(which-command vi | head -1)
|
||||||
|
|
||||||
if [[ -z "$PREFERED_VI" ]]; then
|
if [[ -z "$PREFERED_VI" ]]; then
|
||||||
alias my_vi='eval $EDITOR '
|
alias my_vi='eval $EDITOR '
|
||||||
|
@ -12,9 +12,9 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -r "$HOME/.config/_my.emacs/spacemacs/emacs.d/init.el" \
|
if [[ -r "$HOME/.config/_my.emacs/spacemacs/emacs.d/init.el" \
|
||||||
&& -n "$(type -fP emacsclient)" \
|
&& -n "$(which-command emacsclient)" \
|
||||||
&& -n "$(type -fP emacs)" \
|
&& -n "$(which-command emacs)" \
|
||||||
&& -n "$(type -fP edit-with-spacemacs)" \
|
&& -n "$(which-command edit-with-spacemacs)" \
|
||||||
]]; then
|
]]; then
|
||||||
alias my_editor='edit-with-spacemacs'
|
alias my_editor='edit-with-spacemacs'
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
if [[ -n "$(type -fP zfs)" ]]; then
|
if [[ -n "$(which-command zfs)" ]]; then
|
||||||
alias zls='sudo zfs list -o name,used,avail,refer,canmount,mounted,mountpoint'
|
alias zls='sudo zfs list -o name,used,avail,refer,canmount,mounted,mountpoint'
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
if [[ -n "$(type -fP setxkbmap)" && -n "$DISPLAY" ]]; then
|
if [[ -n "$(which-command setxkbmap)" && -n "$DISPLAY" ]]; then
|
||||||
setxkbmap -option
|
setxkbmap -option
|
||||||
setxkbmap -option caps:escape
|
setxkbmap -option caps:escape
|
||||||
setxkbmap -option caps:ctrl_modifier
|
setxkbmap -option caps:ctrl_modifier
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
if [[ -n "$(type -fP chezmoi)" ]]; then
|
if [[ -n "$(which-command chezmoi)" ]]; then
|
||||||
alias cdcz="cd $(chezmoi source-path)"
|
alias cdcz="cd $(chezmoi source-path)"
|
||||||
alias czcd="cdcz "
|
alias czcd="cdcz "
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
if [[ -n "$(type -fP oh-my-posh)" && -z "$INSIDE_EMACS" ]]; then
|
if [[ -n "$(which-command oh-my-posh)" ]]; then
|
||||||
OHMYPOSH_CONFIG=''
|
OHMYPOSH_CONFIG=''
|
||||||
[[ -r ~/.poshtheme.omp.json ]] && OHMYPOSH_CONFIG="~/.poshtheme.omp.json"
|
[[ -r ~/.poshtheme.omp.json ]] && OHMYPOSH_CONFIG="~/.poshtheme.omp.json"
|
||||||
eval "$(oh-my-posh init bash --config $OHMYPOSH_CONFIG)"
|
eval "$(oh-my-posh init bash --config $OHMYPOSH_CONFIG)"
|
||||||
|
|
|
@ -4,6 +4,4 @@ export HISTFILESIZE=100000 # big big history
|
||||||
shopt -s histappend # append to history, don't overwrite it
|
shopt -s histappend # append to history, don't overwrite it
|
||||||
|
|
||||||
# Save and reload the history after each command finishes
|
# Save and reload the history after each command finishes
|
||||||
if ! [[ "$PROMPT_COMMAND" =~ "history -a; history -c; history -r;" ]]; then
|
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
|
||||||
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
|
|
||||||
fi
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
if [[ -n "$(which-command oh-my-posh)" ]]; then
|
||||||
|
OHMYPOSH_CONFIG=''
|
||||||
|
[[ -r ~/.poshtheme.omp.json ]] && OHMYPOSH_CONFIG="~/.poshtheme.omp.json"
|
||||||
|
eval "$(oh-my-posh init zsh --config $OHMYPOSH_CONFIG)"
|
||||||
|
unset OHMYPOSH_CONFIG
|
||||||
|
fi
|
|
@ -0,0 +1,15 @@
|
||||||
|
# The following lines were added by compinstall
|
||||||
|
|
||||||
|
zstyle ':completion:*' completer _complete _ignored
|
||||||
|
zstyle :compinstall filename '/mnt/szmedia/USERDATA/home/sz/.zshrc'
|
||||||
|
|
||||||
|
autoload -Uz compinit
|
||||||
|
compinit
|
||||||
|
# End of lines added by compinstall
|
||||||
|
# Lines configured by zsh-newuser-install
|
||||||
|
HISTFILE=~/.histfile
|
||||||
|
HISTSIZE=1000
|
||||||
|
SAVEHIST=99999
|
||||||
|
bindkey -e
|
||||||
|
# End of lines configured by zsh-newuser-install
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
alias which_command="whence "
|
|
@ -1,14 +1,5 @@
|
||||||
# The following lines were added by compinstall
|
[ -z ${DBG_SZSHRC} ] || echo "Entered .zshrc"
|
||||||
|
|
||||||
zstyle ':completion:*' completer _complete _ignored
|
[[ -r ~/.sz.shrc ]] && source ~/.sz.shrc
|
||||||
zstyle :compinstall filename '/mnt/szmedia/USERDATA/home/sz/.zshrc'
|
|
||||||
|
|
||||||
autoload -Uz compinit
|
[ -z ${DBG_SZSHRC} ] || echo "Exiting .zshrc"
|
||||||
compinit
|
|
||||||
# End of lines added by compinstall
|
|
||||||
# Lines configured by zsh-newuser-install
|
|
||||||
HISTFILE=~/.histfile
|
|
||||||
HISTSIZE=1000
|
|
||||||
SAVEHIST=99999
|
|
||||||
bindkey -e
|
|
||||||
# End of lines configured by zsh-newuser-install
|
|
||||||
|
|
Loading…
Reference in New Issue