Last active
October 30, 2024 15:25
-
-
Save JoeHowarth/832c0661476942cd2adebbc445922973 to your computer and use it in GitHub Desktop.
Portable minimal nvim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # portable-nvim.sh - Install Neovim in userspace without sudo | |
| # run with: ssh user@host "curl -sL https://your-host/portable-nvim.sh | bash" | |
| set -euo pipefail | |
| # Configuration | |
| INSTALL_DIR="$HOME/.local/nvim" | |
| NVIM_VERSION="v0.9.5" # Set a specific version for stability | |
| ARCH="$(uname -m)" | |
| OS="$(uname -s | tr '[:upper:]' '[:lower:]')" | |
| # Ensure ~/.local/bin exists and is in PATH | |
| mkdir -p "$HOME/.local/bin" | |
| if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then | |
| echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.bashrc" | |
| export PATH="$HOME/.local/bin:$PATH" | |
| fi | |
| # Download and install | |
| echo "Installing Neovim ${NVIM_VERSION} for ${OS}-${ARCH}..." | |
| mkdir -p "$INSTALL_DIR" | |
| cd "$INSTALL_DIR" | |
| # Download and extract | |
| curl -LO "https://github.com/neovim/neovim/releases/download/${NVIM_VERSION}/nvim-${OS}64.tar.gz" | |
| tar xzf "nvim-${OS}64.tar.gz" --strip-components=1 | |
| rm "nvim-${OS}64.tar.gz" | |
| # Create symbolic link | |
| ln -sf "$INSTALL_DIR/bin/nvim" "$HOME/.local/bin/nvim" | |
| # Create minimal config | |
| mkdir -p "$HOME/.config/nvim" | |
| cat > "$HOME/.config/nvim/init.lua" << 'EOF' | |
| -- Minimal config for remote servers | |
| vim.opt.number = true | |
| vim.opt.ignorecase = true | |
| vim.opt.smartcase = true | |
| vim.opt.hlsearch = true | |
| vim.opt.incsearch = true | |
| vim.opt.mouse = 'a' | |
| vim.opt.clipboard = 'unnamedplus' | |
| vim.opt.breakindent = true | |
| vim.opt.undofile = true | |
| vim.opt.ignorecase = true | |
| vim.opt.smartcase = true | |
| vim.opt.updatetime = 250 | |
| vim.opt.timeoutlen = 300 | |
| vim.opt.splitright = true | |
| vim.opt.splitbelow = true | |
| -- Basic keymaps | |
| vim.api.nvim_set_keymap('i', 'fd', '<Esc>', { noremap = true, silent = true }) | |
| vim.api.nvim_set_keymap('n', '<space>', '<nop>', { noremap = true, silent = true }) | |
| vim.g.mapleader = ' ' | |
| vim.g.maplocalleader = ' ' | |
| -- Basic file navigation | |
| vim.api.nvim_set_keymap('n', '<leader>e', ':Ex<CR>', { noremap = true, silent = true }) | |
| EOF | |
| echo "Neovim installed to $INSTALL_DIR" | |
| echo "Symlink created at ~/.local/bin/nvim" | |
| echo "Basic config created at ~/.config/nvim/init.lua" | |
| echo "Run 'source ~/.bashrc' or start a new shell to use nvim" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment