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 tor='torbrowser-launcher'
|
||||||
alias emax="devour emacsclient -c -a 'emacs' 1>/dev/null"
|
alias emax="devour emacsclient -c -a 'emacs' 1>/dev/null"
|
||||||
alias em="emacsclient -nw -a 'emacs -nw'"
|
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
|
# Colorful output
|
||||||
alias ls='LC_COLLATE=C ls --color=auto --group-directories-first -hN -A'
|
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 &
|
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() {
|
function ya() {
|
||||||
local tmp="$(mktemp -t "yazi-cwd.XXXXX")"
|
local tmp="$(mktemp -t "yazi-cwd.XXXXX")"
|
||||||
yazi "$@" --cwd-file="$tmp"
|
yazi "$@" --cwd-file="$tmp"
|
||||||
|
|
@ -198,6 +235,9 @@ compinit -d ~/.cache/zcompdump
|
||||||
zstyle ':completion:*:*:*:*:*' menu select
|
zstyle ':completion:*:*:*:*:*' menu select
|
||||||
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # case insensitive tab completion
|
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # case insensitive tab completion
|
||||||
|
|
||||||
|
|
||||||
|
compdef _ncd_completion ncd
|
||||||
|
|
||||||
# Remove green background of simlinks
|
# Remove green background of simlinks
|
||||||
LS_COLORS+=':ow=01;33'
|
LS_COLORS+=':ow=01;33'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue