diff --git a/.npmrc b/.npmrc index 0c1972d..2c11950 100644 --- a/.npmrc +++ b/.npmrc @@ -6,4 +6,4 @@ init-license=MIT scope=@${NPM_SCOPE} # set value NPM_SCOPE in .zshrc loglevel=notice registry=https://registry.npmjs.org/ -npm.pkg.github.com/:_authToken=${GH_TOKEN} # set value GH_TOKEN in .zshrc +npm.pkg.github.com/:_authToken=${NPM_TOKEN} # set value NPM_TOKEN in .zshrc diff --git a/Brewfile b/Brewfile deleted file mode 100644 index 73c00c7..0000000 --- a/Brewfile +++ /dev/null @@ -1,101 +0,0 @@ -tap "espanso/espanso" -tap "homebrew/bundle" -tap "localsend/localsend" -brew "xz" -brew "zstd" -brew "libtiff" -brew "jpeg-xl" -brew "c-ares" -brew "icu4c@76" -brew "libuv" -brew "openssl@3" -brew "node" -brew "bitwarden-cli" -brew "gettext" -brew "glib" -brew "duti" -brew "sqlite" -brew "gh" -brew "git" -brew "unbound" -brew "gnutls" -brew "netpbm" -brew "harfbuzz" -brew "python@3.13" -brew "graphviz" -brew "httpie" -brew "libssh" -brew "pipx" -brew "pyenv" -brew "python-argcomplete" -brew "qemu" -brew "yarn" -cask "alt-tab" -cask "balenaetcher" -cask "bitwarden" -cask "espanso" -cask "ghostty" -cask "latest" -cask "localsend" -cask "mark-text" -cask "monitorcontrol" -cask "notion-calendar" -cask "notunes" -cask "numi" -cask "pearcleaner" -cask "shottr" -cask "stats" -cask "warp" -cask "yaak" -vscode "aaron-bond.better-comments" -vscode "alefragnani.project-manager" -vscode "bradlc.vscode-tailwindcss" -vscode "christian-kohler.npm-intellisense" -vscode "christian-kohler.path-intellisense" -vscode "chrmarti.regex" -vscode "davidanson.vscode-markdownlint" -vscode "dbaeumer.vscode-eslint" -vscode "denoland.vscode-deno" -vscode "dracula-theme.theme-dracula" -vscode "dsznajder.es7-react-js-snippets" -vscode "editorconfig.editorconfig" -vscode "emmanuelbeziat.vscode-great-icons" -vscode "esbenp.prettier-vscode" -vscode "formulahendry.auto-close-tag" -vscode "formulahendry.auto-rename-tag" -vscode "github.copilot" -vscode "github.copilot-chat" -vscode "github.copilot-workspace" -vscode "github.vscode-github-actions" -vscode "github.vscode-pull-request-github" -vscode "gruntfuggly.todo-tree" -vscode "hashicorp.terraform" -vscode "hbenl.vscode-test-explorer" -vscode "idered.npm" -vscode "maxvanderschee.web-accessibility" -vscode "meganrogge.template-string-converter" -vscode "mikestead.dotenv" -vscode "ms-azuretools.vscode-docker" -vscode "ms-vscode-remote.remote-containers" -vscode "ms-vscode.live-server" -vscode "ms-vscode.test-adapter-converter" -vscode "ms-vsliveshare.vsliveshare" -vscode "mylesmurphy.prettify-ts" -vscode "nicoespeon.abracadabra" -vscode "orta.vscode-jest" -vscode "philnash.ngrok-for-vscode" -vscode "pwabuilder.pwa-studio" -vscode "quicktype.quicktype" -vscode "ritwickdey.liveserver" -vscode "saoudrizwan.claude-dev" -vscode "sburg.vscode-javascript-booster" -vscode "sleistner.vscode-fileutils" -vscode "sonarsource.sonarlint-vscode" -vscode "stevencl.adddoccomments" -vscode "stylelint.vscode-stylelint" -vscode "visualstudioexptteam.intellicode-api-usage-examples" -vscode "visualstudioexptteam.vscodeintellicode" -vscode "wayou.vscode-todo-highlight" -vscode "wmaurer.change-case" -vscode "xabikos.javascriptsnippets" -vscode "yoavbls.pretty-ts-errors" diff --git a/README.md b/README.md index bb4fb9a..a67b630 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,72 @@ # dotfiles -Hey! ๐Ÿ‘‹ +This is my dotfiles for personal app configs and customizations. I mainly use zsh, but you might adapt for bash or other shells. -This repo stores my personal app configs and customizations. I mainly use zsh, but you can adapt for bash or other shells. -Since I work with macOS and Ubuntu, configs are optimized for these OSs. But no worries - you can easily tweak them for other systems too! +This repo is 100% open for you to explore and customize. -## Usage +## Requirements -This repo is 100% open for you to explore and customize. Just clone it and swap my configs with yours - makes it super easy to get your dev environment up and running on any new machine. +You need to have the following tools installed: -## Getting Started +- [Homebrew](https://brew.sh/) +- [zsh](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH#install-and-set-up-zsh-as-default) +- [oh-my-zsh](https://ohmyz.sh/#install) +- [git](https://git-scm.com/downloads) -1. Clone this repository to your local machine: +## How to use + +1. Install Homebrew: + +```bash +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +``` + +2. Clone this repository and open folder `dotfiles`: ```bash -git clone git@github.com:tcelestino/dotfiles.git +git clone git@github.com:tcelestino/dotfiles.git && cd dotfiles ``` -2. Open folder `dotfiles` and set run file to install +3. Open `.zshrc` file and change variables `USER_NAME`, `USER_EMAIL` and `NPM_SCOPE`. You might set `GH_TOKEN` and `NPM_TOKEN` too. +4. Set your email and name for git on `.gitconfig` file. + +5. Install zsh (if you not have it installed): + +```bash +## linux +sudo apt update && sudo apt install zsh +``` ```bash -chmod +x install +## macos +brew install zsh ``` -3. Open `.zshrc` file and change variables "USER_NAME", "USER_EMAIL" and "NPM_SCOPE". You might set `GH_TOKEN` and `NPM_TOKEN` too. + +_zsh is default shell on latest versions of macOS_ + +6. Install oh-my-zsh: ```bash +sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" +``` -4. Run the install script +7. Run the install script: ```bash -./install +./install --ssh-email ``` -โš ๏ธ **Don't forget to set values `GH_TOKEN` and `NPM_TOKEN`!!** + +## Apps and dev tools + +My apps and dev tools for Linux and macOS. + +- [Linux apps](docs/linux-apps.md) +- [macOS apps](docs/macos-apps.md) +- [Dev tools](docs/dev-tools.md) ## Additional Configurations - To set the keyboard layout to include the 'รง' character on Ubuntu, follow the steps in the article "[Ajeitando o cedilha errado (ฤ‡) no Ubuntu Linux](https://www.danielkossmann.com/pt/ajeitando-cedilha-errado-ubuntu-linux/)" -- If you use iTerm2, you might import the color scheme and other configurations into iTerm2. The settings can be found in the "iterm2" folder. ## Contributing @@ -45,4 +75,5 @@ If you have any suggestions, improvements, or bug fixes, feel free to open an is This project follows the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. Please use it when making changes to the codebase. ## License + See in [LICENSE](LICENSE). diff --git a/docs/dev-tools.md b/docs/dev-tools.md new file mode 100644 index 0000000..4952476 --- /dev/null +++ b/docs/dev-tools.md @@ -0,0 +1,30 @@ +# Dev tools + +My dev tools for macOS and Linux + +| Name | Description | URL | +| ---------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------ | +| Beekeeper Studio | Database management tool | [https://www.beekeeperstudio.io/](https://www.beekeeperstudio.io/) | +| Cursor | AI-powered code editor | [https://www.cursor.com/](https://www.cursor.com/) | +| Deno | Runtime for JavaScript and TypeScript | [https://deno.com/](https://deno.com/) | +| Flatpak | Package manager for Linux | [https://flatpak.org/](https://flatpak.org/) | +| Git | Distributed version control system | [https://git-scm.com/](https://git-scm.com/) | +| MongoDB Compass | Database management tool | [https://www.mongodb.com/products/compass](https://www.mongodb.com/products/compass) | +| Node.js | JavaScript runtime for application development | [https://nodejs.org/](https://nodejs.org/) | +| OrbStack | Containerization tool | [https://orbstack.com/](https://orbstack.com/) | +| Redis | Database | [https://redis.io/](https://redis.io/) | +| VSCode | Code editor | [https://code.visualstudio.com/](https://code.visualstudio.com/) | +| Yaak | API client | [https://yaak.app/](https://yaak.app/) | +| Yarn | Fast and reliable package manager for Node.js | [https://yarnpkg.com/](https://yarnpkg.com/) | + +## NPM packages + +NPM packages I use globally + +| Name | Description | URL | +| ----------------- | ------------------------------- | -------------------------------------------------------------------------------------------------- | +| @nestjs/cli | NestJS Command Line Interface | [https://docs.nestjs.com/](https://docs.nestjs.com/) | +| fastify-cli | CLI for Fastify framework | [https://www.fastify.io/](https://www.fastify.io/) | +| git-cz | Tool for conventional commits | [https://www.npmjs.com/package/git-cz](https://www.npmjs.com/package/git-cz) | +| n | Node Version Manager | [https://github.com/tj/n/](https://github.com/tj/n/) | +| npm-check-updates | Tool to update npm dependencies | [https://www.npmjs.com/package/npm-check-updates](https://www.npmjs.com/package/npm-check-updates) | diff --git a/docs/linux-apps.md b/docs/linux-apps.md new file mode 100644 index 0000000..81a8c78 --- /dev/null +++ b/docs/linux-apps.md @@ -0,0 +1,10 @@ +# Linux apps + +My Linux apps + +| Name | Description | URL | +| ---------------- | -------------------------------- | -------------------------------------------------------------- | +| Firefox | Web browser | [https://www.firefox.com/](https://www.firefox.com/) | +| Gnome Extensions | Power to Gnome | [https://extensions.gnome.org/](https://extensions.gnome.org/) | +| Terminator | Multi-monitor terminal for Linux | [https://gnome-terminator.org/](https://gnome-terminator.org/) | +| Ulauncher | Spotlight for Linux | [https://ulauncher.io/](https://ulauncher.io/) | diff --git a/docs/macos-apps.md b/docs/macos-apps.md new file mode 100644 index 0000000..ff6ca3f --- /dev/null +++ b/docs/macos-apps.md @@ -0,0 +1,74 @@ +# macOS apps + +My macOS apps + +| Name | Description | URL | +| ------------------ | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Amphetamine | Keep your Mac awake | [https://apps.apple.com/us/app/amphetamine/id937984704?mt=12](https://apps.apple.com/us/app/amphetamine/id937984704?mt=12) | +| balenaEtcher | Flash OS images to SD cards & USB drives. | [https://github.com/balena-io/etcher/tree/master](https://github.com/balena-io/etcher/tree/master) | +| Battery Monitor | Monitor your battery | [https://apps.apple.com/us/app/battery-monitor-health-info/id836505650?mt=12](https://apps.apple.com/us/app/battery-monitor-health-info/id836505650?mt=12) | +| Bear | Markdown notes | [https://bear.app](https://bear.app) | +| Beekeeper Studio | Database management tool | [https://www.beekeeperstudio.io/](https://www.beekeeperstudio.io/) | +| Bitwarden | Password manager | [https://bitwarden.com](https://bitwarden.com) | +| Budget Flow | Financial Manager | [https://budget-flow.app/](https://budget-flow.app/) | +| Claude | Anthropic AI app | [https://claude.ai/download](https://claude.ai/download) | +| Daisy Disk | Find it. Clean it | [https://daisydiskapp.com/](https://daisydiskapp.com/) | +| Espanso | Text expander | [https://espanso.org/](https://espanso.org/) | +| Floorp | Web browser | [https://www.floorp.app/](https://www.floorp.app/) | +| f.lux | Color temperature | [https://justgetflux.com/](https://justgetflux.com/) | +| Ghostty | Terminal | [https://ghostty.org/](https://ghostty.org/) | +| Gifski | GIF encoder based on libimagequant (pngquant) | [https://github.com/ImageOptim/gifski/](https://github.com/ImageOptim/gifski/) | +| Google Drive | Synchronize your GDrive | [https://www.google.com/drive/download/](https://www.google.com/drive/download/) | +| Itsycal | Calendar on menu bar | [https://www.mowglii.com/itsycal/](https://www.mowglii.com/itsycal/) | +| Kaspersky VPN | VPN | [https://www.kaspersky.com.br/vpn-secure-connection/download-vpn](https://www.kaspersky.com.br/vpn-secure-connection/download-vpn) | +| Latest | A small utility app for macOS about all the latest updates | [https://github.com/mangerlahn/Latest](https://github.com/mangerlahn/Latest) | +| LocalSend | Share files all devices | [https://localsend.org/](https://localsend.org/) | +| Maccy | Clipboard manager | [https://maccy.app/](https://maccy.app/) | +| Monitor Control | Control your display's brightness & volume on your Mac | [https://github.com/MonitorControl/MonitorControl](https://github.com/MonitorControl/MonitorControl) | +| NextDNS | DNS | [https://nextdns.io](https://nextdns.io) | +| noTunes | Prevent iTunes or Apple Music from launching | [https://github.com/tombonez/noTunes](https://github.com/tombonez/noTunes) | +| Notion | Notes | [https://www.notion.so/](https://www.notion.so/) | +| Notion Calendar | Calendar | [https://www.notion.com/product/calendar](https://www.notion.com/product/calendar) | +| Numi | Advanced calculator | [https://numi.app/](https://numi.app/) | +| Pearcleaner | Remove apps with security | [https://www.nektony.com/products/pear-cleaner](https://www.nektony.com/products/pear-cleaner) | +| Picview | Image viewer | [https://apps.apple.com/br/app/picview-image-viewer/id6452016140?mt=12](https://apps.apple.com/br/app/picview-image-viewer/id6452016140?mt=12) | +| Raycast | Spotlight for macOS | [https://www.raycast.com/](https://www.raycast.com/) | +| Rectangle | Window manager | [https://rectangleapp.com/](https://rectangleapp.com/) | +| Shottr | Screenshot tool | [https://shottr.cc/](https://shottr.cc/) | +| Speediness | Speed test | [https://sindresorhus.com/speediness](https://sindresorhus.com/speediness) | +| Stats | Status bar | [https://github.com/exelban/stats](https://github.com/exelban/stats) | +| The Unarchiver | Archive manager | [https://theunarchiver.com/](https://theunarchiver.com/) | +| Todoist | Todo list | [https://www.todoist.com](https://www.todoist.com) | +| UTM | Running OS for macOS | [https://mac.getutm.app/](https://mac.getutm.app/) | +| Unsplash Wallpaper | Wallpaper for macOS | [https://apps.apple.com/us/app/unsplash-wallpapers/id1284863847?mt=12](https://apps.apple.com/us/app/unsplash-wallpapers/id1284863847?mt=12) | +| VLC | Media player | [https://www.videolan.org/vlc/](https://www.videolan.org/vlc/) | + +## Raycast Extensions + +My list of Raycast extensions. Yes, I use Raycast free! ๐Ÿ˜€. + +- Amphetamine +- Bear Notes +- Clean Keyboard +- Color Picker +- Cursor +- Download Manager +- Emojis Search +- Github +- Google Workspace +- HTTP Status Codes +- Installed Extensions +- Kill Process +- Model Context Protocol Registry +- Oh My Zsh Plugins +- Raindrop.io +- Search MDN +- Search npm packages +- Shell history +- Svgl +- Timers +- Todoist +- UUID Generator +- Video Downloader + +See more extensions at [https://www.raycast.com/store](https://www.raycast.com/store) diff --git a/extras/fonts/JetBrainsMonoNL-Bold.ttf b/extras/fonts/JetBrainsMonoNL-Bold.ttf new file mode 100644 index 0000000..f78f84f Binary files /dev/null and b/extras/fonts/JetBrainsMonoNL-Bold.ttf differ diff --git a/extras/fonts/JetBrainsMonoNL-ExtraLight.ttf b/extras/fonts/JetBrainsMonoNL-ExtraLight.ttf new file mode 100644 index 0000000..6da7b75 Binary files /dev/null and b/extras/fonts/JetBrainsMonoNL-ExtraLight.ttf differ diff --git a/extras/fonts/JetBrainsMonoNL-Regular.ttf b/extras/fonts/JetBrainsMonoNL-Regular.ttf new file mode 100644 index 0000000..70d2ec9 Binary files /dev/null and b/extras/fonts/JetBrainsMonoNL-Regular.ttf differ diff --git a/git/.git-commit-template b/git/.git-commit-template new file mode 100644 index 0000000..ed875a7 --- /dev/null +++ b/git/.git-commit-template @@ -0,0 +1,18 @@ +# Title (maximum 50 characters) +# +# Briefly and imperatively describe the change made + +# Blank line + +# Message body (maximum 72 characters per line) +# +# Explain what and why, not just how. If necessary, provide context, +# motivations, and the impact of the change. Use as many lines as needed. + +# Blank line + +# Footer (optional) +# +# Reference issues, pull requests, or breaking changes, if applicable. +# Example: Closes #123, Related to #456 + diff --git a/git/.gitconfig b/git/.gitconfig index c0e34c6..eeba04c 100644 --- a/git/.gitconfig +++ b/git/.gitconfig @@ -1,20 +1,23 @@ -# This is Git's per-user configuration file. - [user] - name = "" - email = "" + name = "" # e.g. Tiago Celestino + email = "" # e.g. your.email@provider.com [mergetool] keepBackup = true [core] - editor = vim + editor = $EDITOR excludesfile = ~/.gitignore attributesfile = ~/.gitattributes [init] defaultBranch = main +[push] + autoSetupRemote = true + +[commit] + template = ~/.git-commit-template [alias] ci = commit @@ -33,10 +36,10 @@ fu = fetch origin pum = pull origin master pumn = pull origin main - pud = pull origin dev + pud = pull origin develop fupum = !git co master && git fu && git pum fupumn = !git co main && git fu && git pumn - fupud = !git co dev && git fu && git pud + fupud = !git co develop && git fu && git pud rb = "!f() { \ branch=\"$(git branch 2>/dev/null | grep \\* | awk '{ print $2 }')\" && \ if git rev-parse --verify master >/dev/null 2>&1; then \ @@ -67,3 +70,4 @@ deletebranches = !git branch --merged | grep -v \\* | xargs git branch -D prune = !git remote prune origin cleanup = "!f() { git branch | grep -v \" $(git rev-parse --abbrev-ref HEAD)\" | xargs git branch -D; git fetch --prune;}; f" + diff --git a/install b/install old mode 100644 new mode 100755 index 0b7a3ac..098f8cd --- a/install +++ b/install @@ -5,28 +5,84 @@ set -euo pipefail # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' +YELLOW='\033[1;33m' NC='\033[0m' # Get current location DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -# Helper function to print info messages +# Global variable for user email +SSH_EMAIL="" + +# Array to store completed steps +declare -a completed_steps=() + +# Show usage information +# @param $1 Exit code (optional) +show_usage() { + local exit_code="${1:-0}" + echo "Usage: $0 --ssh-email " + echo "" + echo "Options:" + echo " --ssh-email Email address for SSH key generation (required)" + echo " -h, --help Show this help message" + echo "" + echo "Example:" + echo " $0 --ssh-email user@example.com" + exit "$exit_code" +} + +# Parse command line arguments +parse_arguments() { + while [[ $# -gt 0 ]]; do + case $1 in + --ssh-email) + SSH_EMAIL="$2" + shift 2 + ;; + -h|--help) + show_usage 0 + ;; + *) + echo -e "${RED}[ERROR]${NC} Unknown option: $1" + show_usage 1 + ;; + esac + done + + # Validate required arguments + if [[ -z "$SSH_EMAIL" ]]; then + echo -e "${RED}[ERROR]${NC} Email address is required" + show_usage 1 + fi + + # Validate email format (basic validation) + if [[ ! "$SSH_EMAIL" =~ ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$ ]]; then + echo -e "${RED}[ERROR]${NC} Invalid email format: $SSH_EMAIL" + exit 1 + fi +} + +# Register a completed step +# @param $1 Step name +register_completed_step() { + local step="$1" + completed_steps+=("$step") +} + +# Print info messages +# @param $1 Message log() { echo -e "${GREEN}[INFO]${NC} $1" } -# Helper function to print error messages in red and exit +# Print error messages in red and exit +# @param $1 Message error() { echo -e "${RED}[ERROR]${NC} $1" exit 1 } -# Verify if required dependencies (Node.js, Homebrew, Git) are installed -# check_dependencies() { -# command -v node >/dev/null 2>&1 || error "Node.js is required but not installed. https://nodejs.org/" -# command -v git >/dev/null 2>&1 || error "Git is required but not installed. https://git-scm.com/downloads" -# } - # Create a symbolic link # @param $1 Source file path # @param $2 Destination link path @@ -91,88 +147,169 @@ copy_file() { fi } -# Install Homebrew if not already installed -install_brew() { - if ! command -v brew >/dev/null 2>&1; then - log "Installing Homebrew..." - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - else - log "Homebrew is already installed." +# Configure zsh +setup_zsh() { + if ! command -v zsh >/dev/null 2>&1; then + error "zsh is not installed. Please install zsh before continuing." fi -} -# Install Oh My Zsh if not already installed -install_oh_my_zsh() { - if [ -d "$HOME/.oh-my-zsh" ]; then - log "oh-my-zsh is already installed." - else - log "Installing oh-my-zsh..." - if ! sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"; then - error "Failed to install oh-my-zsh" - fi + if [ "$DOTFILES_ZSH_SETUP" = true ]; then + log "oh-my-zsh already setup. Skipping..." + return fi -} -# Install Deno runtime if not already installed -install_deno() { - if [ -d "$HOME/.deno/bin/deno" ]; then - log "Deno is already installed.." + # copy zshrc based on the OS + if [[ "$OSTYPE" == "darwin"* ]]; then + log "Copying zshrc for macOS..." + copy_file "$DIR/macos/.zshrc" "$HOME/.zshrc" else - log "Installing Deno" - if ! sh -c "$(curl -fsSL https://deno.land/install.sh)"; then - error "Failed to install Deno" - fi + log "Copying zshrc for Linux..." + copy_file "$DIR/linux/.zshrc" "$HOME/.zshrc" fi + + copy_dir "$DIR/zsh/themes" "$HOME/.oh-my-zsh/themes" + copy_file "$DIR/zsh/aliases.zsh" "$HOME/.oh-my-zsh/custom/aliases.zsh" + copy_dir "$DIR/zsh/custom-functions" "$HOME/.oh-my-zsh/plugins/custom-functions" + + register_completed_step "zsh" + log "zsh settings configured successfully!" + + DOTFILES_ZSH_SETUP=true } -# Configure Git settings by linking gitconfig file +# Configure Git setup_git() { + if [ "$DOTFILES_GIT_SETUP" = true ]; then + log "git already setup. Skipping..." + return + fi + copy_file "$DIR/git/.gitconfig" "$HOME/.gitconfig" copy_file "$DIR/git/.gitignore" "$HOME/.gitignore" copy_file "$DIR/git/.gitattributes" "$HOME/.gitattributes" -} + copy_file "$DIR/git/.git-commit-template" "$HOME/.git-commit-template" + register_completed_step "Git" + log "Git settings configured successfully!" -# Configure Zsh settings by linking various configuration files -setup_zsh() { - copy_file "$DIR/zsh/.zshrc" "$HOME/.zshrc" - copy_dir "$DIR/zsh/themes" "$HOME/.oh-my-zsh/themes" - copy_file "$DIR/zsh/aliases.zsh" "$HOME/.oh-my-zsh/custom/aliases.zsh" - copy_dir "$DIR/zsh/custom-functions" "$HOME/.oh-my-zsh/plugins/custom-functions" + DOTFILES_GIT_SETUP=true } -# Install global NPM packages required for development -install_global_npm_pkg() { - log "Installing global npm packages..." - npm install -g git-cz # https://github.com/streamich/git-cz - npm install -g n # https://github.com/tj/n - npm install -g fastify-cli #https://fastify.dev/ +# Configure Homebrew and install packages from Brewfile +setup_brew() { + if ! command -v brew >/dev/null 2>&1; then + error "Homebrew is not installed. Please install Homebrew first." + fi + + if [ "$DOTFILES_BREW_SETUP" = true ]; then + log "Brewfile already setup. Skipping..." + return + fi + + # copy Brewfile based on the OS + if [[ "$OSTYPE" == "darwin"* ]]; then + log "Copying Brewfile for macOS..." + copy_file "$DIR/macos/.Brewfile" "$HOME/.Brewfile" + else + log "Copying Brewfile for Linux..." + copy_file "$DIR/linux/.Brewfile" "$HOME/.Brewfile" + fi + + log "Executing brew bundle install..." + if ! brew bundle install --file="$HOME/.Brewfile"; then + error "Brew bundle install failed" + fi + register_completed_step "Homebrew" + log "Homebrew settings configured successfully!" + + DOTFILES_BREW_SETUP=true } -# Configure NPM settings and install global packages +# Configure NPM setup_npm() { + if [ "$DOTFILES_NPM_SETUP" = true ]; then + log "npm already setup. Skipping..." + return + fi + copy_file "$DIR/.npmrc" "$HOME/.npmrc" + register_completed_step "NPM" + log "NPM configured successfully!" # Install npm globally without sudo. Based on https://github.com/sindresorhus/guides/blob/main/npm-global-without-sudo.md if [ -d "$HOME/.npm-packages" ]; then log ".npm-packages folder exists" + return else mkdir -p "$HOME/.npm-packages" fi - install_global_npm_pkg + DOTFILES_NPM_SETUP=true } -# Configure Homebrew and install packages from Brewfile -setup_brew() { - copy_file "$DIR/Brewfile" "$HOME/Brewfile" - log "Executing brew bundle install..." - if ! brew bundle install; then - error "Brew bundle install failed" +# Install global npm packages +setup_global_npm_packages() { + if ! command -v node >/dev/null 2>&1; then + error "node is not installed. Please install node first." + fi + + if [ "$DOTFILES_NPM_SETUP" = true ]; then + log "global npm packages already setup. Skipping..." + return + fi + + log "Installing global npm packages..." + npm install -g npm-check-updates n git-cz @nestjs/cli fastify-cli yarn + register_completed_step "npm packages" + log "npm packages installed successfully!" + + DOTFILES_NPM_SETUP=true +} + +# Configure SSH +setup_ssh() { + if [ -f "$HOME/.ssh/id_ed25519" ]; then + log "SSH key already exists. Skipping..." + return + fi + + if [ "$DOTFILES_SSH_SETUP" = true ]; then + log "SSH already setup. Skipping..." + return fi + + log "Generating SSH key for email: $SSH_EMAIL" + ssh-keygen -t ed25519 -C "$SSH_EMAIL" + log "SSH key generated successfully!" + + log "Adding SSH agent in background..." + eval "$(ssh-agent -s)" + log "SSH agent added to the background successfully!" + + log "Adding SSH key to the ssh-agent..." + if [[ "$OSTYPE" == "darwin"* ]]; then + ssh-add --apple-use-keychain ~/.ssh/id_ed25519 + else + ssh-add ~/.ssh/id_ed25519 + fi + log "SSH key added to the ssh-agent successfully!" + + log "Adding SSH config..." + copy_file "$DIR/ssh/config" "$HOME/.ssh/config" + log "SSH config added successfully!" + + register_completed_step "ssh" + log "SSH configured successfully!" + + DOTFILES_SSH_SETUP=true } -# Install custom fonts based on the operating system +# Configure my favorites fonts setup_fonts() { + if [ "$DOTFILES_FONTS_SETUP" = true ]; then + log "fonts already setup. Skipping..." + return + fi + if [[ "$OSTYPE" == "darwin"* ]]; then # macOS local font_dir="$HOME/Library/Fonts" @@ -180,7 +317,10 @@ setup_fonts() { mkdir -p "$font_dir" fi log "Installing fonts for macOS..." - cp "$DIR/extras/fonts/"* "$font_dir/" + copy_dir "$DIR/extras/fonts/"* "$font_dir/" + log "Fonts installed successfully!" + + DOTFILES_FONTS_SETUP=true elif [[ "$OSTYPE" == "linux-gnu"* ]]; then # Ubuntu/Linux local font_dir="$HOME/.local/share/fonts" @@ -188,37 +328,133 @@ setup_fonts() { mkdir -p "$font_dir" fi log "Installing fonts for Linux..." - cp "$DIR/extras/fonts/"* "$font_dir/" + copy_dir "$DIR/extras/fonts/"* "$font_dir/" + + if ! fc-cache -f -v; then + log "Installing Fontconfig..." + sudo apt update && sudo apt install fontconfig + log "Fontconfig installed successfully!" + fi + + log "Fontcaching..." fc-cache -f -v + log "Fontcaching done!" + + register_completed_step "Fonts" + log "Fonts configured successfully!" + + DOTFILES_FONTS_SETUP=true else error "Unsupported operating system" fi } -# Configure macOS system settings if running on macOS +# Configure macOS setup_macos() { - if [[ "$OSTYPE" == "darwin"* ]]; then - log "Setting up macOS..." - sh .macos + if [ "$DOTFILES_MACOS_SETUP" = true ]; then + log "macOS already setup. Skipping..." + return + fi + + log "Settings for macOS" + + if [[ -x "$DIR/macos/.macos" ]]; then + sh "$DIR/macos/.macos" + register_completed_step "macOS" + log "macOS settings configured successfully!" + copy_file "$DIR/extras/duti_picview.config" "$HOME/duti_picview.config" # Configure duti (macOS default application manager) settings + else + error "$DIR/macos/.macos not found or not executable." + fi + + DOTFILES_MACOS_SETUP=true +} + +ask_continue() { + local message="$1" + local step="$2" + echo -e "\n${GREEN}[INFO]${NC} Step $step: $message" + read -p "Your choice (Y/n/q): " response + + if [ -z "$response" ]; then + response="y" fi + + case "$response" in + [Yy]*) + return 0 + ;; + [Nn]*) + log "Step $step skipped." + return 1 + ;; + [Qq]*) + log "Installation interrupted by user." + exit 0 + ;; + *) + log "Invalid option. Please try again." + ask_continue "$message" "$step" + ;; + esac } main() { + # Parse command line arguments first + parse_arguments "$@" + log "Starting installation from $DIR..." + log "Email for SSH key: $SSH_EMAIL" + log "This script will configure your environment with the following steps:" + + echo "1. Configure Zsh" + echo "2. Configure Homebrew and install packages" + echo "3. Configure Git" + echo "4. Configure SSH" + echo "5. Configure NPM" + echo "6. Install global npm packages" + # echo "7. Set custom fonts" + + if [[ "$OSTYPE" == "darwin"* ]]; then + echo "7. Configure macOS" + fi + + if ask_continue "Configure Zsh" "1"; then + setup_zsh + fi + + if ask_continue "Configure Homebrew and install packages" "2"; then + setup_brew + fi + + if ask_continue "Configure Git" "3"; then + setup_git + fi + + if ask_continue "Configure SSH" "4"; then + setup_ssh + fi - install_oh_my_zsh - install_brew - install_deno + if ask_continue "Configure NPM" "5"; then + setup_npm + fi + + if ask_continue "Install global npm packages" "6"; then + setup_global_npm_packages + fi + + # if ask_continue "Set custom fonts" "7"; then + # setup_fonts + # fi - setup_zsh - setup_brew - setup_git - setup_npm - setup_macos - setup_fonts + if [[ "$OSTYPE" == "darwin"* ]]; then + if ask_continue "Configure macOS" "7"; then + setup_macos + fi + fi - log "Settings completed successfully! ๐ŸŽ‰" + log "Configurations completed successfully! ๐ŸŽ‰" } main "$@" diff --git a/iterm2/Dracula.itermcolors b/iterm2/Dracula.itermcolors deleted file mode 100644 index 619da48..0000000 --- a/iterm2/Dracula.itermcolors +++ /dev/null @@ -1,225 +0,0 @@ - - - - - - - - Ansi 0 Color - - Blue Component - 0.0 - Green Component - 0.0 - Red Component - 0.0 - - Ansi 1 Color - - Blue Component - 0.3333333432674408 - Green Component - 0.3333333432674408 - Red Component - 1 - - Ansi 10 Color - - Blue Component - 0.4823529411764706 - Green Component - 0.98039215686274506 - Red Component - 0.31372549019607843 - - Ansi 11 Color - - Blue Component - 0.5490196078431373 - Green Component - 0.98039215686274506 - Red Component - 0.94509803921568625 - - Ansi 12 Color - - Blue Component - 0.97647058823529409 - Green Component - 0.57647058823529407 - Red Component - 0.74117647058823533 - - Ansi 13 Color - - Blue Component - 0.77647058823529413 - Green Component - 0.47450980392156861 - Red Component - 1 - - Ansi 14 Color - - Blue Component - 0.99215686274509807 - Green Component - 0.9137254901960784 - Red Component - 0.54509803921568623 - - Ansi 15 Color - - Blue Component - 1 - Green Component - 1 - Red Component - 1 - - Ansi 2 Color - - Blue Component - 0.4823529411764706 - Green Component - 0.98039215686274506 - Red Component - 0.31372549019607843 - - Ansi 3 Color - - Blue Component - 0.5490196078431373 - Green Component - 0.98039215686274506 - Red Component - 0.94509803921568625 - - Ansi 4 Color - - Blue Component - 0.97647058823529409 - Green Component - 0.57647058823529407 - Red Component - 0.74117647058823533 - - Ansi 5 Color - - Blue Component - 0.77647058823529413 - Green Component - 0.47450980392156861 - Red Component - 1 - - Ansi 6 Color - - Blue Component - 0.99215686274509807 - Green Component - 0.9137254901960784 - Red Component - 0.54509803921568623 - - Ansi 7 Color - - Blue Component - 0.73333334922790527 - Green Component - 0.73333334922790527 - Red Component - 0.73333334922790527 - - Ansi 8 Color - - Blue Component - 0.33333333333333331 - Green Component - 0.33333333333333331 - Red Component - 0.33333333333333331 - - Ansi 9 Color - - Blue Component - 0.33333333333333331 - Green Component - 0.33333333333333331 - Red Component - 1 - - Background Color - - Blue Component - 0.15977837145328522 - Green Component - 0.12215272337198257 - Red Component - 0.11765811592340469 - - Bold Color - - Blue Component - 0.90237069129943848 - Green Component - 0.90237069129943848 - Red Component - 0.90237069129943848 - - Cursor Color - - Blue Component - 0.73333334922790527 - Green Component - 0.73333334922790527 - Red Component - 0.73333334922790527 - - Cursor Text Color - - Blue Component - 1 - Green Component - 1 - Red Component - 1 - - Foreground Color - - Blue Component - 0.90032327175140381 - Green Component - 0.90032327175140381 - Red Component - 0.90032327175140381 - - Selected Text Color - - Blue Component - 1 - Green Component - 1 - Red Component - 1 - - Selection Color - - Blue Component - 0.35294118523597717 - Green Component - 0.27843138575553894 - Red Component - 0.26666668057441711 - - - diff --git a/linux/.Brewfile b/linux/.Brewfile new file mode 100644 index 0000000..f33a439 --- /dev/null +++ b/linux/.Brewfile @@ -0,0 +1,53 @@ +tap "homebrew/bundle" +tap "espanso/espanso" +tap "localsend/localsend" +# TIFF library and utilities +brew "libtiff" +# Cryptography and SSL/TLS Toolkit +brew "openssl@3" +# Command-line interface for SQLite +brew "sqlite" +# Interpreted, interactive, object-oriented programming language +brew "python@3.13" +# Core application library for C +brew "glib" +# Asynchronous DNS library +brew "c-ares" +# Multi-platform support library with a focus on asynchronous I/O +brew "libuv" +# Secure and free password manager for all of your devices +brew "bitwarden-cli" +# GNU compiler collection +brew "gcc" +# GNU internationalization (i18n) and localization (l10n) library +brew "gettext" +# GitHub command-line tool +brew "gh" +# Distributed revision control system +brew "git" +# Validating, recursive, caching DNS resolver +brew "unbound" +# GNU Transport Layer Security (TLS) Library +brew "gnutls" +# Image manipulation +brew "netpbm" +# OpenType text shaping engine +brew "harfbuzz" +# Graph visualization software from AT&T and Bell Labs +brew "graphviz" +# User-friendly cURL replacement (command-line HTTP client) +brew "httpie" +# C/C++ and Java libraries for Unicode and globalization +brew "icu4c@76" +# C library SSHv1/SSHv2 client and server protocols +brew "libssh" +# Execute binaries from Python packages in isolated environments +brew "pipx" +# Python version management +brew "pyenv" +# Tab completion for Python argparse +brew "python-argcomplete" +# Generic machine emulator and virtualizer +brew "qemu" +# JavaScript package manager +brew "yarn" diff --git a/linux/.zshrc b/linux/.zshrc new file mode 100644 index 0000000..67e02c5 --- /dev/null +++ b/linux/.zshrc @@ -0,0 +1,65 @@ +DISABLE_AUTO_UPDATE="true" +DISABLE_MAGIC_FUNCTIONS="true" +DISABLE_COMPFIX="true" + +autoload -Uz compinit +if [ "$(date +'%j')" != "$(stat -f '%Sm' -t '%j' ~/.zcompdump 2>/dev/null)" ]; then + compinit +else + compinit -C +fi + +export ZSH=$HOME/.oh-my-zsh + +ZSH_THEME="dracula" + +plugins=(brew copypath copyfile custom-functions deno docker docker-compose extract git history npm python ubuntu vscode web-search yarn) + +# global +export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" +export PATH=$HOME/local/bin:$PATH +export NPM_PACKAGES="${HOME}/.npm-packages" +export PATH="$NPM_PACKAGES/bin:$PATH" +export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" +#export JAVA_HOME="$(/usr/libexec/java_home -v 1.$JAVA_VERSION)" # enable this if you are using java +#export PATH=/usr/share/maven/bin:$PATH # enable this if you are using maven +#export PATH=$HOME/mongodb/bin:$PATH # enable this if you are using mongodb +#export PATH=$PATH:~/.composer/vendor/bin # enable this if you are using composer + +# github +export GH_TOKEN="" # create token at https://github.com/settings/apps select "Personal access tokens" + +# ssh +export SSH_KEY_PATH=$HOME/.ssh/id_ed25519 + +# node and npm +export NODE_ENV="development" +export NPM_TOKEN="" # create token at https://www.npmjs.com/settings/tokens +export NPM_SCOPE="" # e.g. tcelestino + +# local +export USER_NAME="" # e.g. tcelestino +export USER_EMAIL="" # e.g. your.email@provider.com + +# preferred editor for local and remote sessions +if [[ -n $SSH_CONNECTION ]]; then + export EDITOR='vim' +else + export EDITOR='code' +fi + +# web search custom search engines +ZSH_WEB_SEARCH_ENGINES=( + reddit "https://www.reddit.com/search/?q=" + linkedin "https://www.linkedin.com/search/results/all/?keywords=" + mdn "https://developer.mozilla.org/search?q=" +) + +# deno settings +. "$HOME/.deno/env" + +# homebrew +eval "$($HOME/.linuxbrew/bin/brew shellenv)" + +source $ZSH/oh-my-zsh.sh + diff --git a/macos/.Brewfile b/macos/.Brewfile new file mode 100644 index 0000000..9d396c5 --- /dev/null +++ b/macos/.Brewfile @@ -0,0 +1,96 @@ +tap "espanso/espanso" +tap "localsend/localsend" +# General-purpose data compression with high compression ratio +brew "xz" +# Zstandard is a real-time compression algorithm +brew "zstd" +# TIFF library and utilities +brew "libtiff" +# Asynchronous DNS library +brew "c-ares" +# Multi-platform support library with a focus on asynchronous I/O +brew "libuv" +# Cryptography and SSL/TLS Toolkit +brew "openssl@3" +# Platform built on V8 to build network applications +brew "node" +# Secure and free password manager for all of your devices +brew "bitwarden-cli" +# GNU internationalization (i18n) and localization (l10n) library +brew "gettext" +# Core application library for C +brew "glib" +# Select default apps for documents and URL schemes on macOS +brew "duti" +# GitHub command-line tool +brew "gh" +# Distributed revision control system +brew "git" +# Validating, recursive, caching DNS resolver +brew "unbound" +# GNU Transport Layer Security (TLS) Library +brew "gnutls" +# Image manipulation +brew "netpbm" +# OpenType text shaping engine +brew "harfbuzz" +# Graph visualization software from AT&T and Bell Labs +brew "graphviz" +# Command-line interface for SQLite +brew "sqlite" +# Interpreted, interactive, object-oriented programming language +brew "python@3.13" +# User-friendly cURL replacement (command-line HTTP client) +brew "httpie" +# C/C++ and Java libraries for Unicode and globalization +brew "icu4c@76" +# C library SSHv1/SSHv2 client and server protocols +brew "libssh" +# Execute binaries from Python packages in isolated environments +brew "pipx" +# Python version management +brew "pyenv" +# Tab completion for Python argparse +brew "python-argcomplete" +# Generic machine emulator and virtualizer +brew "qemu" +# Persistent key-value database, with built-in net interface +brew "redis" +# JavaScript package manager +brew "yarn" +# Enable Windows-like alt-tab +cask "alt-tab" +# Tool to flash OS images to SD cards & USB drives +cask "balenaetcher" +# Cross platform SQL editor and database management app +cask "beekeeper-studio" +# Desktop password and login vault +cask "bitwarden" +# Cross-platform Text Expander written in Rust +cask "espanso" +# Terminal emulator that uses platform-native UI and GPU acceleration +cask "ghostty" +# Utility that shows the latest app updates +cask "latest" +# Open-source cross-platform alternative to AirDrop +cask "localsend" +# Markdown editor +cask "mark-text" +# Tool to control external monitor brightness & volume +cask "monitorcontrol" +# Calendar for professionals and teams +cask "notion-calendar" +# Simple application that will prevent iTunes or Apple Music from launching +cask "notunes" +# Calculator and converter application +cask "numi" +# Replacement for Docker Desktop +cask "orbstack" +# Utility to uninstall apps and remove leftover files from old/uninstalled apps +cask "pearcleaner" +# Screenshot measurement and annotation tool +cask "shottr" +# System monitor for the menu bar +cask "stats" +# REST, GraphQL and gRPC client +cask "yaak" diff --git a/macos/.ghostty-config b/macos/.ghostty-config new file mode 100644 index 0000000..68f76c1 --- /dev/null +++ b/macos/.ghostty-config @@ -0,0 +1,6 @@ +font-family = "JetBrains Mono NL" +font-size = 16 +theme = dracula + +#keybind = super+v=paste_from_selection +#keybind = super+shift+v=paste_from_clipboard diff --git a/.macos b/macos/.macos similarity index 99% rename from .macos rename to macos/.macos index 676b73a..b069a2f 100755 --- a/.macos +++ b/macos/.macos @@ -137,6 +137,9 @@ defaults write "com.apple.systemsound" "com.apple.sound.uiaudio.enabled" -int 0 echo -n 'a' | sudo tee /private/var/db/.AccessibilityAPIEnabled > /dev/null 2>&1 sudo chmod 444 /private/var/db/.AccessibilityAPIEnabled +# Disable shake mouse pointer to locate +defaults write ~/Library/Preferences/.GlobalPreferences CGDisableCursorLocationMagnification -bool YES + # Enable full keyboard access for all controls # (e.g. enable Tab in modal dialogs) defaults write NSGlobalDomain AppleKeyboardUIMode -int 3 diff --git a/macos/.zshrc b/macos/.zshrc new file mode 100644 index 0000000..2464206 --- /dev/null +++ b/macos/.zshrc @@ -0,0 +1,60 @@ +DISABLE_AUTO_UPDATE="true" +DISABLE_MAGIC_FUNCTIONS="true" +DISABLE_COMPFIX="true" + +autoload -Uz compinit +if [ "$(date +'%j')" != "$(stat -f '%Sm' -t '%j' ~/.zcompdump 2>/dev/null)" ]; then + compinit +else + compinit -C +fi + +export ZSH=$HOME/.oh-my-zsh + +ZSH_THEME="dracula" + +plugins=(brew copypath copyfile custom-functions deno docker docker-compose extract git history macos npm python vscode web-search yarn) + +# global +export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" +export PATH=$HOME/local/bin:$PATH +export NPM_PACKAGES="${HOME}/.npm-packages" +export PATH="$NPM_PACKAGES/bin:$PATH" +export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" +export PATH="/opt/homebrew/bin:$PATH" # brew on Apple Silicon +export PATH="/usr/local/bin:$PATH" # brew on Intel +#export JAVA_HOME="$(/usr/libexec/java_home -v 1.$JAVA_VERSION)" # enable this if you are using java +#export PATH=/usr/share/maven/bin:$PATH # enable this if you are using maven +#export PATH=$HOME/mongodb/bin:$PATH # enable this if you are using mongodb +#export PATH=$PATH:~/.composer/vendor/bin # enable this if you are using composer + +# github +export GH_TOKEN="" # create token at https://github.com/settings/apps select "Personal access tokens" + +# ssh +export SSH_KEY_PATH=$HOME/.ssh/id_ed25519 + +# node and npm +export NODE_ENV="development" +export NPM_TOKEN="" # create token at https://www.npmjs.com/settings/tokens +export NPM_SCOPE="" # e.g. tcelestino + +# local +export USER_NAME="" # e.g. tcelestino +export USER_EMAIL="" # e.g. your.email@provider.com + +# preferred editor for local and remote sessions +if [[ -n $SSH_CONNECTION ]]; then + export EDITOR='vim' +else + export EDITOR='code' +fi + +# web search custom search engines +ZSH_WEB_SEARCH_ENGINES=( + reddit "https://www.reddit.com/search/?q=" + linkedin "https://www.linkedin.com/search/results/all/?keywords=" + mdn "https://developer.mozilla.org/search?q=" +) + +source $ZSH/oh-my-zsh.sh diff --git a/ssh/config b/ssh/config index 321e772..bf1c306 100644 --- a/ssh/config +++ b/ssh/config @@ -1,4 +1,4 @@ Host * UseKeychain yes AddKeysToAgent yes - IdentityFile ~/.ssh/id_rsa + IdentityFile ~/.ssh/id_ed25519 diff --git a/zsh/.zshrc b/zsh/.zshrc deleted file mode 100644 index aaa73cc..0000000 --- a/zsh/.zshrc +++ /dev/null @@ -1,41 +0,0 @@ -export ZSH=$HOME/.oh-my-zsh - -ZSH_THEME="dracula" - -plugins=(alias-finder brew copypath copyfile deno dotenv docker docker-compose extract history iterm2 git macos npm python vscode web-search yarn custom-functions) - - -# global -#export JAVA_HOME="$(/usr/libexec/java_home -v 1.$JAVA_VERSION)" # enable this if you are using java -export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" -export PATH=/usr/share/maven/bin:$PATH -export PATH=$HOME/local/bin:$PATH -export PATH=$HOME/mongodb/bin:$PATH -export PATH=$PATH:~/.composer/vendor/bin -export PATH="/opt/homebrew/bin:$PATH" # brew on Apple Silicon -export PATH="/usr/local/bin:$PATH" # brew on Intel -export NPM_PACKAGES="${HOME}/.npm-packages" -export PATH="$NPM_PACKAGES/bin:$PATH" -export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" -export GH_TOKEN="" # create token at https://github.com/settings/apps select "Personal access tokens" -export NPM_TOKEN="" -export NODE_ENV="development" -export SSH_KEY_PATH="~/.ssh/id_ed" # set your ssh key path -export USER_NAME="" -export USER_EMAIL="" -export NPM_SCOPE=${USER:-your_username} # e.g. tcelestino - -# preferred editor for local and remote sessions -if [[ -n $SSH_CONNECTION ]]; then - export EDITOR='vim' -else - export EDITOR='code' -fi - -# web search custom search engines -ZSH_WEB_SEARCH_ENGINES=( - reddit "https://www.reddit.com/search/?q=" - linkedin "https://www.linkedin.com/search/results/all/?keywords=" -) - -source $ZSH/oh-my-zsh.sh diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh index de74613..cd841a0 100755 --- a/zsh/aliases.zsh +++ b/zsh/aliases.zsh @@ -1,8 +1,8 @@ # oh-my-zsh alias zshconfig="$EDITOR ~/.zshrc" alias ohmyzsh="$EDITOR ~/.oh-my-zsh" -alias reload="omz reload" # reload oh-my-zsh -alias zsh-alias="$EDITOR ~/.oh-my-zsh/custom/aliases.zsh" +alias reload="omz reload" +alias custom-alias="$EDITOR ~/.oh-my-zsh/custom/aliases.zsh" # local development alias server="python -m SimpleHTTPServer" @@ -10,63 +10,61 @@ alias serveo="ssh -R 80:localhost:3000 serveo.net" alias redis-start="/opt/homebrew/opt/redis/bin/redis-server /opt/homebrew/etc/redis.conf" #start redis # https://paulbrowne.xyz/https-localhost -alias https-server='http-server --ssl --cert ~/.ssl/localhost.crt --key ~/.ssl/localhost.key -a localhost -o' +alias https-server="http-server --ssl --cert ~/.ssl/localhost.crt --key ~/.ssl/localhost.key -a localhost -o" # npm -alias npm-i='npm install' -alias npm-is='npm install --save' -alias npm-id='npm install --save-dev' -alias npm-ig='npm install --global' -alias npm-start='npm start' -alias npm-test='npm test' -alias npm-it='npm install && npm test' -alias npm-lk='npm link' -alias npm-run='npm run' +alias npm-i="npm install" +alias npm-is="npm install --save" +alias npm-id="npm install --save-dev" +alias npm-ig="npm install --global" +alias npm-start="npm start" +alias npm-test="npm test" +alias npm-it="npm install && npm test" +alias npm-lk="npm link" +alias npm-run="npm run" +alias npm-ri="rm -rf node_modules && npm i" alias npm-reset='rm -rf node_modules && rm -f package-lock.json && npm install && npx node-notifier-cli -t "Done" -m "npm modules reinstalled" -s Glass -i https://cdn.rawgit.com/npm/logos/31945b5c/npm%20square/n-64.png' -alias npm-ri='rm -rf node_modules && npm i' +alias npm-outdated="ncu -i --format group" #update package list using npm-check-update -# git +# git-cz alias commit="git-cz --disable-emoji" alias commitall="git add . && git-cz --disable-emoji" -# mac -alias shutdown="sudo shutdown -h now" -alias hosts="sudo $EDITOR /etc/hosts" -alias dns_clear="dscacheutil -flushcache" - # directory -alias downloads='cd ~/Downloads/' -alias projects='cd ~/Projects/' -alias work='cd ~/work' +alias downloads="cd ~/Downloads" +alias work=workFolder # mv, rm, cp -alias mv='mv -v' -alias rm='rm -i -v' -alias cp='cp -v' +alias mv="mv -v" +alias rm="rm -i -v" +alias cp="cp -v" alias rd="rmdir" alias del="rm -i" -alias cl="clear" -alias -- -="cd -" - # docker -alias dockercleand='docker rmi $(docker images -q)' # delete all images -alias dockercleanu='docker rmi $(docker images -q -f dangling=true)' # delete all untagged images -alias dockercleans='docker rm $(docker ps -a -q)' # delete all stopped images -alias dockerstop='docker stop $(docker ps -aq)' # stop all container -alias dcu='docker-compose up' #start with docker-composer -alias dcd='docker-compose down' #stop with docker-composer -alias dcr='docker-compose restart' #restart with docker-composer -alias dcb='docker-compose build' #build with docker-composer -alias dcl='docker-compose logs' #logs with docker-composer -alias dcp='docker-compose -f docker-compose.dependencies.yaml up -d' #start dependencies with docker-composer -alias docker_hostclean='export DOCKER_HOST=' # clean DOCKER_HOST +alias docker-rmi="docker rmi $(docker images -q)" # delete all images +alias docker-rmiu="docker rmi $(docker images -q -f dangling=true)" # delete all untagged images +alias docker-rmus="docker rm $(docker ps -a -q)" # delete all stopped images +alias docker-stop="docker stop $(docker ps -aq)" # stop all container +alias docker-ch="export DOCKER_HOST=" + +# docker-compose +alias dcup="docker-compose up" #start with docker-compose +alias dcd="docker-compose down" #stop containers +alias dcdv="docker-compose down -v" #stop with docker-compose and remove volumes +alias dcr="docker-compose restart" #restart containers with docker-compose +alias dcb="docker-compose build" #build with docker-compose +alias dclg="docker-compose logs" #logs with docker-compose +alias dcdpup="docker-compose -f docker-compose.dependencies.yaml up -d" #start dependencies with docker-compose +alias dcdpd="docker-compose -f docker-compose.dependencies.yaml down" #stop dependencies with docker-compose +alias dcdpdv="docker-compose -f docker-compose.dependencies.yaml down -v" #stop dependencies with docker-compose and remove volumes -alias fs="stat -f \"%z bytes\"" -alias chmox='chmod -x' +# utils +alias fs=filesize +alias chmox="chmod -x" alias where=which alias killnode="killall -9 node" - -alias checkport=checkPort # use my zsh custom plugin -alias killport=killPort # use my zsh custom plugin alias what_shell=ps -p $$ -o pid,comm= # show current shell +alias checkport=checkPort +alias killport=killPort + diff --git a/zsh/custom-functions/custom-functions.plugin.zsh b/zsh/custom-functions/custom-functions.plugin.zsh index 6e719f2..7fd2dcc 100755 --- a/zsh/custom-functions/custom-functions.plugin.zsh +++ b/zsh/custom-functions/custom-functions.plugin.zsh @@ -67,3 +67,29 @@ function logprocess() { journalctl -f -u "$1" 2>/dev/null || tail -f /var/log/syslog | grep "$1" fi } + +# open work folder +function workFolder() { + if [ -d ~/Projects ]; then + cd ~/Projects + elif [ -d ~/projects ]; then + cd ~/projects + elif [ -d ~/work ]; then + cd ~/work + elif [ -d ~/Work ]; then + cd ~/Work + else + echo "Folder ~/Projects, ~/projects, ~/work or ~/Work does not exist" + fi +} + +# show the size of a file or directory on macos and linux +function filesize() { + if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS + stat -f "%z bytes" "$@" + else + # Linux + stat -c "%s bytes" "$@" + fi +}