From ea842efa4de150c0f02e7aa3de5bd27c8087a4fb Mon Sep 17 00:00:00 2001 From: agryphus Date: Wed, 4 Feb 2026 12:22:25 -0500 Subject: [PATCH] Add: ncd --- misc/.config/zsh/.zshrc | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/misc/.config/zsh/.zshrc b/misc/.config/zsh/.zshrc index 342b882..4135986 100755 --- a/misc/.config/zsh/.zshrc +++ b/misc/.config/zsh/.zshrc @@ -68,6 +68,8 @@ alias zoom='dlkiller zoom' alias tor='torbrowser-launcher' alias emax="devour emacsclient -c -a 'emacs' 1>/dev/null" alias em="emacsclient -nw -a 'emacs -nw'" +alias wgup="sudo wg-quick up ~/wg-quick.conf" +alias wgdown="sudo wg-quick down ~/wg-quick.conf" # Colorful output alias ls='LC_COLLATE=C ls --color=auto --group-directories-first -hN -A' @@ -105,6 +107,41 @@ function pwdterm { setsid -f $TERMINAL -e $SHELL >/dev/null 2>&1 & } +function ncd() { + local dir=$1 + local file=$2 + + cd "$dir" || return + + if [[ -n "$file" ]]; then + nvim "$file" + else + nvim + fi +} + +_ncd_completion() { + local dir + local resolved_dir + + dir="${words[2]}" + + if command -v realpath &>/dev/null; then + resolved_dir="$(realpath -- "$dir" 2>/dev/null)" + elif command -v readlink &>/dev/null; then + resolved_dir="$(readlink -f -- "$dir" 2>/dev/null)" + else + # fallback: assume relative to $PWD manually + resolved_dir="$PWD/$dir" + fi + + if [[ -d $resolved_dir ]]; then + _files -W "$resolved_dir" + else + _files + fi +} + function ya() { local tmp="$(mktemp -t "yazi-cwd.XXXXX")" yazi "$@" --cwd-file="$tmp" @@ -198,6 +235,9 @@ compinit -d ~/.cache/zcompdump zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # case insensitive tab completion + +compdef _ncd_completion ncd + # Remove green background of simlinks LS_COLORS+=':ow=01;33'