The following is added to all three shells bash, zsh, nushell: Pressing c-t at any time lets you insert a file/dir at the current cursor location using fzf. Same for 'T' in vicmd mode. Pressing alt-c at any time lets you jump to that directory using zoxide, with the zle editor content intact. Same for 'C' in vicmd mode. Zsh implementation from: https://github.com/ajeetdsouza/zoxide/issues/357 Bash implementation: https://github.com/ajeetdsouza/zoxide/issues/516 Nushell implementation taken from: https://github.com/junegunn/fzf/issues/4122 TODO: Nushell fzf mapping has one problem in that it does not quote the selected file in any way. So any file with e.g. a space in it will have to be manually fixed afterwards.
64 lines
1.4 KiB
Bash
64 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# ~/.bashrc
|
|
#
|
|
# shellcheck disable=SC1090
|
|
|
|
CONFDIR="${XDG_CONFIG_HOME:-$HOME/.config}"
|
|
|
|
# If not running interactively, don't do anything
|
|
[[ $- != *i* ]] && return
|
|
|
|
[ -f "$CONFDIR/sh/alias" ] && source "$CONFDIR/sh/alias"
|
|
# load additional aliases
|
|
if [ -d "$CONFDIR/sh/alias.d" ]; then
|
|
for _alias in "$CONFDIR/sh/alias.d"/*.sh; do
|
|
. "$_alias"
|
|
done
|
|
unset _alias
|
|
fi
|
|
if [ -d "$CONFDIR/bash/alias.d" ]; then
|
|
for _alias in "$CONFDIR/bash/alias.d"/*.sh; do
|
|
. "$_alias"
|
|
done
|
|
unset _alias
|
|
fi
|
|
|
|
alias ls='ls --color=auto'
|
|
|
|
eval "$(starship init bash)"
|
|
eval "$(zoxide init bash)"
|
|
export CARAPACE_BRIDGES='zsh,fish,bash,inshellisense' # optional
|
|
source <(carapace _carapace)
|
|
|
|
set -o vi
|
|
stty time 0
|
|
bind 'set keyseq-timeout 1'
|
|
|
|
# insert files with c-t or T in vicmd mode
|
|
FZF_CTRL_R_COMMAND="" FZF_ALT_C_COMMAND="" eval "$(fzf --bash)"
|
|
builtin bind -m vi-command '"T": "\C-z\C-t\C-z"'
|
|
|
|
_run-cdi() {
|
|
# Get the directory from zoxide query
|
|
local dir=$(zoxide query -i)
|
|
|
|
# If no directory is found, clear the line
|
|
if [[ -z "$dir" ]]; then
|
|
echo ''
|
|
return
|
|
fi
|
|
|
|
# Call cd with the directory
|
|
cd -- "$dir"
|
|
|
|
# Return the exit status of cd
|
|
return $?
|
|
}
|
|
# Make the function _run-cdi available
|
|
# shellcheck disable=SC2016
|
|
bind -x '"\ec": "`_run-cdi`"'
|
|
# shellcheck disable=SC2016
|
|
bind -m vi-command -x '"C": "`_run-cdi`"'
|
|
|
|
eval "$(atuin init bash)"
|