♻️ refactor(bin): use the global editor variable for more modularity
This commit is contained in:
parent
3d43a97ac4
commit
b7cdbec020
3 changed files with 21 additions and 17 deletions
|
@ -1,10 +0,0 @@
|
||||||
function cdzc --description 'Open directories from zoxide in vscode'
|
|
||||||
set selected_dir (zi)
|
|
||||||
|
|
||||||
if test -n "$selected_dir"
|
|
||||||
cd "$selected_dir"
|
|
||||||
codium -r .
|
|
||||||
else
|
|
||||||
commandline -f repaint
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -17,6 +17,7 @@ folder = [
|
||||||
]
|
]
|
||||||
|
|
||||||
text = [
|
text = [
|
||||||
|
{ run = '$EDITOR "$@"', block = true, desc = "$EDITOR", for = "linux" },
|
||||||
{ run = 'nvim "$@"', block = true, desc = "neovim", for = "linux" },
|
{ run = 'nvim "$@"', block = true, desc = "neovim", for = "linux" },
|
||||||
{ run = 'kitty --detach nvim "$@"', block = true, desc = "neovim (detached)", for = "linux" },
|
{ run = 'kitty --detach nvim "$@"', block = true, desc = "neovim (detached)", for = "linux" },
|
||||||
{ run = 'codium "$@"', orphan = true, desc = "vscodium", for = "linux" },
|
{ run = 'codium "$@"', orphan = true, desc = "vscodium", for = "linux" },
|
||||||
|
|
|
@ -59,6 +59,14 @@ handle_kitty() {
|
||||||
$eza
|
$eza
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle_editor() {
|
||||||
|
if [[ "$EDITOR" == "nvim" || "$EDITOR" == "vim" ]]; then
|
||||||
|
echo "terminal"
|
||||||
|
elif [[ "$EDITOR" == "code" || "$EDITOR" == "codium" ]]; then
|
||||||
|
echo "gui"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
selected_dir=$($projects_command | $fzf_command --prompt='Select a directory: ' \
|
selected_dir=$($projects_command | $fzf_command --prompt='Select a directory: ' \
|
||||||
--header='CTRL-P: Projects / CTRL-Z: Zoxide' \
|
--header='CTRL-P: Projects / CTRL-Z: Zoxide' \
|
||||||
--bind "ctrl-p:reload($projects_command)" \
|
--bind "ctrl-p:reload($projects_command)" \
|
||||||
|
@ -68,6 +76,8 @@ selected_dir=$($projects_command | $fzf_command --prompt='Select a directory: '
|
||||||
tab_title=$(basename "$selected_dir")
|
tab_title=$(basename "$selected_dir")
|
||||||
|
|
||||||
if [[ -n "$selected_dir" ]]; then
|
if [[ -n "$selected_dir" ]]; then
|
||||||
|
editor_type=$(handle_editor)
|
||||||
|
if [[ $editor_type == "terminal" ]]; then
|
||||||
if command -v tmux &>/dev/null; then
|
if command -v tmux &>/dev/null; then
|
||||||
if command -v tmuxp &>/dev/null; then
|
if command -v tmuxp &>/dev/null; then
|
||||||
handle_tmuxp
|
handle_tmuxp
|
||||||
|
@ -77,4 +87,7 @@ if [[ -n "$selected_dir" ]]; then
|
||||||
elif [[ "$TERM" == "xterm-kitty" ]]; then
|
elif [[ "$TERM" == "xterm-kitty" ]]; then
|
||||||
handle_kitty
|
handle_kitty
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
$EDITOR -r "$selected_dir"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue