♻️ 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 = [
|
||||
{ run = '$EDITOR "$@"', block = true, desc = "$EDITOR", for = "linux" },
|
||||
{ run = 'nvim "$@"', block = true, desc = "neovim", for = "linux" },
|
||||
{ run = 'kitty --detach nvim "$@"', block = true, desc = "neovim (detached)", for = "linux" },
|
||||
{ run = 'codium "$@"', orphan = true, desc = "vscodium", for = "linux" },
|
||||
|
|
|
@ -59,6 +59,14 @@ handle_kitty() {
|
|||
$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: ' \
|
||||
--header='CTRL-P: Projects / CTRL-Z: Zoxide' \
|
||||
--bind "ctrl-p:reload($projects_command)" \
|
||||
|
@ -68,13 +76,18 @@ selected_dir=$($projects_command | $fzf_command --prompt='Select a directory: '
|
|||
tab_title=$(basename "$selected_dir")
|
||||
|
||||
if [[ -n "$selected_dir" ]]; then
|
||||
if command -v tmux &>/dev/null; then
|
||||
if command -v tmuxp &>/dev/null; then
|
||||
handle_tmuxp
|
||||
else
|
||||
handle_tmux
|
||||
editor_type=$(handle_editor)
|
||||
if [[ $editor_type == "terminal" ]]; then
|
||||
if command -v tmux &>/dev/null; then
|
||||
if command -v tmuxp &>/dev/null; then
|
||||
handle_tmuxp
|
||||
else
|
||||
handle_tmux
|
||||
fi
|
||||
elif [[ "$TERM" == "xterm-kitty" ]]; then
|
||||
handle_kitty
|
||||
fi
|
||||
elif [[ "$TERM" == "xterm-kitty" ]]; then
|
||||
handle_kitty
|
||||
else
|
||||
$EDITOR -r "$selected_dir"
|
||||
fi
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue