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.
|
||||
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
|
||||
# for examples
|
||||
[ -z ${DBG_SZSHRC} ] || echo "Entered .bashrc"
|
||||
|
||||
# If not running interactively, don't do anything
|
||||
case $- in
|
||||
*i*) echo "Welcome $USER to $(hostname)";;
|
||||
*) return;;
|
||||
esac
|
||||
[[ -r ~/.sz.shrc ]] && source ~/.sz.shrc
|
||||
|
||||
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")")
|
||||
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
|
||||
[ -z ${DBG_SZSHRC} ] || echo "Exiting .bashrc"
|
||||
|
|
|
@ -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 "
|
||||
|
||||
# some more ls aliases
|
||||
alias ll='ls -alF'
|
||||
alias la='ls -A'
|
||||
alias l='ls -CF'
|
||||
|
||||
alias lessr="less --raw-control-chars "
|
||||
|
||||
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
|
||||
PREFERED_VI=$(type -fP vi | head -1)
|
||||
PREFERED_VI=$(which-command vi | head -1)
|
||||
|
||||
if [[ -z "$PREFERED_VI" ]]; then
|
||||
alias my_vi='eval $EDITOR '
|
||||
|
@ -12,9 +12,9 @@ else
|
|||
fi
|
||||
|
||||
if [[ -r "$HOME/.config/_my.emacs/spacemacs/emacs.d/init.el" \
|
||||
&& -n "$(type -fP emacsclient)" \
|
||||
&& -n "$(type -fP emacs)" \
|
||||
&& -n "$(type -fP edit-with-spacemacs)" \
|
||||
&& -n "$(which-command emacsclient)" \
|
||||
&& -n "$(which-command emacs)" \
|
||||
&& -n "$(which-command edit-with-spacemacs)" \
|
||||
]]; then
|
||||
alias my_editor='edit-with-spacemacs'
|
||||
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'
|
||||
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 caps:escape
|
||||
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 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=''
|
||||
[[ -r ~/.poshtheme.omp.json ]] && OHMYPOSH_CONFIG="~/.poshtheme.omp.json"
|
||||
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
|
||||
|
||||
# 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"
|
||||
fi
|
||||
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
|
||||
|
|
|
@ -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
|
||||
zstyle :compinstall filename '/mnt/szmedia/USERDATA/home/sz/.zshrc'
|
||||
[[ -r ~/.sz.shrc ]] && source ~/.sz.shrc
|
||||
|
||||
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
|
||||
[ -z ${DBG_SZSHRC} ] || echo "Exiting .zshrc"
|
||||
|
|
Loading…
Reference in New Issue