Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
braun-daniel committed Oct 10, 2024
1 parent b936695 commit 0f134b1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 39 deletions.
39 changes: 10 additions & 29 deletions src/fzf/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,19 @@
# Exit script on any error
set -e

# Determine the remote user (typically non-root, like vscode or devuser)
REMOTE_USER="${_REMOTE_USER:-root}"
# Install git
echo "Installing git..."
apt-get update
apt-get install -y git

# Change to remote user
echo "Changing to remote user..."
su - "$_REMOTE_USER"

# Clone the fzf repository into the remote user's home directory
echo "Cloning fzf repository..."
git clone --depth 1 https://github.com/junegunn/fzf.git "$REMOTE_USER_HOME/.fzf"
git clone --depth 1 https://github.com/junegunn/fzf.git "${_REMOTE_USER_HOME}/.fzf"

# Run the fzf install script
echo "Running fzf install script..."
"$REMOTE_USER_HOME/.fzf/install"

# Home directory of the remote user
USER_HOME="/home/${REMOTE_USER}"

# Set up fzf key bindings and fuzzy completion for bash
if [ -n "$BASH_VERSION" ]; then
echo "Setting up fzf key bindings and fuzzy completion for bash..."
echo 'eval "$(fzf --bash)"' >> "${USER_HOME}/.bashrc"
chown "${REMOTE_USER}:${REMOTE_USER}" "${USER_HOME}/.bashrc"
fi

# Set up fzf key bindings and fuzzy completion for zsh
if [ -n "$ZSH_VERSION" ]; then
echo "Setting up fzf key bindings and fuzzy completion for zsh..."
echo 'source <(fzf --zsh)' >> "${USER_HOME}/.zshrc"
chown "${REMOTE_USER}:${REMOTE_USER}" "${USER_HOME}/.zshrc"
fi

# Set up fzf key bindings for fish
if [ -n "$FISH_VERSION" ]; then
echo "Setting up fzf key bindings for fish..."
mkdir -p "${USER_HOME}/.config/fish"
echo 'fzf --fish | source' >> "${USER_HOME}/.config/fish/config.fish"
chown -R "${REMOTE_USER}:${REMOTE_USER}" "${USER_HOME}/.config/fish"
fi
$REMOTE_USER_HOME/.fzf/install --all
20 changes: 10 additions & 10 deletions src/spaceship/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
# Exit script on any error
set -e

# Check if zsh is installed
if ! command -v zsh > /dev/null; then
echo "Zsh is not installed. Please install zsh before running this script."
exit 1
fi
# Install ZSH
echo "Installing ZSH..."
apt-get update
apt-get install -y zsh

# Ensure the DevContainer user's home directory is used
DEVCONTAINER_HOME="${HOME}"
# Change to remote user
echo "Changing to remote user..."
su - "$_REMOTE_USER"

# Create the .zsh directory if it doesn't exist
mkdir -p "$DEVCONTAINER_HOME/.zsh"
mkdir -p "${_REMOTE_USER_HOME}/.zsh"

# Clone the spaceship-prompt repository into the .zsh directory
git clone --depth=1 https://github.com/spaceship-prompt/spaceship-prompt.git "$DEVCONTAINER_HOME/.zsh/spaceship"
git clone --depth=1 https://github.com/spaceship-prompt/spaceship-prompt.git "${_REMOTE_USER_HOME}/.zsh/spaceship"

# Make sure the spaceship-prompt is permanently sourced in the .zshrc file
echo 'source "$DEVCONTAINER_HOME/.zsh/spaceship/spaceship.zsh"' >> "$DEVCONTAINER_HOME/.zshrc"
echo 'source "${_REMOTE_USER_HOME}/.zsh/spaceship/spaceship.zsh"' >> "${_REMOTE_USER_HOME}/.zshrc"

0 comments on commit 0f134b1

Please sign in to comment.