From cb5affa0e11c200f175e26ced4f2866aa916d2c9 Mon Sep 17 00:00:00 2001 From: A Farzat Date: Tue, 5 Nov 2024 07:42:55 +0900 Subject: Remove zsh submodule Zsh config will be included as bare files instead of a submodule. The zsh config repo will still exist, but the content will be used by yadm without the repo itself. --- .config/zsh/halfway/aliases.zsh | 29 +++++++++++++++++++++ .config/zsh/halfway/completion.zsh | 12 +++++++++ .config/zsh/halfway/functions.zsh | 53 ++++++++++++++++++++++++++++++++++++++ .config/zsh/halfway/general.zsh | 9 +++++++ .config/zsh/halfway/options.zsh | 6 +++++ .config/zsh/halfway/parameters.zsh | 4 +++ 6 files changed, 113 insertions(+) create mode 100644 .config/zsh/halfway/aliases.zsh create mode 100644 .config/zsh/halfway/completion.zsh create mode 100644 .config/zsh/halfway/functions.zsh create mode 100644 .config/zsh/halfway/general.zsh create mode 100644 .config/zsh/halfway/options.zsh create mode 100644 .config/zsh/halfway/parameters.zsh (limited to '.config/zsh/halfway') diff --git a/.config/zsh/halfway/aliases.zsh b/.config/zsh/halfway/aliases.zsh new file mode 100644 index 0000000..fc7815f --- /dev/null +++ b/.config/zsh/halfway/aliases.zsh @@ -0,0 +1,29 @@ +# Edit bash history. +alias mbashhistory='${EDITOR:-nvim} ~/.bash_history' +# Edit zsh history. +alias mhistory='${EDITOR:-nvim} $ZDOTDIR/.zsh_history' +# Edit and view using ${EDITOR:-nvim}. +alias v='${EDITOR:-nvim}' +alias edit='${EDITOR:-nvim}' +alias view='${EDITOR:-nvim} -M' +# Edit zshrc. +alias mzshrc='${EDITOR:-nvim} -S "$ZDOTDIR/Session.vim"' +# Edit ${EDITOR:-nvim} configuration files. +alias mvimrc='${EDITOR:-nvim} -S "$XDG_CONFIG_HOME/nvim/Session.vim"' +# List swap files +alias ls-swap='la "${XDG_STATE_HOME:-$HOME/.local/state}/nvim/swap/"' +# Edit the ledger file. +alias mledger='${EDITOR:-nvim} -S $XDG_DATA_HOME/ledger/Session.vim' +# Edit all files in git dir. +alias vgit='git ls-files -z | xargs -0 ${EDITOR:-nvim}' +# Suspend the machine. +alias ssuspend='systemctl suspend' +# Restore cursor to original colour and transparent behaviour before wal. +alias restore_cursor="printf '%b' '\e]12'" +# General. +alias la='ls -lAh --color=auto' +# Pacman categorize packages. +alias pacman-orphan='pacman -Qtdq' +alias pacman-explicit-native='pacman -Qneq' +alias pacman-explicit='pacman -Qeq' +alias pacman-optional='comm -3 <(pacman -Qttq | sort) <(pacman -Qtteq | sort)' diff --git a/.config/zsh/halfway/completion.zsh b/.config/zsh/halfway/completion.zsh new file mode 100644 index 0000000..da4d070 --- /dev/null +++ b/.config/zsh/halfway/completion.zsh @@ -0,0 +1,12 @@ +# Make completion case insensitive. +zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' +# Disable sort when completing `git checkout`. +zstyle ':completion:*:git-checkout:*' sort false +# Set descriptions format to enable group support. +zstyle ':completion:*:descriptions' format '[%d]' +# Set list-colors to enable filename colorizing. +zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} +# Preview directory's content with eza when completing cd. +zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath' +# Switch group using `,` and `.`. +zstyle ':fzf-tab:*' switch-group ',' '.' diff --git a/.config/zsh/halfway/functions.zsh b/.config/zsh/halfway/functions.zsh new file mode 100644 index 0000000..9bc295c --- /dev/null +++ b/.config/zsh/halfway/functions.zsh @@ -0,0 +1,53 @@ +# Creates the given directories and then moves to the first one. +mkcd() { + mkdir -p "$@"; + cd "$1"; +} + +# Create python directories with __init__.py. +mkdirpython() { + mkdir -p "$@"; + local directory + for directory in "$@"; + do touch "$directory/__init__.py"; + done; +} + +# Switch from the current directory to the equivalent directory on another drive. +sd() { + local wd="$(pwd)"; + wd="${wd/"$1"/"$2"}"; + printf %s\\n "$wd"; + cd "$wd"; +} + +# Copy the current directory to the clipboard. +pcopy() { + printf %s "$(pwd)" | cclip + pwd +} + +vinfo() { + INFOPATH="$XDG_DATA_HOME/info:$INFOPATH" ${EDITOR:-nvim} -R -M -c "Info $@" +only +} + +vn3() { + if [ "$#" -gt 0 ]; then + local direc="$(printf %q "$1")" + shift + ${EDITOR:-nvim} -c "NnnExplorer $direc" "$@" + else + ${EDITOR:-nvim} -c NnnExplorer + fi +} + +# https://github.com/ohmyzsh/ohmyzsh/blob/8487a55/lib/cli.zsh#L625 +src () { + # Delete current completion cache + command rm -f $_comp_dumpfile $ZSH_COMPDUMP + + # Old zsh versions don't have ZSH_ARGZERO + local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" + # Check whether to run a login shell + [[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh" +} diff --git a/.config/zsh/halfway/general.zsh b/.config/zsh/halfway/general.zsh new file mode 100644 index 0000000..909c13f --- /dev/null +++ b/.config/zsh/halfway/general.zsh @@ -0,0 +1,9 @@ +# Run the sequences in the current terminal to apply the theme. +# The first is synchronous, the second is asynchronous. +cat ~/.cache/wal/sequences; +# (cat ~/.cache/wal/sequences &); +# To add support for TTYs this line can be optionally added. +source ~/.cache/wal/colors-tty.sh +# Attempts to restore the cursor colour - harmless, usually doesn't work +# but sometimes it is actually the only thing that works. +printf '%b' '\e]12' diff --git a/.config/zsh/halfway/options.zsh b/.config/zsh/halfway/options.zsh new file mode 100644 index 0000000..9de8d4d --- /dev/null +++ b/.config/zsh/halfway/options.zsh @@ -0,0 +1,6 @@ +setopt extended_history # Record timestamp of command in HISTFILE. +setopt hist_expire_dups_first # Delete duplicates first when HISTFILE size exceeds HISTSIZE. +setopt hist_ignore_dups # Ignore duplicated commands history list. +setopt hist_ignore_space # Ignore commands that start with space. +setopt hist_verify # Show command with history expansion to user before running it. +setopt share_history # Share command history data. diff --git a/.config/zsh/halfway/parameters.zsh b/.config/zsh/halfway/parameters.zsh new file mode 100644 index 0000000..6761722 --- /dev/null +++ b/.config/zsh/halfway/parameters.zsh @@ -0,0 +1,4 @@ +HISTORY_IGNORE="(. */.venv/bin/activate|btop|neomutt|profanity|newsboat|weechat)" +HISTFILE="$ZDOTDIR/.zsh_history" +HISTSIZE=50000 +SAVEHIST=10000 -- cgit v1.2.3-70-g09d2