check nvim version before neovide alias
This commit is contained in:
parent
70eb4de6d3
commit
bc5acd9ecf
1 changed files with 42 additions and 10 deletions
52
.zshrc
52
.zshrc
|
@ -244,18 +244,50 @@ _coding_() {
|
||||||
export EDITOR="codium"
|
export EDITOR="codium"
|
||||||
fi
|
fi
|
||||||
# ─< neovide, the best frontend for any neovim-config >───────────────────────────────────
|
# ─< neovide, the best frontend for any neovim-config >───────────────────────────────────
|
||||||
if [ -d "$HOME/.local/share/neovide/" ]; then
|
# Function to check Neovim version and set up Neovide alias accordingly
|
||||||
if command_exists neovide; then
|
setup_nvim_alias() {
|
||||||
alias nvim='neovide --fork'
|
# Check if Neovide directory exists
|
||||||
|
if [ -d "$HOME/.local/share/neovide/" ]; then
|
||||||
|
# Get the current Neovim version
|
||||||
|
version=$(nvim --version | head -n 1 | awk '{print $2}')
|
||||||
|
|
||||||
|
# Define the required version
|
||||||
|
required_version="0.10.0"
|
||||||
|
|
||||||
|
# Use awk to compare versions
|
||||||
|
if awk -v v1="$version" -v v2="$required_version" 'BEGIN {
|
||||||
|
split(v1, a, "."); split(v2, b, ".");
|
||||||
|
if (a[1] > b[1] || (a[1] == b[1] && a[2] > b[2]) || (a[1] == b[1] && a[2] == b[2] && a[3] >= b[3])) exit(0);
|
||||||
|
exit(1);
|
||||||
|
}'; then
|
||||||
|
# Neovim version is 0.10.0 or higher, use Neovide
|
||||||
|
if command -v neovide > /dev/null; then
|
||||||
|
alias nvim='neovide --fork'
|
||||||
|
else
|
||||||
|
if [ -n "$neovide_path" ]; then
|
||||||
|
alias nvim="$neovide_path --fork"
|
||||||
|
else
|
||||||
|
neovide_path=$(find "$HOME/" -name "*neovide*.appimage" 2>/dev/null)
|
||||||
|
if [ -n "$neovide_path" ]; then
|
||||||
|
alias nvim="$neovide_path --fork"
|
||||||
|
else
|
||||||
|
echo "Neovide not found. Please install Neovide or set neovide_path."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Neovim version is below 0.10.0, use default nvim
|
||||||
|
alias nvim='nvim'
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
if [ -n "$neovide_path" ]; then
|
# Neovide directory does not exist
|
||||||
alias nvim="$neovide_path --fork"
|
echo "Neovide directory not found. Skipping Neovide alias setup."
|
||||||
else
|
|
||||||
neovide_path=$(find "$HOME/" -name "*neovide*.appimage" 2>/dev/null)
|
|
||||||
alias nvim="$neovide_path --fork"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
}
|
||||||
|
|
||||||
|
# Ensure to call the function to apply the alias setup
|
||||||
|
setup_nvim_alias
|
||||||
|
|
||||||
# Function to get the IP address
|
# Function to get the IP address
|
||||||
get_ip() {
|
get_ip() {
|
||||||
ip a | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d/ -f1 | head -n 1
|
ip a | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d/ -f1 | head -n 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue