config/zsh: improve shell startup
This commit is contained in:
parent
5457718f21
commit
927a0b1f13
|
@ -80,7 +80,7 @@ pathadd() {
|
|||
}
|
||||
|
||||
# ZSH completion and stuff {{{1
|
||||
alias rs="reset && source ~/.zprofile && exec $SHELL"
|
||||
alias rs="reset && exec $SHELL"
|
||||
alias hist='print -z $(history | tac | fzf --tiebreak=index --bind='"'"'del:execute(sed "\;$(echo {4..})$d" -i.bak $HISTFILE)'"'"' | sed "s|^ \+||" | cut -d" " -f5-)'
|
||||
|
||||
# Edit shell config files
|
||||
|
@ -90,7 +90,7 @@ edshell() {
|
|||
case $1 in
|
||||
("") file="$CONFIG_SHELL_FUNCTIONS";;
|
||||
(zsh) file="$CONFIG_ZSH/.zshrc";;
|
||||
(prof*) file="$HOME/.zprofile";;
|
||||
(env) file="$HOME/.zshenv";;
|
||||
(-f) grepfile="$(grep --recursive "\(^$2()\|alias $2=\)" $CONFIG_SHELLS -n -m 1)"
|
||||
file="$(echo "$grepfile" | cut -d':' -f1)"
|
||||
line="$(echo "$grepfile" | cut -d':' -f2)"
|
||||
|
@ -99,12 +99,10 @@ edshell() {
|
|||
esac
|
||||
test -f "$file" && checksum="$(md5sum "$file")"
|
||||
$EDITOR "$(test "$line" && echo "+normal! ${line}ggzx" || echo "--")" "${file%:*}"
|
||||
#test -f "$file" || return 1
|
||||
test "$checksum" != "$(md5sum $file)" &&
|
||||
source "$HOME/.zprofile" && exec $SHELL
|
||||
test -s "$file" || return 1
|
||||
test "$checksum" != "$(md5sum $file)" && rs
|
||||
}
|
||||
|
||||
|
||||
# Edit a file in the PATH
|
||||
edbin() {
|
||||
f="$(which $1 2>/dev/null)" && test -f "$f" && edit "$f" ||
|
||||
|
@ -187,8 +185,13 @@ alias lst='( last; last -f /var/log/wtmp.1 ) | grep -v "pts/" | tac | less +G'
|
|||
alias delta="sc restart openvpn-client@deltaPeak.service"
|
||||
sshl() {
|
||||
lemonade server -allow 127.0.0.1 &
|
||||
ssh-copy-id -i "$(ssh -G "$1" | grep "^identityfile " | head -1 | cut -d " " -f2- | sed "s|^~|$HOME|")" "$1"
|
||||
kitty +kitten ssh -R 2489:127.0.0.1:2489 "$@"
|
||||
file="/var/tmp/ssh-$1"
|
||||
if test ! -e "$file"; then
|
||||
ssh-copy-id -i "$(ssh -G "$1" | grep "^identityfile " | head -1 | cut -d " " -f2- | sed "s|^~|$HOME|")" "$1" &&
|
||||
kitty +kitten ssh -R 2489:127.0.0.1:2489 "$@" &&
|
||||
touch "$file"
|
||||
else ssh "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# Listen to loopback of mic
|
||||
|
@ -298,6 +301,7 @@ which perl-rename >/dev/null &&
|
|||
alias lowercase="perl-rename -iv '$lowercase_transliterate'" ||
|
||||
alias lowercase="rename -iv '$lowercase_transliterate'"
|
||||
|
||||
# TODO replace cp by rsync, automatically use compression for remote transfers
|
||||
# rsync directory properly - suffix both dirs with / to act on contents
|
||||
alias rcn='rsync -v --recursive --human-readable --links --dry-run'
|
||||
rcd() { rcn --size-only "$@" | tail +2 | tree --fromfile . | less -F; }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[alias]
|
||||
cgit = !yadm cme "config/git:" $XDG_CONFIG_HOME/git $CONFIG_SHELLS/git $HOME/.local/bin/scripts/git-*
|
||||
cshell = !yadm cme "config/shell:" $CONFIG_SHELLS $HOME/.zprofile
|
||||
cshell = !yadm cme "config/shell:" $CONFIG_SHELLS $HOME/.zshenv
|
||||
cf = !yadm cme "bin:" $CONFIG_SHELLS/functions $HOME/.local/bin/scripts
|
||||
cbin = !yadm cme "bin:" $HOME/.local/bin/scripts
|
||||
|
|
|
@ -144,6 +144,7 @@ export KEYTIMEOUT=1
|
|||
|
||||
# turn on spelling correction
|
||||
setopt correct
|
||||
CORRECT_IGNORE="[_|.]*"
|
||||
# command history - https://unix.stackexchange.com/a/273863
|
||||
HISTSIZE=100000
|
||||
SAVEHIST=$HISTSIZE
|
||||
|
@ -176,28 +177,25 @@ done
|
|||
|
||||
# GENERATED SHIT
|
||||
|
||||
test -e /usr/share/zsh/manjaro-zsh-config &&
|
||||
source /usr/share/zsh/manjaro-zsh-config
|
||||
source_existing() {
|
||||
for arg
|
||||
do test -s "$arg" && source "$arg"
|
||||
done
|
||||
}
|
||||
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
||||
source_existing /usr/share/zsh/manjaro-zsh-config
|
||||
source_existing $CONFIG_ZSH/.p10k.zsh # To customize prompt, run `p10k configure` or edit .p10k.zsh.
|
||||
source_existing /usr/share/fzf/key-bindings.zsh /usr/share/fzf/completion.zsh
|
||||
|
||||
# To customize prompt, run `p10k configure` or edit .p10k.zsh.
|
||||
test -s $CONFIG_ZSH/.p10k.zsh &&
|
||||
source $CONFIG_ZSH/.p10k.zsh
|
||||
source_existing "$NVM_DIR/nvm.sh"
|
||||
source_existing "$NVM_DIR/bash_completion"
|
||||
|
||||
test -d /usr/share/fzf &&
|
||||
source /usr/share/fzf/key-bindings.zsh && source /usr/share/fzf/completion.zsh
|
||||
source_existing $XDG_CONFIG_HOME/broot/launcher/bash/br
|
||||
|
||||
which zoxide >/dev/null &&
|
||||
which zoxide >/dev/null &&
|
||||
eval "$(zoxide init zsh)"
|
||||
|
||||
test -f $XDG_CONFIG_HOME/broot/launcher/bash/br &&
|
||||
source $XDG_CONFIG_HOME/broot/launcher/bash/br
|
||||
|
||||
# Nix
|
||||
test -e /home/janek/.nix-profile/etc/profile.d/nix.sh && source /home/janek/.nix-profile/etc/profile.d/nix.sh
|
||||
source_existing /home/janek/.nix-profile/etc/profile.d/nix.sh
|
||||
which direnv >/dev/null && eval "$(direnv hook zsh)"
|
||||
|
||||
true
|
||||
|
|
1
.zshenv
1
.zshenv
|
@ -30,6 +30,7 @@ export RLWRAP_HOME="$XDG_DATA_HOME"/rlwrap
|
|||
export GOPATH="$XDG_STATE_HOME"/go
|
||||
export CARGO_HOME="$XDG_DATA_HOME"/cargo
|
||||
export RUSTUP_HOME="$XDG_DATA_HOME"/rustup
|
||||
export NVM_DIR="$XDG_DATA_HOME"/nvm
|
||||
|
||||
export CABAL_CONFIG="$XDG_CONFIG_HOME"/cabal/config
|
||||
export CABAL_DIR="$XDG_CACHE_HOME"/cabal
|
||||
|
|
Loading…
Reference in New Issue