diff --git a/Brewfile b/Brewfile index 3cae4f2..4369f58 100644 --- a/Brewfile +++ b/Brewfile @@ -2,3 +2,10 @@ brew "ruby-lsp" brew "lua-language-server" brew "typescript-language-server" +brew "rbenv" +brew "ruby-build" +brew "pyenv" +brew "pyenv-virtualenv" +brew "neovim" +brew "zinit" +brew "fzf" diff --git a/README.md b/README.md index c3f3b56..cacf677 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,17 @@ -# My Dotfiles +# Dotfiles ## External Dependencies - Neovim - Kitty - Homebrew +- ZSH (as the default shell for the user) ## Installation Assuming external dependencies are installed, run `./install.sh`. + +## Notes + +Does not currently install Python, Ruby, Node, etc. Install whatever build +dependencies are needed, then use rbenv, pyenv, nvm, etc. to manage them. diff --git a/applications/kitty.desktop b/applications/kitty.desktop new file mode 100644 index 0000000..97b12af --- /dev/null +++ b/applications/kitty.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=Kitty +Exec="$HOME/.local/kitty.app/bin/kitty" +Icon="$XDG_DATA_HOME/icons/kitty-whiskers.svg" +Type=Application +Categories=Utility diff --git a/icons/kitty-whiskers.svg b/icons/kitty-whiskers.svg new file mode 100644 index 0000000..75063eb --- /dev/null +++ b/icons/kitty-whiskers.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/install.sh b/install.sh index 2978bb6..03152f4 100755 --- a/install.sh +++ b/install.sh @@ -1,15 +1,36 @@ #!/bin/bash -set -euo pipefail +set -euxo pipefail + +export XDG_DATA_HOME="${XDG_DATA_HOME:-"$HOME/.local/share"}" +export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-"$HOME/.config"}" echo "Installing fonts" -sudo cp -R fonts/* /usr/share/fonts +fonts_dir="$XDG_DATA_HOME/fonts" +cp -R fonts/* "$fonts_dir/" fc-cache echo "Installing homebrew dependencies" brew bundle install +echo "Installing application icons and entries" +icons_dir="$XDG_DATA_HOME/icons/" +mkdir -p "$icons_dir" +cp -f icons/* "$icons_dir" +applications_dir="$XDG_DATA_HOME/applications/" +mkdir -p "$applications_dir" +envsubst > "$applications_dir/kitty.desktop" < applications/kitty.desktop +xdg-desktop-menu forceupdate + echo "Creating symlinks" -ln -sf "$PWD/nvim" "${XDG_CONFIG_HOME:-$HOME/.config}/nvim" -ln -sf "$PWD/kitty" "${XDG_CONFIG_HOME:-$HOME/.config}/kitty" +ln -sf "$PWD/nvim" "$XDG_CONFIG_HOME/nvim" +ln -sf "$PWD/kitty" "$XDG_CONFIG_HOME/kitty" +ln -sf "$PWD/zsh/zshrc" "$HOME/.zshrc" +ln -sf "$PWD/zsh/zsh_functions" "$HOME/.zsh_functions" +ln -sf "$PWD/zsh/zsh_aliases" "$HOME/.zsh_aliases" +ln -sf "$PWD/zsh/zsh_plugins" "$HOME/.zsh_plugins" +ln -sf "$PWD/zsh/zsh_prompt" "$HOME/.zsh_prompt" + +echo "Installing NVM" +curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh" | bash echo "Done" diff --git a/zsh/zsh_aliases b/zsh/zsh_aliases new file mode 100644 index 0000000..d2ebe84 --- /dev/null +++ b/zsh/zsh_aliases @@ -0,0 +1,10 @@ +# Clipboard aliases +# y - yank text to clipboard +# p - put text from clipboard +if q command -v wl-copy; then + alias y='wl-copy' + alias p='wl-paste' +elif q command -v xclip; then + alias y='xclip -selection -clipboard' + alias p='xclip -selection -clipboard -o' +fi diff --git a/zsh/zsh_functions b/zsh/zsh_functions new file mode 100644 index 0000000..f1578a8 --- /dev/null +++ b/zsh/zsh_functions @@ -0,0 +1,4 @@ +# Silently run a command +function q { + "$@" > /dev/null 2>&1 +} diff --git a/zsh/zsh_plugins b/zsh/zsh_plugins new file mode 100644 index 0000000..a6e614f --- /dev/null +++ b/zsh/zsh_plugins @@ -0,0 +1,8 @@ +zinit_path='/home/linuxbrew/.linuxbrew/opt/zinit/zinit.zsh' + +if [[ -f "$zinit_path" ]]; then + . "$zinit_path" + + # Use fzf for tab completion in zsh + zinit light 'Aloxaf/fzf-tab' +fi diff --git a/zsh/zsh_prompt b/zsh/zsh_prompt new file mode 100644 index 0000000..c8fcaa6 --- /dev/null +++ b/zsh/zsh_prompt @@ -0,0 +1,30 @@ +autoload -Uz add-zsh-hook vcs_info compinit +compinit +setopt promptsubst + +# Sets `prompt_workdir` to home-relative, abbreviated working directory +# example: `/home/julien/Code/foo/bar` > `~/C/f/bar` +set_prompt_workdir() { + local workdir="${PWD/#$HOME/~}" + local workdir_segments=( ${(s:/:)workdir} ) + local short_workdir_segments=() + for (( i=1; i <= ${#workdir_segments}; i++ )) do + segment=${workdir_segments[i]} + if [[ $i < ${#workdir_segments} ]]; then + short_workdir_segments+=${segment[1]} + else + short_workdir_segments+="$segment" + fi + done + prompt_workdir="${(j./.)short_workdir_segments}" + if [[ "$PWD" != "$HOME"* ]]; then + prompt_workdir="/$prompt_workdir" + fi +} +add-zsh-hook precmd set_prompt_workdir +add-zsh-hook precmd vcs_info +zstyle ':vcs_info:git:*' formats ' %F{red}%b%f%c%u' +zstyle ':vcs_info:git:*' check-for-changes true +zstyle ':vcs_info:git:*' stagedstr '%F{green}+%f' +zstyle ':vcs_info:git:*' unstagedstr '%F{yellow}+%f' +export PROMPT='%B%F{cyan}%n%f%F{blue}@%f%F{cyan}%m%f%F{blue}:%f%F{green}${prompt_workdir}%f${vcs_info_msg_0_} %(!.#.>)%b ' diff --git a/zsh/zshrc b/zsh/zshrc new file mode 100644 index 0000000..83c90c3 --- /dev/null +++ b/zsh/zshrc @@ -0,0 +1,29 @@ +# add custom executable locations +export PATH="$HOME/.local/kitty.app/bin:$PATH" +export PATH="$HOME/.local/bin:$PATH" + +# linux brew +export LINUX_BREW_PATH="/home/linuxbrew/.linuxbrew/bin/brew" +[[ -x "$LINUX_BREW_PATH" ]] && \ + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + +# rbenv +export RBENV_ROOT="$HOME/.rbenv" +eval "$(rbenv init - zsh)" + +# pyenv +export PYENV_ROOT="$HOME/.pyenv" +[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH" +eval "$(pyenv init - zsh)" +eval "$(pyenv virtualenv-init -)" + +# nvm +export NVM_DIR="$HOME/.nvm" +[[ -s "$NVM_DIR/nvm.sh" ]] && . "$NVM_DIR/nvm.sh" +[[ -s "$NVM_DIR/zsh_completion" ]] && . "$NVM_DIR/zsh_completion" + +# further customizations +[[ -f "$HOME/.zsh_functions" ]] && . "$HOME/.zsh_functions" +[[ -f "$HOME/.zsh_aliases" ]] && . "$HOME/.zsh_aliases" +[[ -f "$HOME/.zsh_plugins" ]] && . "$HOME/.zsh_plugins" +[[ -f "$HOME/.zsh_prompt" ]] && . "$HOME/.zsh_prompt"