[profiles/base] modify zsh config
This commit is contained in:
@@ -1,11 +1,18 @@
|
|||||||
# Set PATH environment variable
|
# Set PATH environment variable
|
||||||
typeset -U path PATH
|
typeset -U path PATH
|
||||||
path=("${HOME}/.local/bin" /usr/local/sbin /usr/local/bin /usr/sbin /sbin "${path[@]}")
|
path=(
|
||||||
|
"${HOME}/.local/bin"
|
||||||
|
"/usr/local/sbin"
|
||||||
|
"/usr/local/bin"
|
||||||
|
"/usr/sbin"
|
||||||
|
"/sbin"
|
||||||
|
"${path[@]}"
|
||||||
|
)
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
# Configure shell history behavior
|
# Configure shell history behavior
|
||||||
HISTFILE=${HOME}/.zsh_history
|
HISTFILE="${HOME}/.zsh_history"
|
||||||
HISTSIZE=10000
|
HISTSIZE="10000"
|
||||||
SAVEHIST=10000
|
SAVEHIST="10000"
|
||||||
setopt appendhistory
|
setopt appendhistory
|
||||||
setopt HIST_IGNORE_SPACE
|
setopt HIST_IGNORE_SPACE
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Enable vi keybindings
|
# Enable vi keybindings
|
||||||
bindkey -v
|
bindkey -v
|
||||||
export KEYTIMEOUT=1
|
export KEYTIMEOUT="1"
|
||||||
autoload -z edit-command-line
|
autoload -z edit-command-line
|
||||||
zle -N edit-command-line
|
zle -N edit-command-line
|
||||||
bindkey '^e' edit-command-line
|
bindkey '^e' edit-command-line
|
||||||
@@ -13,24 +13,24 @@ bindkey '^U' backward-kill-line
|
|||||||
|
|
||||||
# Change cursor shape for different vi modes
|
# Change cursor shape for different vi modes
|
||||||
zle-keymap-select() {
|
zle-keymap-select() {
|
||||||
if [[ ${KEYMAP} == vicmd ]] ||
|
if [[ "${KEYMAP}" == "vicmd" ]] ||
|
||||||
[[ $1 == block ]]; then
|
[[ "$1" == "block" ]]; then
|
||||||
echo -ne '\e[2 q'
|
echo -ne '\e[2 q'
|
||||||
psvar[1]="(cmd) "
|
psvar[1]="(cmd) "
|
||||||
elif [[ ${KEYMAP} == main ]] ||
|
elif [[ "${KEYMAP}" == "main" ]] ||
|
||||||
[[ ${KEYMAP} == viins ]] ||
|
[[ "${KEYMAP}" == "viins" ]] ||
|
||||||
[[ -z ${KEYMAP} ]] ||
|
[[ -z "${KEYMAP}" ]] ||
|
||||||
[[ $1 == beam ]]; then
|
[[ "$1" == "beam" ]]; then
|
||||||
echo -ne '\e[6 q'
|
echo -ne '\e[6 q'
|
||||||
psvar[1]="(ins) "
|
psvar[1]="(ins) "
|
||||||
fi
|
fi
|
||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
}
|
}
|
||||||
zle -N zle-keymap-select
|
zle -N zle-keymap-select
|
||||||
zle-line-init() {
|
zle-line-init() {
|
||||||
zle -K viins # Initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
|
zle -K viins # Initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
|
||||||
echo -ne '\e[6 q'
|
echo -ne '\e[6 q'
|
||||||
psvar[1]="(ins) "
|
psvar[1]="(ins) "
|
||||||
}
|
}
|
||||||
zle -N zle-line-init
|
zle -N zle-line-init
|
||||||
echo -ne '\e[6 q' # Use beam shape cursor on startup
|
echo -ne '\e[6 q' # Use beam shape cursor on startup
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
if [[ -z ${TMUX} ]]; then
|
if [[ -z "${TMUX}" ]]; then
|
||||||
export REAL_TERM=${TERM}
|
export REAL_TERM="${TERM}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${REAL_TERM} != "linux" ]]; then
|
if [[ "${REAL_TERM}" != "linux" ]]; then
|
||||||
# To customize prompt, run `p10k configure` or edit ~/.zsh/prompt/p10k.zsh.
|
# To customize prompt, run `p10k configure` or edit ~/.zsh/prompt/p10k.zsh.
|
||||||
. "${HOME}/.zsh/plugins/powerlevel10k/powerlevel10k.zsh-theme"
|
. "${HOME}/.zsh/plugins/powerlevel10k/powerlevel10k.zsh-theme"
|
||||||
|
|
||||||
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
|
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
|
||||||
# Initialization code that may require console input (password prompts, [y/n]
|
# Initialization code that may require console input (password prompts, [y/n]
|
||||||
# confirmations, etc.) must go above this block; everything else may go below.
|
# confirmations, etc.) must go above this block; everything else may go below.
|
||||||
if [[ -r "${XDG_CACHE_HOME:-${HOME}/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
if [[ -r "${XDG_CACHE_HOME:-${HOME}/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
||||||
. "${XDG_CACHE_HOME:-${HOME}/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
. "${XDG_CACHE_HOME:-${HOME}/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -f ${HOME}/.zsh/prompt/p10k.zsh ]] && . "${HOME}/.zsh/prompt/p10k.zsh"
|
[[ -f "${HOME}/.zsh/prompt/p10k.zsh" ]] && . "${HOME}/.zsh/prompt/p10k.zsh"
|
||||||
else
|
else
|
||||||
. "${HOME}/.zsh/prompt/fallback.zsh"
|
. "${HOME}/.zsh/prompt/fallback.zsh"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ fpath=("${HOME}/.zsh/plugins/zsh-completions/src" "${fpath[@]}")
|
|||||||
autoload -U compinit promptinit
|
autoload -U compinit promptinit
|
||||||
compinit
|
compinit
|
||||||
promptinit
|
promptinit
|
||||||
[[ -f /etc/gentoo-release ]] && prompt gentoo
|
[[ -f "/etc/gentoo-release" ]] && prompt gentoo
|
||||||
|
|
||||||
# Enable cache for completions
|
# Enable cache for completions
|
||||||
zstyle ":completion::complete:*" use-cache 1
|
zstyle ":completion::complete:*" use-cache 1
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
# emacs specific stuff
|
# emacs specific stuff
|
||||||
[[ ${EAT_SHELL_INTEGRATION_DIR} ]] && . "${EAT_SHELL_INTEGRATION_DIR}/zsh"
|
[[ -n "${EAT_SHELL_INTEGRATION_DIR}" ]] &&
|
||||||
|
. "${EAT_SHELL_INTEGRATION_DIR}/zsh"
|
||||||
|
|||||||
@@ -22,5 +22,5 @@ export GPGKEY="4A45503BBE575E3D4DAF28E27264AFFDC98D52BB"
|
|||||||
# gpg-agent
|
# gpg-agent
|
||||||
unset SSH_AGENT_PID
|
unset SSH_AGENT_PID
|
||||||
if [[ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]]; then
|
if [[ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]]; then
|
||||||
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket 2>/dev/null)
|
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket 2>/dev/null)"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -8,15 +8,15 @@ export LESS='-R --use-color -Dd+r$Du+b$'
|
|||||||
zmodload zsh/zpty
|
zmodload zsh/zpty
|
||||||
|
|
||||||
pty() {
|
pty() {
|
||||||
zpty pty-${UID} ${1+$@}
|
zpty pty-${UID} ${1+$@}
|
||||||
if [[ ! -t 1 ]]; then
|
if [[ ! -t 1 ]]; then
|
||||||
setopt local_traps
|
setopt local_traps
|
||||||
trap '' INT
|
trap '' INT
|
||||||
fi
|
fi
|
||||||
zpty -r pty-${UID}
|
zpty -r pty-${UID}
|
||||||
zpty -d pty-${UID}
|
zpty -d pty-${UID}
|
||||||
}
|
}
|
||||||
|
|
||||||
ptyless() {
|
ptyless() {
|
||||||
pty "$@" | less
|
pty "$@" | less
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,81 +1,84 @@
|
|||||||
# HSTR configuration - add this to ~/.zshrc
|
# HSTR configuration - add this to ~/.zshrc
|
||||||
if command -v hstr >/dev/null 2>&1; then
|
if command -v hstr >/dev/null 2>&1; then
|
||||||
alias hh=hstr # hh to be alias for hstr
|
alias hh="hstr" # hh to be alias for hstr
|
||||||
setopt histignorespace # skip cmds w/ leading space from history
|
setopt histignorespace # skip cmds w/ leading space from history
|
||||||
export HSTR_CONFIG=hicolor # get more colors
|
export HSTR_CONFIG="hicolor" # get more colors
|
||||||
hstr_no_tiocsti() {
|
hstr_no_tiocsti() {
|
||||||
zle -I
|
zle -I
|
||||||
{ HSTR_OUT="$( { </dev/tty hstr ${BUFFER}; } 2>&1 1>&3 3>&- )"; } 3>&1;
|
{ HSTR_OUT="$( { </dev/tty hstr ${BUFFER}; } 2>&1 1>&3 3>&- )"; } 3>&1;
|
||||||
BUFFER=${HSTR_OUT}
|
BUFFER="${HSTR_OUT}"
|
||||||
CURSOR=${#BUFFER}
|
CURSOR="${#BUFFER}"
|
||||||
zle redisplay
|
zle redisplay
|
||||||
}
|
}
|
||||||
zle -N hstr_no_tiocsti
|
zle -N hstr_no_tiocsti
|
||||||
bindkey '\C-r' hstr_no_tiocsti
|
bindkey '\C-r' hstr_no_tiocsti
|
||||||
export HSTR_TIOCSTI=n
|
export HSTR_TIOCSTI=n
|
||||||
else
|
else
|
||||||
bindkey '\C-r' history-incremental-search-backward
|
bindkey '\C-r' history-incremental-search-backward
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# better ls
|
# better ls
|
||||||
if command -v eza >/dev/null 2>&1; then
|
if command -v eza >/dev/null 2>&1; then
|
||||||
alias ll="eza -bghHlS"
|
alias ll="eza -bghHlS"
|
||||||
else
|
else
|
||||||
alias ll="exa -bghHlS"
|
alias ll="exa -bghHlS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# bat (debian)
|
# bat (debian)
|
||||||
if command -v batcat >/dev/null 2>&1; then
|
if command -v batcat >/dev/null 2>&1; then
|
||||||
alias bat=batcat
|
alias bat=batcat
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ranger
|
# ranger
|
||||||
ranger_cd() {
|
ranger_cd() {
|
||||||
temp_file=$(mktemp -t "ranger_cd.XXXXXXXXXX")
|
temp_file=$(mktemp -t "ranger_cd.XXXXXXXXXX")
|
||||||
ranger --choosedir="${temp_file}" -- "${@:-${PWD}}"
|
ranger --choosedir="${temp_file}" -- "${@:-${PWD}}"
|
||||||
if chosen_dir=$(cat -- "${temp_file}") && [ -n ${chosen_dir} ] && [ ${chosen_dir} != "${PWD}" ]; then
|
if chosen_dir=$(cat -- "${temp_file}") &&
|
||||||
cd -- "${chosen_dir}"
|
[ -n "${chosen_dir}" ] &&
|
||||||
fi
|
[ "${chosen_dir}" != "${PWD}" ]; then
|
||||||
rm -f -- "${temp_file}"
|
cd -- "${chosen_dir}"
|
||||||
|
fi
|
||||||
|
rm -f -- "${temp_file}"
|
||||||
}
|
}
|
||||||
alias ranger=ranger_cd
|
alias ranger="ranger_cd"
|
||||||
|
|
||||||
# mc
|
# mc
|
||||||
if [[ -f /usr/libexec/mc/mc.sh ]]; then
|
[[ -f "/usr/libexec/mc/mc.sh" ]] && . "/usr/libexec/mc/mc.sh"
|
||||||
. /usr/libexec/mc/mc.sh
|
[[ -f "/usr/lib/mc/mc.sh" ]] && . "/usr/lib/mc/mc.sh"
|
||||||
fi
|
|
||||||
|
|
||||||
# nix package manager
|
# nix package manager
|
||||||
if [[ -e "${HOME}/.nix-profile/etc/profile.d/nix.sh" ]]; then
|
[[ -e "${HOME}/.nix-profile/etc/profile.d/nix.sh" ]] &&
|
||||||
. "${HOME}/.nix-profile/etc/profile.d/nix.sh"
|
. "${HOME}/.nix-profile/etc/profile.d/nix.sh"
|
||||||
fi
|
|
||||||
|
|
||||||
# nix shell
|
# nix shell
|
||||||
if command -v nix-your-shell >/dev/null 2>&1; then
|
if command -v nix-your-shell >/dev/null 2>&1; then
|
||||||
nix-your-shell zsh | . /dev/stdin
|
nix-your-shell zsh | . /dev/stdin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# node.js
|
# node.js
|
||||||
export NVM_DIR="${HOME}/.nvm"
|
export NVM_DIR="${HOME}/.nvm"
|
||||||
[[ -s ${NVM_DIR}/nvm.sh ]] && . "${NVM_DIR}/nvm.sh" # This loads nvm
|
[[ -s "${NVM_DIR}/nvm.sh" ]] &&
|
||||||
[[ -s ${NVM_DIR}/bash_completion ]] && . "${NVM_DIR}/bash_completion" # This loads nvm bash_completion
|
. "${NVM_DIR}/nvm.sh" # This loads nvm
|
||||||
|
[[ -s "${NVM_DIR}/bash_completion" ]] &&
|
||||||
|
. "${NVM_DIR}/bash_completion" # This loads nvm bash_completion
|
||||||
|
|
||||||
# rvm
|
# rvm
|
||||||
[[ -s ${HOME}/.rvm/scripts/rvm ]] && . "${HOME}/.rvm/scripts/rvm"
|
[[ -s "${HOME}/.rvm/scripts/rvm" ]] && . "${HOME}/.rvm/scripts/rvm"
|
||||||
|
|
||||||
# pyenv
|
# pyenv
|
||||||
export PYENV_ROOT=${HOME}/.pyenv
|
export PYENV_ROOT="${HOME}/.pyenv"
|
||||||
if [[ -d ${PYENV_ROOT}/bin ]]; then
|
if [[ -d "${PYENV_ROOT}/bin" ]]; then
|
||||||
path=("${PYENV_ROOT}/bin" "${path[@]}")
|
path=("${PYENV_ROOT}/bin" "${path[@]}")
|
||||||
export PATH
|
export PATH
|
||||||
eval "$(pyenv init - zsh)"
|
eval "$(pyenv init - zsh)"
|
||||||
eval "$(pyenv virtualenv-init -)"
|
eval "$(pyenv virtualenv-init -)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# inside tmux, we don't know if Sway got restarted
|
# inside tmux, we don't know if Sway got restarted
|
||||||
if [[ -v TMUX ]]; then
|
if [[ -v TMUX ]]; then
|
||||||
swaymsg() {
|
swaymsg() {
|
||||||
export SWAYSOCK="${XDG_RUNTIME_DIR}/sway-ipc.${UID}.$(pgrep -x sway).sock"
|
SWAYSOCK="${XDG_RUNTIME_DIR}/sway-ipc.${UID}.$(pgrep -x sway).sock"
|
||||||
command swaymsg "$@"
|
export SWAYSOCK
|
||||||
}
|
command swaymsg "$@"
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ alias tq="tmuxinator start quake"
|
|||||||
alias sudo="sudo "
|
alias sudo="sudo "
|
||||||
alias rsync_copy="rsync -aAXUHvh --partial-dir=.rsync-partial --progress"
|
alias rsync_copy="rsync -aAXUHvh --partial-dir=.rsync-partial --progress"
|
||||||
alias rsync_copy_ssh="rsync_copy -e ssh"
|
alias rsync_copy_ssh="rsync_copy -e ssh"
|
||||||
alias rsync_backup="rsync_copy --numeric-ids --delete --exclude={'/dev/*','/proc/*','/sys/*','/tmp/*','/run/*','/mnt/*','/media/*','/lost+found'}"
|
alias rsync_backup="rsync_copy --numeric-ids --delete --exclude={'/dev/*', \
|
||||||
|
'/proc/*','/sys/*','/tmp/*','/run/*','/mnt/*','/media/*','/lost+found'}"
|
||||||
alias rsync_backup_ssh="rsync_backup -e ssh"
|
alias rsync_backup_ssh="rsync_backup -e ssh"
|
||||||
alias rsync_restore="rsync_copy --numeric-ids --delete --exclude='lost+found'"
|
alias rsync_restore="rsync_copy --numeric-ids --delete --exclude='lost+found'"
|
||||||
alias rsync_restore_ssh="rsync_restore -e ssh"
|
alias rsync_restore_ssh="rsync_restore -e ssh"
|
||||||
alias glog="git log --oneline"
|
alias glog="git log --oneline"
|
||||||
alias emerge_world="emerge --ask --verbose --deep --newuse --update @world"
|
alias emerge_world="emerge --ask --verbose --deep --newuse --update @world"
|
||||||
alias sync_repo="rsync_copy_ssh --delete ~/arch_paczuchy/* vps.paraboletancza.org:/srv/http/repo.paraboletancza.org/arch"
|
alias sync_repo="rsync_copy_ssh --delete ~/arch_paczuchy/* \
|
||||||
|
vps.paraboletancza.org:/srv/http/repo.paraboletancza.org/arch"
|
||||||
alias aur_sync="aur sync --sign --chroot"
|
alias aur_sync="aur sync --sign --chroot"
|
||||||
alias aur_build="aur build --sign --chroot"
|
alias aur_build="aur build --sign --chroot"
|
||||||
|
|||||||
@@ -1,35 +1,35 @@
|
|||||||
take() {
|
take() {
|
||||||
local -r directory=$1
|
local -r directory="$1"
|
||||||
mkdir -p "${directory}"
|
mkdir -p "${directory}"
|
||||||
cd "${directory}"
|
cd "${directory}" || exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# downloading from youtube
|
# downloading from youtube
|
||||||
yt-dlp() {
|
yt-dlp() {
|
||||||
local -a -r args=(
|
local -a -r args=(
|
||||||
--cookies-from-browser "chromium:${HOME}/.local/share/qutebrowser"
|
--cookies-from-browser "chromium:${HOME}/.local/share/qutebrowser"
|
||||||
--extractor-args "youtube:player_client=default,web_safari;player_js_version=actual"
|
--extractor-args "youtube:player_client=default,web_safari;player_js_version=actual"
|
||||||
--fragment-retries infinite
|
--fragment-retries infinite
|
||||||
)
|
)
|
||||||
command yt-dlp "${args[@]}" "$@"
|
command yt-dlp "${args[@]}" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
yt_dl_mp3() {
|
yt_dl_mp3() {
|
||||||
yt-dlp -t mp3 --embed-thumbnail "$@"
|
yt-dlp -t mp3 --embed-thumbnail "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
yt_dl_channel() {
|
yt_dl_channel() {
|
||||||
local -a -r args=(
|
local -a -r args=(
|
||||||
--download-archive "archive.txt"
|
--download-archive "archive.txt"
|
||||||
--output "%(upload_date)s.%(title)s.%(id)s.%(ext)s"
|
--output "%(upload_date)s.%(title)s.%(id)s.%(ext)s"
|
||||||
--merge-output-format mkv
|
--merge-output-format mkv
|
||||||
--ignore-errors
|
--ignore-errors
|
||||||
--write-sub
|
--write-sub
|
||||||
--sub-langs "en,pl"
|
--sub-langs "en,pl"
|
||||||
--cookies-from-browser "chromium:${HOME}/.local/share/qutebrowser"
|
--cookies-from-browser "chromium:${HOME}/.local/share/qutebrowser"
|
||||||
--write-description
|
--write-description
|
||||||
--write-info-json
|
--write-info-json
|
||||||
--write-thumbnail
|
--write-thumbnail
|
||||||
)
|
)
|
||||||
yt-dlp "${args[@]}" "$@"
|
yt-dlp "${args[@]}" "$@"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# load zsh configuration
|
# load zsh configuration
|
||||||
for file in "${HOME}/.zsh/conf.d/"*.zsh(N); do
|
for file in "${HOME}/.zsh/conf.d/"*.zsh(N); do
|
||||||
source "${file}"
|
source "${file}"
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user