diff --git a/Brewfile b/Brewfile new file mode 100644 index 0000000..12a87af --- /dev/null +++ b/Brewfile @@ -0,0 +1,17 @@ +# Packages +brew "redis" +brew "zsh" +brew "asdf" + +# Cask applications +cask "iterm2" +cask "visual-studio-code" + +# Fonts +cask "font-cascadia-mono" +cask "font-cascadia-code" +cask "font-hack" +cask "font-fira-code" + +# Taps (if not already included) +tap "homebrew/cask-fonts" diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..47c0c49 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Yatish Mehta + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..8178208 --- /dev/null +++ b/README.md @@ -0,0 +1,154 @@ +# My Dotfiles + +This repository contains my personal dotfiles. These configurations help set up a development environment quickly and efficiently. + +## Repository Structure + +- `Brewfile`: List of packages and applications to install via Homebrew +- `git/gitconfig`: Git configuration +- `zsh/zshrc`: ZSH configuration +- `zsh/theme/yatish.zsh-theme`: Custom ZSH theme +- `mac-setup.sh`: Script to set macOS preferences +- `zsh-setup.sh`: Script to set up Zsh, Oh My Zsh, and custom theme +- `vscode-setup.sh`: Script to set up VSCode settings and extensions +- `vscode/settings.json`: VSCode settings +- `vscode/extensions.txt`: List of VSCode extensions to install +- `LICENSE.md`: MIT License for the project + +## Installation + +Follow these steps to install and set up the dotfiles: + +1. Clone this repository: + + ``` + mkdir -p ~/code && cd ~/code && git clone https://github.com/yatish27/dotfiles.git + ``` + +2. Install Homebrew (if not already installed): + + ``` + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + ``` + +3. Install essential tools and applications using Brewfile: + + ``` + cd ~/code/dotfiles + brew bundle + ``` + +4. Set up Zsh, Oh My Zsh, and custom theme: + + ``` + ./zsh-setup.sh + ``` + +5. Install desired languages and tools with asdf: + + ``` + asdf plugin add nodejs + asdf install nodejs latest + asdf global nodejs latest + + asdf plugin add ruby + asdf install ruby latest + asdf global ruby latest + ``` + +6. Set macOS preferences: + + ``` + ./mac-setup.sh + ``` + +7. Set up VSCode: + + Make sure you have the `code` command-line tool installed. If not, open VSCode, press Cmd+Shift+P, and run "Shell Command: Install 'code' command in PATH". + + Then run the VSCode setup script: + + ``` + ./vscode-setup.sh + ``` + + This will copy your settings and install your extensions. + +8. Restart your terminal or run `source ~/.zshrc` to apply the changes. + +## Customization + +Feel free to modify any of the dotfiles to suit your preferences. The main configuration files are: + +- Shell Configuration + + - `zsh/zshrc`: ZSH configuration + - `zsh/theme/yatish.zsh-theme`: Custom ZSH theme + +- Git Configuration + + - `git/gitconfig`: Git configuration (remember to update with your name and email) + +- Package Management + + - `Brewfile`: List of packages and applications to install via Homebrew + +- macOS Settings + + - `mac-setup.sh`: Script to set macOS preferences + +- VSCode Configuration + - `vscode-setup.sh`: Script to set up VSCode settings and extensions + - `vscode/settings.json`: VSCode settings + - `vscode/extensions.txt`: List of VSCode extensions to install + +## Updating + +To update your dotfiles: + +1. Pull the latest changes from the repository: + + ``` + cd ~/code/dotfiles + git pull origin main + ``` + +2. Copy the updated configuration files: + + ``` + cp ~/code/dotfiles/zsh/zshrc ~/.zshrc + cp ~/code/dotfiles/git/gitconfig ~/.gitconfig + cp ~/code/dotfiles/zsh/theme/yatish.zsh-theme ~/.oh-my-zsh/themes/ + ``` + +3. If there are changes to the Brewfile, run: + + ``` + brew bundle + ``` + +4. If there are changes to VSCode settings or extensions, run: + + ``` + ./vscode-setup.sh + ``` + +5. Restart your terminal or run `source ~/.zshrc` to apply the changes. + +## Additional Tips + +### Git Aliases + +To set up a nice `git lg` alias for a prettier log output: + +``` +git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --" +``` + +## Contributing + +If you have any suggestions or improvements, feel free to open an issue or submit a pull request. + +## License + +This project is open source and available under the [MIT License](LICENSE). diff --git a/git/.gitconfig b/git/.gitconfig new file mode 100644 index 0000000..28633fb --- /dev/null +++ b/git/.gitconfig @@ -0,0 +1,49 @@ +[user] + name = Yatish Mehta + email = yatish27@users.noreply.github.com + +[core] + editor = vim + whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol + excludesfile = ~/.gitignore_global + +[color] + ui = auto + +[push] + default = simple + +[pull] + rebase = false + +[merge] + tool = vimdiff + conflictstyle = diff3 + +[diff] + tool = vimdiff + +[alias] + st = status + ci = commit + br = branch + co = checkout + df = diff + dc = diff --cached + lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit -- + lol = log --graph --decorate --pretty=oneline --abbrev-commit + lola = log --graph --decorate --pretty=oneline --abbrev-commit --all + ls = ls-files + +[credential] + helper = cache --timeout=3600 + +[init] + defaultBranch = main + +[fetch] + prune = true + +[help] + autocorrect = 1 + diff --git a/mac-setup.sh b/mac-setup.sh new file mode 100755 index 0000000..5eca585 --- /dev/null +++ b/mac-setup.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Set macOS preferences + +# Set a faster key repeat rate +defaults write -g InitialKeyRepeat -int 10 # normal minimum is 15 (225 ms) +defaults write -g KeyRepeat -int 1 # normal minimum is 2 (30 ms) + +# Show hidden files in Finder +defaults write com.apple.finder AppleShowAllFiles YES + +# Show all filename extensions in Finder +defaults write NSGlobalDomain AppleShowAllExtensions -bool true + +# Disable the "Are you sure you want to open this application?" dialog +defaults write com.apple.LaunchServices LSQuarantine -bool false + +# Enable tap-to-click +defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true +defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 + +# Use list view in all Finder windows by default +defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv" + +# Disable auto-correct +defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false + +# Expand save panel by default +defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true +defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true + +# Expand print panel by default +defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true +defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true + +# Save screenshots to the desktop +defaults write com.apple.screencapture location -string "${HOME}/Desktop" + +# Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF) +defaults write com.apple.screencapture type -string "png" + +echo "macOS settings updated. Some changes may require a logout/restart to take effect." diff --git a/vscode-setup.sh b/vscode-setup.sh new file mode 100755 index 0000000..88530f4 --- /dev/null +++ b/vscode-setup.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Check if code command is available +if ! command -v code &> /dev/null +then + echo "VSCode command line tool is not installed. Please install it first." + echo "You can do this by opening VSCode, pressing Cmd+Shift+P, and running 'Shell Command: Install 'code' command in PATH'" + exit 1 +fi + +# Directory for VSCode settings +VSCODE_USER_DIR="$HOME/Library/Application Support/Code/User" + +# Backup existing settings +if [ -f "$VSCODE_USER_DIR/settings.json" ]; then + mv "$VSCODE_USER_DIR/settings.json" "$VSCODE_USER_DIR/settings.json.backup" +fi + +# Copy settings +cp vscode/settings.json "$VSCODE_USER_DIR/settings.json" + +# Install extensions +while read extension; do + code --install-extension "$extension" +done < vscode/extensions.txt + +echo "VSCode settings and extensions have been updated." diff --git a/vscode/extensions.txt b/vscode/extensions.txt new file mode 100644 index 0000000..8662050 --- /dev/null +++ b/vscode/extensions.txt @@ -0,0 +1,6 @@ +aliariff.vscode-erb-beautify +bradlc.vscode-tailwindcss +enkia.tokyo-night +esbenp.prettier-vscode +sdras.night-owl +shopify.ruby-lsp diff --git a/vscode/settings.json b/vscode/settings.json new file mode 100644 index 0000000..85b8cc3 --- /dev/null +++ b/vscode/settings.json @@ -0,0 +1,100 @@ +{ + "workbench.colorTheme": "Tokyo Night", + "editor.fontFamily": "Cascadia mono", + "editor.fontSize": 14, + "editor.fontWeight": 325, + "editor.letterSpacing": 0, + "editor.formatOnSave": true, + "editor.minimap.enabled": false, + "editor.multiCursorModifier": "alt", + "editor.trimAutoWhitespace": true, + "editor.rulers": [80, 120], + "editor.maxTokenizationLineLength": 200000, + "editor.inlineSuggest.enabled": true, + "editor.semanticHighlighting.enabled": true, + "editor.insertSpaces": true, + "editor.formatOnType": true, + "editor.stickyScroll.enabled": false, + "editor.tabSize": 2, + "editor.autoClosingBrackets": "always", + "editor.autoClosingQuotes": "always", + "editor.guides.indentation": true, + "editor.guides.bracketPairs": true, + "files.autoSave": "onFocusChange", + "telemetry.telemetryLevel": "off", + "typescript.surveys.enabled": false, + "update.showReleaseNotes": false, + "security.workspace.trust.untrustedFiles": "open", + "workbench.startupEditor": "none", + "tailwindCSS.includeLanguages": { + "ruby": "html", + "erb": "html" + }, + "rubyLsp.pullDiagnosticsOn": "save", + "rubyLsp.enabledFeatures": { + "codeActions": true, + "diagnostics": false, + "documentHighlights": true, + "documentLink": true, + "documentSymbols": true, + "foldingRanges": true, + "formatting": true, + "hover": true, + "inlayHint": true, + "onTypeFormatting": true, + "selectionRanges": true, + "semanticHighlighting": true, + "completion": true, + "codeLens": true, + "definition": true, + "workspaceSymbol": true, + "signatureHelp": true + }, + "files.associations": { + "*.html.erb": "erb" + }, + "git.autofetch": true, + "github.copilot.enable": { + "*": true, + "plaintext": false, + "markdown": true, + "scminput": false + }, + "github.copilot.editor.enableAutoCompletions": true, + "git.confirmSync": false, + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[ruby]": { + "tailwindCSS.experimental.classRegex": ["\\bclass:\\s*[\"']([^\"']*)[\"']"], + "editor.defaultFormatter": "Shopify.ruby-lsp", + "editor.formatOnSave": true, + "editor.tabSize": 2, + "editor.insertSpaces": true, + "editor.semanticHighlighting.enabled": true, + "editor.formatOnType": true, + "files.trimTrailingWhitespace": true, + "files.trimFinalNewlines": true, + "editor.rulers": [120] + }, + "[erb]": { + "tailwindCSS.experimental.classRegex": ["\\bclass:\\s*[\"']([^\"']*)[\"']"], + "editor.defaultFormatter": "aliariff.vscode-erb-beautify", + "editor.formatOnSave": true + }, + "[jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[css]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[handlebars]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + } +} diff --git a/zsh-setup.sh b/zsh-setup.sh new file mode 100755 index 0000000..58d0677 --- /dev/null +++ b/zsh-setup.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Install Oh My Zsh +if [ ! -d "$HOME/.oh-my-zsh" ]; then + echo "Installing Oh My Zsh..." + sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended +else + echo "Oh My Zsh is already installed." +fi + +# Copy zshrc file +echo "Copying zshrc file..." +cp ~/code/dotfiles/zsh/zshrc ~/.zshrc + +# Copy custom theme +echo "Copying custom theme..." +cp ~/code/dotfiles/zsh/theme/yatish.zsh-theme ~/.oh-my-zsh/themes/ + +# Set ZSH_THEME in .zshrc +echo "Setting custom theme in .zshrc..." +sed -i '' 's/ZSH_THEME=".*"/ZSH_THEME="yatish"/' ~/.zshrc + +# Set up asdf +echo "Setting up asdf..." +echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ~/.zshrc + +echo "Zsh setup complete. Please restart your terminal or run 'source ~/.zshrc' to apply changes." diff --git a/zsh/theme/yatish27.zsh-theme b/zsh/theme/yatish27.zsh-theme new file mode 100644 index 0000000..07c97b4 --- /dev/null +++ b/zsh/theme/yatish27.zsh-theme @@ -0,0 +1,42 @@ +function collapse_pwd { + echo $(pwd | sed -e "s,^$HOME,~,") +} + +function prompt_char { + git branch >/dev/null 2>/dev/null && echo '±' && return + hg root >/dev/null 2>/dev/null && echo '☿' && return + echo '○' +} + +function battery_charge { + echo `$BAT_CHARGE` 2>/dev/null +} + +function virtualenv_info { + [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') ' +} + + function hg_prompt_info { + hg prompt --angle-brackets "\ + < on %{$fg[magenta]%}%{$reset_color%}>\ + < at %{$fg[yellow]%}%{$reset_color%}>\ + %{$fg[green]%}%{$reset_color%}< + patches: >" 2>/dev/null + } + +function ruby_ps1 { + ruby_version=`asdf current ruby | awk '{print $2}'` + echo $ruby_version +} + +PROMPT=' +%(?,%F{green},%F{red})%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} using %{$fg[blue]%}$(ruby_ps1)%{$reset_color%} in %{$fg_bold[green]%}$(collapse_pwd)%{$reset_color%}$(hg_prompt_info)$(git_prompt_info) +$(virtualenv_info)$(prompt_char) ' + +RPROMPT='' + +ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[red]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?" +ZSH_THEME_GIT_PROMPT_CLEAN="" \ No newline at end of file diff --git a/zsh/zshrc b/zsh/zshrc new file mode 100644 index 0000000..7277321 --- /dev/null +++ b/zsh/zshrc @@ -0,0 +1,114 @@ +# If you come from bash you might have to change your $PATH. +# export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:$PATH + +# Path to your Oh My Zsh installation. +export ZSH="$HOME/.oh-my-zsh" + +# Set name of the theme to load --- if set to "random", it will +# load a random theme each time Oh My Zsh is loaded, in which case, +# to know which specific one was loaded, run: echo $RANDOM_THEME +# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes +ZSH_THEME="yatish27" + +# Set list of themes to pick from when loading at random +# Setting this variable when ZSH_THEME=random will cause zsh to load +# a theme from this variable instead of looking in $ZSH/themes/ +# If set to an empty array, this variable will have no effect. +# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) + +# Uncomment the following line to use case-sensitive completion. +# CASE_SENSITIVE="true" + +# Uncomment the following line to use hyphen-insensitive completion. +# Case-sensitive completion must be off. _ and - will be interchangeable. +# HYPHEN_INSENSITIVE="true" + +# Uncomment one of the following lines to change the auto-update behavior +# zstyle ':omz:update' mode disabled # disable automatic updates +# zstyle ':omz:update' mode auto # update automatically without asking +# zstyle ':omz:update' mode reminder # just remind me to update when it's time + +# Uncomment the following line to change how often to auto-update (in days). +# zstyle ':omz:update' frequency 13 + +# Uncomment the following line if pasting URLs and other text is messed up. +# DISABLE_MAGIC_FUNCTIONS="true" + +# Uncomment the following line to disable colors in ls. +# DISABLE_LS_COLORS="true" + +# Uncomment the following line to disable auto-setting terminal title. +# DISABLE_AUTO_TITLE="true" + +# Uncomment the following line to enable command auto-correction. +# ENABLE_CORRECTION="true" + +# Uncomment the following line to display red dots whilst waiting for completion. +# You can also set it to another string to have that shown instead of the default red dots. +# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f" +# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765) +# COMPLETION_WAITING_DOTS="true" + +# Uncomment the following line if you want to disable marking untracked files +# under VCS as dirty. This makes repository status check for large repositories +# much, much faster. +# DISABLE_UNTRACKED_FILES_DIRTY="true" + +# Uncomment the following line if you want to change the command execution time +# stamp shown in the history command output. +# You can set one of the optional three formats: +# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" +# or set a custom format using the strftime function format specifications, +# see 'man strftime' for details. +# HIST_STAMPS="mm/dd/yyyy" + +# Would you like to use another custom folder than $ZSH/custom? +# ZSH_CUSTOM=/path/to/new-custom-folder + +# Which plugins would you like to load? +# Standard plugins can be found in $ZSH/plugins/ +# Custom plugins may be added to $ZSH_CUSTOM/plugins/ +# Example format: plugins=(rails git textmate ruby lighthouse) +# Add wisely, as too many plugins slow down shell startup. +plugins=(git macos brew) + +source $ZSH/oh-my-zsh.sh + +# User configuration + +# export MANPATH="/usr/local/man:$MANPATH" + +# You may need to manually set your language environment +# export LANG=en_US.UTF-8 + +# Preferred editor for local and remote sessions +# if [[ -n $SSH_CONNECTION ]]; then +# export EDITOR='vim' +# else +# export EDITOR='nvim' +# fi + +# Compilation flags +# export ARCHFLAGS="-arch $(uname -m)" + +# Set personal aliases, overriding those provided by Oh My Zsh libs, +# plugins, and themes. Aliases can be placed here, though Oh My Zsh +# users are encouraged to define aliases within a top-level file in +# the $ZSH_CUSTOM folder, with .zsh extension. Examples: +# - $ZSH_CUSTOM/aliases.zsh +# - $ZSH_CUSTOM/macos.zsh +# For a full list of active aliases, run `alias`. +# +# Example aliases +# alias zshconfig="mate ~/.zshrc" +# alias ohmyzsh="mate ~/.oh-my-zsh" + +# ZSH iterm word jump +bindkey "[D" backward-word +bindkey "[C" forward-word +bindkey "^[a" beginning-of-line +bindkey "^[e" end-of-line + + +eval "$(/opt/homebrew/bin/brew shellenv)" +. /opt/homebrew/opt/asdf/libexec/asdf.sh