Add: ncd
This commit is contained in:
parent
f4dee31d18
commit
ea842efa4d
1 changed files with 40 additions and 0 deletions
|
|
@ -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'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue