Skip to content

Instantly share code, notes, and snippets.

@icyveins7
Last active June 2, 2025 07:02
Show Gist options
  • Save icyveins7/879d3f129a6fc3fbfc26ae6e1f1b5a5a to your computer and use it in GitHub Desktop.
Save icyveins7/879d3f129a6fc3fbfc26ae6e1f1b5a5a to your computer and use it in GitHub Desktop.
Setup of my favourite things on a new (Unix) server over ssh
## To use this, do the following:
## git clone https://gist.github.com/879d3f129a6fc3fbfc26ae6e1f1b5a5a.git && mv 879d3f129a6fc3fbfc26ae6e1f1b5a5a/new_server_ssh_setup.sh . && source new_server_ssh_setup.sh && rm -rf 879d3f129a6fc3fbfc26ae6e1f1b5a5a/
# We just place everything while in home directory
cd
## =========== fzf
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
echo '# Source fzf' >> $HOME/.bashrc
# Note that fzf has an interactive option during installation to add to the bashrc already
~/.fzf/install
echo '' >> $HOME/.bashrc
## =========== zoxide
curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh
echo '# Start zoxide' >> $HOME/.bashrc
echo 'export PATH=$HOME/.local/bin:$PATH' >> $HOME/.bashrc # This is the default place it installs to
echo 'eval "$(zoxide init bash)"' >> $HOME/.bashrc
echo '' >> $HOME/.bashrc
## =========== CMake: Get latest cmake since we may need it for other things
wget https://github.com/Kitware/CMake/releases/download/v3.31.4/cmake-3.31.4-linux-x86_64.tar.gz
tar -xzvf cmake-3.31.4-linux-x86_64.tar.gz
rm -rf cmake-3.31.4-linux-x86_64.tar.gz
# Add to bashrc
echo '# Add cmake to PATH' >> $HOME/.bashrc
echo 'export PATH=$HOME/cmake-3.31.4-linux-x86_64/bin:$PATH' >> $HOME/.bashrc
echo '' >> $HOME/.bashrc
# Add some common commands I use
# You can use this like `qcmake -G Ninja` to append to the cmake command
echo '' >> $HOME/.bashrc
echo 'qcmake() {
cmake -B build $*
cd build
}' >> $HOME/.bashrc
echo 'rcmake() {
rm -rf build
}' >> $HOME/.bashrc
echo '' >> $HOME/.bashrc
## =========== Neovim: Get latest neovim? There's a curl-way to parse the API but i'm just going to update this version myself manually..
wget https://github.com/neovim/neovim/releases/download/v0.10.3/nvim-linux64.tar.gz
tar -xzvf nvim-linux64.tar.gz
rm -rf nvim-linux64.tar.gz
# Add it to bashrc
echo '# Add neovim to PATH' >> $HOME/.bashrc
echo 'export PATH=$HOME/nvim-linux64/bin:$PATH' >> $HOME/.bashrc
echo '' >> $HOME/.bashrc
## ========== ripgrep for Neovim's telescope
wget https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-x86_64-unknown-linux-musl.tar.gz
tar -xzvf ripgrep-14.1.1-x86_64-unknown-linux-musl.tar.gz
rm -rf ripgrep-14.1.1-x86_64-unknown-linux-musl.tar.gz
# Add it to bashrc
echo '# Add ripgrep to PATH' >> $HOME/.bashrc
echo 'export PATH=$HOME/ripgrep-14.1.1-x86_64-unknown-linux-musl:$PATH' >> $HOME/.bashrc
echo '' >> $HOME/.bashrc
## =========== Install a devel version of zlib for git in case you don't have admin rights
# Save the current directory
START_DIR=$(pwd)
ZLIB_PREFIX_DIR=$HOME/zlib-1.3.1
read -p "Do you want to install zlib 1.3.1 from source? (y/n): " answer
case "$answer" in
[Yy]* )
echo "Downloading zlib 1.3.1..."
wget https://www.zlib.net/zlib-1.3.1.tar.gz
echo "Extracting archive..."
tar -xzvf zlib-1.3.1.tar.gz
cd zlib-1.3.1 || { echo "Failed to enter directory"; exit 1; }
echo "Configuring build..."
./configure --prefix="$ZLIB_PREFIX_DIR"
echo "Building zlib..."
make -j4
echo "Installing zlib..."
make install
# Prepend the install directory to PATH
echo '# Add zlib to PATH' >> ~/.bashrc
echo 'export PATH="$ZLIB_PREFIX_PATH:$PATH"' >> ~/.bashrc
echo "Updated PATH to include zlib binaries (if any)."
# Return to the original directory
cd "$START_DIR"
echo "Returned to $START_DIR"
;;
[Nn]* )
echo "Installation cancelled."
exit 0
;;
* )
echo "Invalid input. Please answer y or n."
;;
esac
## =========== Install a newer version of git in case you don't have admin rights
# NOTE: this is a stub. we may also need to install openssl and then curl before this, otherwise
# git won't really work properly
# Here's what I found so far:
# 1. zlib
# 2. openssl
# 3. libpsl
# 4. curl (uses above 2)
START_DIR=$(pwd)
GIT_PREFIX_DIR=$HOME/git-2.49.0
read -p "Do you want to install Git 2.49.0 from source? (y/n): " answer
case "$answer" in
    [Yy]* )
        echo "Downloading Git 2.49.0..."
        wget https://www.kernel.org/pub/software/scm/git/git-2.49.0.tar.gz
        echo "Extracting archive..."
        tar -xzvf git-2.49.0.tar.gz
        cd git-2.49.0 || { echo "Failed to enter directory"; exit 1; }
        echo "Configuring build..."
        ./configure --prefix="$GIT_PREFIX_DIR"
        echo "Building Git..."
        make
        echo "Installing Git..."
        make install
        # Return to the original directory
        cd "$START_DIR"
        echo "Returned to $START_DIR"
# Prepend to path
echo '# Add source-built git to PATH' >> ~/.bashrc
echo 'export PATH="$GIT_PREFIX_DIR:$PATH"' >> ~/.bashrc
        ;;
    [Nn]* )
        echo "Installation cancelled."
        exit 0
        ;;
    * )
        echo "Invalid input. Please answer y or n."
        ;;
esac
## ========== add some other aliases (NOTE: this section is to be copied to your bashrc manually)
# This lets you export an envvar to be the current dir
exportthis() {
if [ -z "$1" ]; then
echo "Usage: exportthis VARNAME"
return 1
fi
export "$1=$PWD"
echo "Exported $1=$PWD"
}
# This lets you export an envvar by prepending the current dir to the front
exportadd() {
if [ -z "$1" ]; then
echo "Usage: exportadd VARNAME"
return 1
fi
current_dir="$PWD"
var_name="$1"
current_value="${!var_name}"
export "$var_name=$current_dir${current_value:+:$current_value}"
echo "Prepended $current_dir to $var_name"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment