feat(zsh): improve neovide integration into term

This commit is contained in:
Price Hiller 2024-03-01 04:15:20 -06:00
parent b11ca1a51c
commit d3528370bd
Signed by: Price
GPG Key ID: C3FADDE7A8534BEB
3 changed files with 110 additions and 83 deletions

View File

@ -1,19 +1,25 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
### Eza ### () {
if command -v eza >/dev/null 2>&1; then ### Eza ###
if command -v eza >/dev/null 2>&1; then
alias exa='eza' # This helps some preview commands work from separate repos alias exa='eza' # This helps some preview commands work from separate repos
alias ls="eza --icons --group --group-directories-first --octal-permissions --classify" alias ls="eza --icons --group --group-directories-first --octal-permissions --classify"
alias l="ls -alh" alias l="ls -alh"
alias ll="l" alias ll="l"
alias tree="ls --tree" alias tree="ls --tree"
fi fi
### Git ###
if command -v git >/dev/null 2>&1; then
### Git ###
if command -v git >/dev/null 2>&1; then
if command -v nvim >/dev/null 2>&1; then if command -v nvim >/dev/null 2>&1; then
alias gg="nvim -c 'Neogit'" local editor_to_use=nvim
if [[ -n "${XDG_CURRENT_DESKTOP}" ]] && [[ "${EDITOR}" =~ "^neovide*" ]] && command -v neovide >/dev/null 2>&1; then
editor_to_use="${EDITOR} --"
fi
alias gg="${editor_to_use} -c 'Neogit'"
alias gd="${editor_to_use} -c 'DiffviewOpen'"
alias gl="${editor_to_use} -c 'call feedkeys(\":Neogit log\<CR>l\")'"
fi fi
alias gc="git commit" alias gc="git commit"
@ -27,9 +33,7 @@ if command -v git >/dev/null 2>&1; then
alias gst="git stash" alias gst="git stash"
alias gstc="git stash clear" alias gstc="git stash clear"
alias gsw="git switch" alias gsw="git switch"
alias gd="nvim -c 'DiffviewOpen' -R"
alias gr="git remote" alias gr="git remote"
alias gl="nvim -c 'call feedkeys(\":Neogit log\<CR>l\")'"
alias glo="git log --oneline" alias glo="git log --oneline"
alias gw="git worktree" alias gw="git worktree"
alias gwa="git worktree add" alias gwa="git worktree add"
@ -37,19 +41,19 @@ if command -v git >/dev/null 2>&1; then
alias git-remote="git config --get remote.origin.url" alias git-remote="git config --get remote.origin.url"
alias git-head-default="git rev-parse --abbrev-ref origin/HEAD | cut -d '/' -f2" alias git-head-default="git rev-parse --abbrev-ref origin/HEAD | cut -d '/' -f2"
alias gbc="git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'" alias gbc="git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'"
fi fi
### Mac ### ### Mac ###
if [[ "$OSTYPE" = "darwin"* ]]; then if [[ "$OSTYPE" = "darwin"* ]]; then
alias c="pbcopy" alias c="pbcopy"
alias p="pbpaste" alias p="pbpaste"
alias grep="ggrep" alias grep="ggrep"
alias find="gfind" alias find="gfind"
alias sed="gsed" alias sed="gsed"
fi fi
### Linux ### ### Linux ###
if [[ "${OSTYPE}" == "linux-gnu"* ]]; then if [[ "${OSTYPE}" == "linux-gnu"* ]]; then
if command -v wl-copy >/dev/null 2>&1; then if command -v wl-copy >/dev/null 2>&1; then
alias c="wl-copy" alias c="wl-copy"
alias p="wl-paste" alias p="wl-paste"
@ -59,25 +63,26 @@ if [[ "${OSTYPE}" == "linux-gnu"* ]]; then
alias open="xdg-open" alias open="xdg-open"
alias o="xdg-open" alias o="xdg-open"
fi fi
fi fi
### Bat ### ### Bat ###
if command -v bat >/dev/null 2>&1; then if command -v bat >/dev/null 2>&1; then
alias cat="bat" alias cat="bat"
fi fi
### Wezterm ### ### Wezterm ###
if command -v wezterm >/dev/null 2>&1; then if command -v wezterm >/dev/null 2>&1; then
alias img="wezterm imgcat" alias img="wezterm imgcat"
alias ssh="TERM=xterm-256color ssh" alias ssh="TERM=xterm-256color ssh"
fi fi
### Misc ### ### Misc ###
alias Get-Public-IPV4="dig @resolver4.opendns.com myip.opendns.com +short -4" alias Get-Public-IPV4="dig @resolver4.opendns.com myip.opendns.com +short -4"
alias Get-Public-IPV6="dig @resolver1.ipv6-sandbox.opendns.com AAAA myip.opendns.com +short -6" alias Get-Public-IPV6="dig @resolver1.ipv6-sandbox.opendns.com AAAA myip.opendns.com +short -6"
alias cv="command -v" alias cv="command -v"
alias se="sudo -e" alias se="sudo -e"
if command -v arecord >/dev/null 2>&1; then if command -v arecord >/dev/null 2>&1; then
alias audio-record="arecord -f dat -r 41000 -d 5 $(date_iso_8601).wav" alias audio-record="arecord -f dat -r 41000 -d 5 $(date_iso_8601).wav"
fi fi
}

View File

@ -110,18 +110,33 @@ if [[ -r "${usr/libexec/java_home}" ]]; then
export JAVA_HOME="$(/usr/libexec/java_home)" export JAVA_HOME="$(/usr/libexec/java_home)"
fi fi
### Editor ### # ### Editor ###
if command -v nvim >/dev/null 2>&1; then () {
export EDITOR=nvim local new_editor
export VISUAL=nvim local new_visual
export MANPAGER="nvim +Man!" local new_manpager
elif command -v vim >/dev/null 2>&1; then if [[ -n "${XDG_CURRENT_DESKTOP}" ]] && command -v neovide >/dev/null 2>&1; then
export EDITOR=vim new_editor="neovide --no-fork"
export VISUAL=vim new_visual="neovide --no-fork"
else new_manpager="${XDG_CONFIG_HOME}/zsh/config/profile/profile/manpager_wrapper_func.bash"
export EDITOR=vi elif command -v nvim >/dev/null 2>&1; then
export VISUAL=less new_editor=nvim
fi new_visual=nvim
new_manpager="nvim +Man!"
elif command -v vim >/dev/null 2>&1; then
new_editor=vim
new_visual=vim
new_manpager=less
else
new_editor=vi
new_visual=vi
new_manpager=less
fi
export EDITOR="${EDITOR:-$new_editor}"
export VISUAL="${VISUAL:-$new_visual}"
export MANPAGER="${MANPAGER:-$new_manpager}"
}
### Rust ### ### Rust ###
export CARGO_HOME="${HOME}/.cargo" export CARGO_HOME="${HOME}/.cargo"

View File

@ -0,0 +1,7 @@
#!/usr/bin/env -S nix --extra-experimental-features "nix-command flakes" shell nixpkgs#bash --command bash
main() {
neovide --no-fork -- "+silent!+Man!" -- <(cat "${@}")
}
main "${@}"