├── src ├── vim │ ├── vim │ │ ├── backups │ │ │ └── .gitkeep │ │ ├── swaps │ │ │ └── .gitkeep │ │ ├── undos │ │ │ └── .gitkeep │ │ └── snippets │ │ │ └── emmet.json │ └── vimrc ├── bin │ ├── $ │ ├── gzthermal │ │ ├── macos │ │ ├── linux-32 │ │ └── linux-64 │ ├── pngthermal │ │ ├── macos │ │ ├── linux-32 │ │ └── linux-64 │ └── get-compression-heatmap ├── shell │ ├── ubuntu │ │ ├── bash_init │ │ ├── bash_autocompletion │ │ ├── bash_colors │ │ └── bash_aliases │ ├── bashrc │ ├── bash_logout │ ├── bash_init │ ├── bash_autocompletion │ ├── macos │ │ ├── bash_init │ │ ├── bash_autocompletion │ │ ├── bash_colors │ │ └── bash_aliases │ ├── curlrc │ ├── bash_aliases │ ├── inputrc │ ├── bash_profile │ ├── bash_options │ ├── bash_exports │ ├── bash_prompt │ └── bash_functions ├── os │ ├── preferences │ │ ├── macos │ │ │ ├── close_system_preferences_panes.applescript │ │ │ ├── security_and_privacy.sh │ │ │ ├── firefox.sh │ │ │ ├── photos.sh │ │ │ ├── language_and_region.sh │ │ │ ├── main.sh │ │ │ ├── maps.sh │ │ │ ├── textedit.sh │ │ │ ├── chrome.sh │ │ │ ├── app_store.sh │ │ │ ├── terminal.sh │ │ │ ├── init.sh │ │ │ ├── trackpad.sh │ │ │ ├── keyboard.sh │ │ │ ├── set_terminal_theme.applescript │ │ │ ├── safari.sh │ │ │ ├── dock.sh │ │ │ ├── finder.sh │ │ │ ├── ui_and_ux.sh │ │ │ └── Solarized Dark.terminal │ │ ├── ubuntu │ │ │ ├── main.sh │ │ │ ├── privacy.sh │ │ │ ├── terminal.sh │ │ │ ├── ui_and_ux.sh │ │ │ └── set_terminal_theme.sh │ │ └── main.sh │ ├── installs │ │ ├── macos │ │ │ ├── vim.sh │ │ │ ├── git.sh │ │ │ ├── gpg.sh │ │ │ ├── tmux.sh │ │ │ ├── compression_tools.sh │ │ │ ├── video_tools.sh │ │ │ ├── image_tools.sh │ │ │ ├── misc.sh │ │ │ ├── misc_tools.sh │ │ │ ├── browsers.sh │ │ │ ├── web_font_tools.sh │ │ │ ├── main.sh │ │ │ ├── vscode.sh │ │ │ ├── bash.sh │ │ │ ├── utils.sh │ │ │ ├── xcode.sh │ │ │ └── homebrew.sh │ │ ├── ubuntu │ │ │ ├── vim.sh │ │ │ ├── cleanup.sh │ │ │ ├── git.sh │ │ │ ├── tmux.sh │ │ │ ├── misc.sh │ │ │ ├── image_tools.sh │ │ │ ├── compression_tools.sh │ │ │ ├── main.sh │ │ │ ├── build-essentials.sh │ │ │ ├── misc_tools.sh │ │ │ └── utils.sh │ │ ├── main.sh │ │ ├── npm.sh │ │ ├── vim.sh │ │ └── volta.sh │ ├── restart.sh │ ├── update_content.sh │ ├── initialize_git_repository.sh │ ├── create_local_config_files.sh │ ├── create_symbolic_links.sh │ ├── set_github_ssh_key.sh │ ├── setup.sh │ └── utils.sh ├── git │ ├── gitattributes │ ├── gitignore │ └── gitconfig └── tmux │ └── tmux.conf ├── .markdownlint.json ├── LICENSE.txt └── README.md /src/vim/vim/backups/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/vim/vim/swaps/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/vim/vim/undos/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/bin/$: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | $@ 4 | -------------------------------------------------------------------------------- /src/shell/ubuntu/bash_init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | -------------------------------------------------------------------------------- /src/shell/bashrc: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | [ -n "$PS1" ] \ 4 | && . "$HOME/.bash_profile" 5 | -------------------------------------------------------------------------------- /src/bin/gzthermal/macos: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alrra/dotfiles/HEAD/src/bin/gzthermal/macos -------------------------------------------------------------------------------- /src/bin/pngthermal/macos: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alrra/dotfiles/HEAD/src/bin/pngthermal/macos -------------------------------------------------------------------------------- /src/bin/gzthermal/linux-32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alrra/dotfiles/HEAD/src/bin/gzthermal/linux-32 -------------------------------------------------------------------------------- /src/bin/gzthermal/linux-64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alrra/dotfiles/HEAD/src/bin/gzthermal/linux-64 -------------------------------------------------------------------------------- /src/bin/pngthermal/linux-32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alrra/dotfiles/HEAD/src/bin/pngthermal/linux-32 -------------------------------------------------------------------------------- /src/bin/pngthermal/linux-64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alrra/dotfiles/HEAD/src/bin/pngthermal/linux-64 -------------------------------------------------------------------------------- /src/shell/bash_logout: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Clear console on exit. 4 | 5 | [ "$SHLVL" == 1 ] \ 6 | && clear &> /dev/null 7 | -------------------------------------------------------------------------------- /src/os/preferences/macos/close_system_preferences_panes.applescript: -------------------------------------------------------------------------------- 1 | #!/usr/bin/osascript 2 | 3 | tell application "System Preferences" to quit 4 | -------------------------------------------------------------------------------- /src/shell/ubuntu/bash_autocompletion: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -f /etc/bash_completion ] && ! shopt -oq posix; then 4 | . /etc/bash_completion 5 | fi 6 | -------------------------------------------------------------------------------- /src/git/gitattributes: -------------------------------------------------------------------------------- 1 | # Automatically normalize line endings for all text-based files. 2 | # https://git-scm.com/docs/gitattributes#_end_of_line_conversion 3 | # 4 | # * text=auto 5 | -------------------------------------------------------------------------------- /src/shell/bash_init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4 | 5 | # Load OS specific configs. 6 | 7 | . "$OS/bash_init" 8 | -------------------------------------------------------------------------------- /src/shell/bash_autocompletion: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4 | 5 | # Load OS specific configs. 6 | 7 | . "$OS/bash_autocompletion" 8 | -------------------------------------------------------------------------------- /src/os/installs/macos/vim.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "./utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | brew_install "Vim" "vim" 9 | -------------------------------------------------------------------------------- /src/os/installs/ubuntu/vim.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "./utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | install_package "Vim" "vim-gtk3" 9 | -------------------------------------------------------------------------------- /src/os/preferences/ubuntu/main.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" 4 | 5 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6 | 7 | ./privacy.sh 8 | ./terminal.sh 9 | ./ui_and_ux.sh 10 | -------------------------------------------------------------------------------- /src/os/installs/ubuntu/cleanup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "./utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n Cleanup\n\n" 9 | autoremove 10 | -------------------------------------------------------------------------------- /src/os/installs/main.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n • Installs\n\n" 9 | 10 | "./$(get_os)/main.sh" 11 | -------------------------------------------------------------------------------- /.markdownlint.json: -------------------------------------------------------------------------------- 1 | { 2 | "header-style": { 3 | "style": "setext_with_atx" 4 | }, 5 | "line-length": { 6 | "code_blocks": false, 7 | "tables": false 8 | }, 9 | "strong-style": { 10 | "style": "underscore" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/os/preferences/main.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n • Preferences\n" 9 | 10 | "./$(get_os)/main.sh" 11 | -------------------------------------------------------------------------------- /src/os/installs/macos/git.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n Git\n\n" 10 | 11 | brew_install "Git" "git" 12 | -------------------------------------------------------------------------------- /src/os/installs/ubuntu/git.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n Git\n\n" 10 | 11 | install_package "Git" "git" 12 | -------------------------------------------------------------------------------- /src/os/installs/ubuntu/tmux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n tmux\n\n" 10 | 11 | install_package "tmux" "tmux" 12 | -------------------------------------------------------------------------------- /src/os/installs/ubuntu/misc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n Miscellaneous\n\n" 10 | 11 | install_package "VLC" "vlc" 12 | -------------------------------------------------------------------------------- /src/os/installs/ubuntu/image_tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n Image Tools\n\n" 10 | 11 | install_package "ImageMagick" "imagemagick" 12 | -------------------------------------------------------------------------------- /src/os/installs/macos/gpg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n GPG\n\n" 10 | 11 | brew_install "GPG" "gpg" 12 | brew_install "Pinentry" "pinentry-mac" 13 | -------------------------------------------------------------------------------- /src/os/installs/macos/tmux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n tmux\n\n" 10 | 11 | brew_install "tmux" "tmux" 12 | brew_install "Pasteboard" "reattach-to-user-namespace" 13 | -------------------------------------------------------------------------------- /src/os/installs/macos/compression_tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n Compression Tools\n\n" 10 | 11 | brew_install "Brotli" "brotli" 12 | brew_install "Zopfli" "zopfli" 13 | -------------------------------------------------------------------------------- /src/os/installs/macos/video_tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n Video Tools\n\n" 10 | 11 | brew_install "AtomicParsley" "atomicparsley" 12 | brew_install "FFmpeg" "ffmpeg" 13 | -------------------------------------------------------------------------------- /src/os/installs/ubuntu/compression_tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n Compression Tools\n\n" 10 | 11 | install_package "Brotli" "brotli" 12 | install_package "Zopfli" "zopfli" 13 | -------------------------------------------------------------------------------- /src/os/preferences/macos/security_and_privacy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n Security & Privacy\n\n" 9 | 10 | execute "defaults write com.apple.AdLib allowApplePersonalizedAdvertising -int 0" \ 11 | "Disable personalized ads" 12 | -------------------------------------------------------------------------------- /src/vim/vim/snippets/emmet.json: -------------------------------------------------------------------------------- 1 | { 2 | "html": { 3 | "snippets": { 4 | "html5": "\n\n\n\t\n\t\n\t\n\n\n\n\t${child}\n\n" 5 | }, 6 | "variables": { 7 | "lang": "en" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/os/installs/macos/image_tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n Image Tools\n\n" 10 | 11 | brew_install "ImageMagick" "imagemagick" 12 | brew_install "ImageOptim" "imageoptim" "--cask" 13 | brew_install "pngquant" "pngquant" 14 | -------------------------------------------------------------------------------- /src/os/preferences/macos/firefox.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n Firefox\n\n" 9 | 10 | execute "defaults write org.mozilla.firefox AppleEnableSwipeNavigateWithScrolls -bool false" \ 11 | "Disable backswipe" 12 | 13 | killall "firefox" &> /dev/null 14 | -------------------------------------------------------------------------------- /src/os/installs/macos/misc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n Miscellaneous\n\n" 10 | 11 | brew_install "Rectangle" "rectangle" "--cask" 12 | brew_install "Unarchiver" "the-unarchiver" "--cask" 13 | brew_install "VLC" "vlc" "--cask" 14 | -------------------------------------------------------------------------------- /src/os/installs/macos/misc_tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n Miscellaneous Tools\n\n" 10 | 11 | brew_install "eyeD3" "eye-d3" 12 | brew_install "pdfcpu" "pdfcpu" 13 | brew_install "ShellCheck" "shellcheck" 14 | brew_install "Yarn" "yarn" 15 | -------------------------------------------------------------------------------- /src/os/preferences/ubuntu/privacy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n Privacy\n\n" 9 | 10 | execute "gsettings set com.canonical.Unity.Lenses remote-content-search 'none'" \ 11 | "Turn off 'Remote Search' so that search terms in Dash do not get sent over the internet" 12 | -------------------------------------------------------------------------------- /src/os/restart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | main() { 9 | 10 | print_in_purple "\n • Restart\n\n" 11 | 12 | ask_for_confirmation "Do you want to restart?" 13 | printf "\n" 14 | 15 | if answer_is_yes; then 16 | sudo shutdown -r now &> /dev/null 17 | fi 18 | 19 | } 20 | 21 | main 22 | -------------------------------------------------------------------------------- /src/os/preferences/ubuntu/terminal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n Terminal\n\n" 9 | 10 | execute "gsettings set org.gnome.desktop.interface monospace-font-name 'Monospace 12'" \ 11 | "Change font size" 12 | 13 | execute "./set_terminal_theme.sh" \ 14 | "Set custom terminal theme" 15 | -------------------------------------------------------------------------------- /src/os/preferences/macos/photos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n Photos\n\n" 9 | 10 | execute "defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true" \ 11 | "Prevent Photos from opening automatically when devices are plugged in" 12 | 13 | killall "Photos" &> /dev/null 14 | -------------------------------------------------------------------------------- /src/os/preferences/macos/language_and_region.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n Language & Region\n\n" 9 | 10 | execute "defaults write -g AppleLanguages -array 'en'" \ 11 | "Set language" 12 | 13 | execute "defaults write -g AppleMeasurementUnits -string 'Centimeters'" \ 14 | "Set measurement units" 15 | -------------------------------------------------------------------------------- /src/os/installs/macos/browsers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n Browsers\n" 10 | 11 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 12 | 13 | printf "\n" 14 | 15 | brew_install "Chrome" "google-chrome" "--cask" 16 | brew_install "Firefox" "firefox" "--cask" 17 | -------------------------------------------------------------------------------- /src/os/installs/ubuntu/main.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | update 10 | upgrade 11 | 12 | ./build-essentials.sh 13 | 14 | ./git.sh 15 | ./compression_tools.sh 16 | ./image_tools.sh 17 | ./misc.sh 18 | ./misc_tools.sh 19 | ./../volta.sh 20 | ./../npm.sh 21 | ./tmux.sh 22 | ./../vim.sh 23 | 24 | ./cleanup.sh 25 | -------------------------------------------------------------------------------- /src/os/preferences/macos/main.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" 4 | 5 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6 | 7 | ./init.sh 8 | 9 | ./app_store.sh 10 | ./chrome.sh 11 | ./dock.sh 12 | ./finder.sh 13 | ./firefox.sh 14 | ./keyboard.sh 15 | ./language_and_region.sh 16 | ./maps.sh 17 | ./photos.sh 18 | ./safari.sh 19 | ./security_and_privacy.sh 20 | ./terminal.sh 21 | ./textedit.sh 22 | ./trackpad.sh 23 | ./ui_and_ux.sh 24 | -------------------------------------------------------------------------------- /src/os/installs/macos/web_font_tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n Web Font Tools\n\n" 10 | 11 | brew_install "TTF/OTF → WOFF (Zopfli)" "sfnt2woff-zopfli" "" "bramstein/webfonttools" 12 | brew_install "TTF/OTF → WOFF" "sfnt2woff" "" "bramstein/webfonttools" 13 | brew_install "WOFF2" "woff2" "" "bramstein/webfonttools" 14 | -------------------------------------------------------------------------------- /src/os/preferences/ubuntu/ui_and_ux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n UI & UX\n\n" 9 | 10 | execute "gsettings set org.gnome.desktop.background picture-options 'stretched'" \ 11 | "Set desktop background image options" 12 | 13 | execute "gsettings set org.gnome.libgnomekbd.keyboard layouts \"[ 'us', 'ro' ]\"" \ 14 | "Set keyboard languages" 15 | -------------------------------------------------------------------------------- /src/os/installs/macos/main.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | ./xcode.sh 10 | ./homebrew.sh 11 | 12 | reload_local_shell_configs 13 | ./bash.sh 14 | 15 | ./git.sh 16 | ./../volta.sh 17 | ./browsers.sh 18 | ./compression_tools.sh 19 | ./gpg.sh 20 | ./image_tools.sh 21 | ./misc.sh 22 | ./misc_tools.sh 23 | ./../npm.sh 24 | ./tmux.sh 25 | ./video_tools.sh 26 | ./../vim.sh 27 | ./vscode.sh 28 | ./web_font_tools.sh 29 | -------------------------------------------------------------------------------- /src/os/preferences/macos/maps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n Maps\n\n" 9 | 10 | execute "defaults write com.apple.Maps LastClosedWindowViewOptions '{ 11 | localizeLabels = 1; // show labels in English 12 | mapType = 11; // show hybrid map 13 | trafficEnabled = 0; // do not show traffic 14 | }'" \ 15 | "Set view options" 16 | 17 | killall "Maps" &> /dev/null 18 | -------------------------------------------------------------------------------- /src/os/installs/npm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | install_npm_package() { 9 | 10 | execute \ 11 | ". $HOME/.bash.local \ 12 | && npm install --global --silent $2" \ 13 | "$1" 14 | 15 | } 16 | 17 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 18 | 19 | main() { 20 | 21 | print_in_purple "\n npm\n\n" 22 | 23 | install_npm_package "Update npm" "npm" 24 | 25 | } 26 | 27 | main 28 | -------------------------------------------------------------------------------- /src/os/preferences/macos/textedit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n TextEdit\n\n" 9 | 10 | execute "defaults write com.apple.TextEdit PlainTextEncoding -int 4 && \ 11 | defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4" \ 12 | "Open and save files as UTF-8 encoded" 13 | 14 | execute "defaults write com.apple.TextEdit RichText 0" \ 15 | "Use plain text mode for new documents" 16 | 17 | killall "TextEdit" &> /dev/null 18 | -------------------------------------------------------------------------------- /src/os/preferences/ubuntu/set_terminal_theme.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6 | 7 | declare tmpDir="$(mktemp --directory)" 8 | 9 | # Use external script to set the Solarized color set. 10 | git clone https://github.com/aruhier/gnome-terminal-colors-solarized.git "$tmpDir" 11 | cd "$tmpDir" 12 | 13 | # Ensured the right (reviewed) script is executed. 14 | git checkout -b main 9651c41df0f89e87feee0c798779abba0f9395e0 15 | 16 | # Run script and automatically respond to all prompts 17 | printf "1\nYES\n" | ./set_dark.sh 18 | 19 | # Clean up. 20 | rm -rf "$tmpDir" 21 | -------------------------------------------------------------------------------- /src/os/preferences/macos/chrome.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n Chrome\n\n" 9 | 10 | execute "defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false" \ 11 | "Disable backswipe" 12 | 13 | execute "defaults write com.google.Chrome PMPrintingExpandedStateForPrint2 -bool true" \ 14 | "Expand print dialog by default" 15 | 16 | execute "defaults write com.google.Chrome DisablePrintPreview -bool true" \ 17 | "Use system-native print preview dialog" 18 | 19 | killall "Google Chrome" &> /dev/null 20 | -------------------------------------------------------------------------------- /src/os/installs/ubuntu/build-essentials.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n Build Essentials\n\n" 10 | 11 | # Install tools for compiling/building software from source. 12 | install_package "Build Essential" "build-essential" 13 | 14 | # GnuPG archive keys of the Debian archive. 15 | install_package "GnuPG archive keys" "debian-archive-keyring" 16 | 17 | # Software which is not included by default 18 | # in Ubuntu due to legal or copyright reasons. 19 | #install_package "Ubuntu Restricted Extras" "ubuntu-restricted-extras" 20 | -------------------------------------------------------------------------------- /src/shell/macos/bash_init: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4 | 5 | # Set up Homebrew. 6 | 7 | set_homebrew() { 8 | HARDWARE="$(uname -m)" 9 | prefix="" 10 | 11 | if [ "$HARDWARE" == "arm64" ]; then 12 | prefix="/opt/homebrew" 13 | elif [ "$HARDWARE" == "x86_64" ]; then 14 | prefix="/usr/local" 15 | fi 16 | 17 | eval "$($prefix/bin/brew shellenv)" 18 | } 19 | 20 | set_homebrew 21 | unset -f set_homebrew 22 | 23 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 24 | 25 | # Configure Homebrew to not auto-update before running commands 26 | # such as: `brew install`, `brew upgrade`, and `brew tap`. 27 | # 28 | # https://docs.brew.sh/Manpage#environment 29 | 30 | export HOMEBREW_NO_AUTO_UPDATE=1 31 | -------------------------------------------------------------------------------- /src/shell/curlrc: -------------------------------------------------------------------------------- 1 | # cURL configuration options. 2 | # https://curl.haxx.se/docs/manpage.html 3 | 4 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 | 6 | # Limit the time (in seconds) the connection is allowed to take. 7 | 8 | connect-timeout = 60 9 | 10 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 11 | 12 | # Follow HTTP redirects. 13 | 14 | location 15 | 16 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 17 | 18 | # Display progress as a simple progress bar. 19 | 20 | progress-bar 21 | 22 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 23 | 24 | # Show error messages. 25 | 26 | show-error 27 | 28 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 29 | 30 | # Send a fake UA string for the HTTP servers that sniff it. 31 | 32 | user-agent = "Mozilla/5.0 Gecko" 33 | -------------------------------------------------------------------------------- /src/os/installs/ubuntu/misc_tools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | print_in_purple "\n Miscellaneous Tools\n\n" 10 | 11 | install_package "cURL" "curl" 12 | install_package "ShellCheck" "shellcheck" 13 | install_package "xclip" "xclip" 14 | 15 | if ! package_is_installed "yarn"; then 16 | 17 | add_key "https://dl.yarnpkg.com/debian/pubkey.gpg" \ 18 | || print_error "Yarn (add key)" 19 | 20 | add_to_source_list "https://dl.yarnpkg.com/debian/ stable main" "yarn.list" \ 21 | || print_error "Yarn (add to package resource list)" 22 | 23 | update &> /dev/null \ 24 | || print_error "Yarn (resync package index files)" 25 | 26 | fi 27 | 28 | install_package "Yarn" "yarn" "--no-install-recommends" 29 | -------------------------------------------------------------------------------- /src/os/installs/macos/vscode.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | install_plugin() { 10 | execute "code --install-extension $2" "$1 plugin" 11 | } 12 | 13 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 14 | 15 | print_in_purple "\n Visual Studio Code\n\n" 16 | 17 | # Install VSCode 18 | brew_install "Visual Studio Code" "visual-studio-code" "--cask" 19 | 20 | printf "\n" 21 | 22 | # Install the VSCode plugins 23 | install_plugin "EditorConfig" "EditorConfig.EditorConfig" 24 | install_plugin "File Icons" "vscode-icons-team.vscode-icons" 25 | install_plugin "MarkdownLint" "DavidAnson.vscode-markdownlint" 26 | install_plugin "Vim" "vscodevim.vim" 27 | 28 | # Close VSCode 29 | osascript -e 'quit app "Visual Studio Code"' 30 | -------------------------------------------------------------------------------- /src/os/preferences/macos/app_store.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n App Store\n\n" 9 | 10 | execute "defaults write com.apple.appstore ShowDebugMenu -bool true" \ 11 | "Enable debug menu" 12 | 13 | execute "defaults write com.apple.commerce AutoUpdate -bool true" \ 14 | "Turn on auto-update" 15 | 16 | execute "defaults write com.apple.SoftwareUpdate AutomaticCheckEnabled -bool true" \ 17 | "Enable automatic update check" 18 | 19 | execute "defaults write com.apple.SoftwareUpdate AutomaticDownload -int 1" \ 20 | "Download newly available updates in background" 21 | 22 | execute "defaults write com.apple.SoftwareUpdate CriticalUpdateInstall -int 1" \ 23 | "Install System data files and security updates" 24 | 25 | killall "App Store" &> /dev/null 26 | -------------------------------------------------------------------------------- /src/os/update_content.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | main() { 9 | 10 | ssh -T git@github.com &> /dev/null 11 | 12 | if [ $? -ne 1 ]; then 13 | ./set_github_ssh_key.sh \ 14 | || return 1 15 | fi 16 | 17 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 18 | 19 | print_in_purple "\n • Update content\n\n" 20 | 21 | ask_for_confirmation "Do you want to update the content from the 'dotfiles' directory?" 22 | 23 | if answer_is_yes; then 24 | 25 | git fetch --all 1> /dev/null \ 26 | && git reset --hard origin/main 1> /dev/null \ 27 | && git checkout main &> /dev/null \ 28 | && git clean -fd 1> /dev/null 29 | 30 | print_result $? "Update content" 31 | 32 | fi 33 | 34 | } 35 | 36 | main 37 | -------------------------------------------------------------------------------- /src/shell/macos/bash_autocompletion: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if command -v brew &> /dev/null; then 4 | 5 | declare BASH_COMPLETION_PATH="$(brew --prefix 2> /dev/null)/etc/profile.d/bash_completion.sh" 6 | 7 | if [ -r "$BASH_COMPLETION_PATH" ]; then 8 | 9 | # Ensure existing `bash-completion@1` continues to work. 10 | # https://github.com/Homebrew/homebrew-core/pull/36254 11 | 12 | export BASH_COMPLETION_COMPAT_DIR="$(brew --prefix)/etc/bash_completion.d" 13 | 14 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 15 | 16 | # Use the latest `bash-completion`. 17 | 18 | . "$BASH_COMPLETION_PATH" 19 | 20 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 21 | 22 | # Make Bash complete the `g` alias just like it does `git`. 23 | 24 | __git_complete g git 25 | 26 | fi 27 | 28 | elif [ -f /etc/bash_completion ]; then 29 | . /etc/bash_completion; 30 | fi 31 | -------------------------------------------------------------------------------- /src/os/installs/vim.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | install_plugins() { 9 | 10 | declare -r VIM_PACK_DIR="$HOME/.vim/pack" 11 | declare -r MINPAC_DIR="$VIM_PACK_DIR/minpac/opt/minpac" 12 | declare -r MINPAC_GIT_REPO_URL="https://github.com/k-takata/minpac.git" 13 | 14 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 15 | 16 | # Install plugins. 17 | 18 | execute \ 19 | "rm -rf $VIM_PACK_DIR \ 20 | && git clone --quiet $MINPAC_GIT_REPO_URL $MINPAC_DIR" \ 21 | "Install plugins" \ 22 | || return 1 23 | 24 | vim +PluginsSetup 25 | 26 | } 27 | 28 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 29 | 30 | main() { 31 | 32 | print_in_purple "\n Vim\n\n" 33 | 34 | "./$(get_os)/vim.sh" 35 | install_plugins 36 | 37 | } 38 | 39 | main 40 | -------------------------------------------------------------------------------- /src/os/installs/volta.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | add_configs() { 9 | # Check if the configs need to be added. 10 | if command -v volta &> /dev/null; then 11 | return 12 | fi 13 | 14 | update_local_shell_configs "export PATH=\"\$HOME/.volta/bin:\$PATH\" # Volta" 15 | } 16 | 17 | install() { 18 | execute \ 19 | "curl https://get.volta.sh | bash -s -- --skip-setup" \ 20 | "Install" 21 | } 22 | 23 | install_node() { 24 | 25 | # Install Node.js LTS. 26 | # Note: This will also set it as the default. 27 | 28 | execute "volta install node" \ 29 | "Install Node.js LTS" 30 | 31 | } 32 | 33 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 34 | 35 | main() { 36 | 37 | print_in_purple "\n Volta\n\n" 38 | 39 | install 40 | add_configs 41 | install_node 42 | 43 | } 44 | 45 | main 46 | -------------------------------------------------------------------------------- /src/os/preferences/macos/terminal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n Terminal\n\n" 9 | 10 | execute "defaults write com.apple.terminal FocusFollowsMouse -string true" \ 11 | "Make the focus automatically follow the mouse" 12 | 13 | execute "defaults write com.apple.terminal SecureKeyboardEntry -bool true" \ 14 | "Enable 'Secure Keyboard Entry'" 15 | 16 | execute "defaults write com.apple.Terminal ShowLineMarks -int 0" \ 17 | "Hide line marks" 18 | 19 | execute "defaults write com.apple.terminal StringEncodings -array 4" \ 20 | "Only use UTF-8" 21 | 22 | execute "./set_terminal_theme.applescript" \ 23 | "Set custom terminal theme" 24 | 25 | # Ensure the Touch ID is used when `sudo` is required. 26 | 27 | if ! grep -q "pam_tid.so" "/etc/pam.d/sudo"; then 28 | execute "sudo sh -c 'echo \"auth sufficient pam_tid.so\" >> /etc/pam.d/sudo'" \ 29 | "Use Touch ID to authenticate sudo" 30 | fi 31 | -------------------------------------------------------------------------------- /src/shell/macos/bash_colors: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4 | 5 | # Set LSCOLORS (FreeBSD / macOS). 6 | # 7 | # * `ls` displays colors if the `-G` option is passed or if 8 | # the `CLICOLOR` environment variable is set. 9 | # 10 | # * The actual colors are configured through the `LSCOLORS` 11 | # environment variable (built-in defaults are used if this 12 | # variable is not set). 13 | 14 | LSCOLORS="" 15 | 16 | LSCOLORS+="gx" # Directory 17 | LSCOLORS+="fx" # Symbolic link 18 | LSCOLORS+="cx" # Socket 19 | LSCOLORS+="dx" # Pipe 20 | LSCOLORS+="cx" # Executable 21 | LSCOLORS+="eg" # Block special 22 | LSCOLORS+="ed" # Character special 23 | LSCOLORS+="ab" # Executable with setuid bit set 24 | LSCOLORS+="ag" # Executable with setgid bit set 25 | LSCOLORS+="cc" # Directory writable to others, with sticky bit 26 | LSCOLORS+="bd" # Directory writable to others, without sticky bit 27 | 28 | export LSCOLORS 29 | 30 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 31 | 32 | # Enable color support. 33 | 34 | alias ls="ls -G" 35 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) Cătălin Mariș 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /src/os/preferences/macos/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | # Check if the terminal has "Full Disk Access", and if it does 9 | # not, ask the user to grant it. 10 | # 11 | # This is required in order to be able to set some preferences. 12 | # See also: https://lapcatsoftware.com/articles/containers.html. 13 | 14 | if ! ls "$HOME/Library/Containers/com.apple.Safari/Data" &> /dev/null; then 15 | printf "\n" 16 | 17 | # Open the "Full Disk Access" system preferences. 18 | open "x-apple.systempreferences:com.apple.preference.security?Privacy_AllFiles" 19 | 20 | # Ask the user to grant "Full Disk Access". 21 | ask "Please grant the terminal \"Full Disk Access\" and then press any key to continue. " 22 | fi 23 | 24 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 25 | 26 | # Close any open "System Preferences" panes in order to 27 | # avoid overriding the preferences that are being changed. 28 | 29 | ./close_system_preferences_panes.applescript 30 | -------------------------------------------------------------------------------- /src/os/initialize_git_repository.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | initialize_git_repository() { 9 | 10 | declare -r GIT_ORIGIN="$1" 11 | 12 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 13 | 14 | if [ -z "$GIT_ORIGIN" ]; then 15 | print_error "Please provide a URL for the Git origin" 16 | exit 1 17 | fi 18 | 19 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 20 | 21 | if ! is_git_repository; then 22 | 23 | # Run the following Git commands in the root of 24 | # the dotfiles directory, not in the `os/` directory. 25 | 26 | cd ../../ \ 27 | || print_error "Failed to 'cd ../../'" 28 | 29 | execute \ 30 | "git init && git remote add origin $GIT_ORIGIN" \ 31 | "Initialize the Git repository" 32 | 33 | fi 34 | 35 | } 36 | 37 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 38 | 39 | main() { 40 | print_in_purple "\n • Initialize Git repository\n\n" 41 | initialize_git_repository "$1" 42 | } 43 | 44 | main "$1" 45 | -------------------------------------------------------------------------------- /src/shell/bash_aliases: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | alias ..="cd .." 4 | alias ...="cd ../.." 5 | alias ....="cd ../../.." 6 | alias cd..="cd .." 7 | 8 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 9 | 10 | alias cp="cp -iv" 11 | # │└─ list copied files 12 | # └─ prompt before overwriting an existing file 13 | 14 | alias mkdir="mkdir -pv" 15 | # │└─ list created directories 16 | # └─ create intermediate directories 17 | 18 | alias mv="mv -iv" 19 | # │└─ list moved files 20 | # └─ prompt before overwriting an existing file 21 | 22 | alias rm="rm -rf --" 23 | 24 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 25 | 26 | alias :q="exit" 27 | alias c="clear" 28 | alias ch="history -c && > ~/.bash_history" 29 | alias d="cd ~/Desktop" 30 | alias e="vim --" 31 | alias g="git" 32 | alias ip="dig +short myip.opendns.com @resolver1.opendns.com" 33 | alias ll="ls -lA" 34 | alias n="npm" 35 | alias p="cd ~/projects" 36 | alias path='printf "%b\n" "${PATH//:/\\n}"' 37 | alias q="exit" 38 | alias t="tmux" 39 | alias y="yarn" 40 | 41 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 42 | 43 | # Load OS specific configs. 44 | 45 | . "$OS/bash_aliases" 46 | -------------------------------------------------------------------------------- /src/os/preferences/macos/trackpad.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n Trackpad\n\n" 9 | 10 | execute "defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true && \ 11 | defaults write com.apple.AppleMultitouchTrackpad Clicking -int 1 && \ 12 | defaults write -g com.apple.mouse.tapBehavior -int 1 && \ 13 | defaults -currentHost write -g com.apple.mouse.tapBehavior -int 1" \ 14 | "Enable 'Tap to click'" 15 | 16 | execute "defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadRightClick -bool true && \ 17 | defaults write com.apple.AppleMultitouchTrackpad TrackpadRightClick -int 1 && \ 18 | defaults -currentHost write -g com.apple.trackpad.enableSecondaryClick -bool true && \ 19 | defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadCornerSecondaryClick -int 0 && \ 20 | defaults write com.apple.AppleMultitouchTrackpad TrackpadCornerSecondaryClick -int 0 && \ 21 | defaults -currentHost write -g com.apple.trackpad.trackpadCornerClickBehavior -int 0" \ 22 | "Map 'click or tap with two fingers' to the secondary click" 23 | -------------------------------------------------------------------------------- /src/shell/ubuntu/bash_colors: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4 | 5 | # Set LS_COLORS (GNU). 6 | # 7 | # - `ls` displays colors if the `--color` option is passed. 8 | # 9 | # - The actual colors are configured through the `LS_COLORS` 10 | # environment variable (built-in defaults are used if this 11 | # variable is not set). 12 | 13 | LS_COLORS="" 14 | 15 | LS_COLORS+="no=0;39:" # Global default 16 | LS_COLORS+="di=0;36:" # Directory 17 | LS_COLORS+="ex=0;32:" # Executable file 18 | LS_COLORS+="fi=0;39:" # File 19 | LS_COLORS+="ec=:" # Non-filename text 20 | LS_COLORS+="mi=1;31:" # Non-existent file pointed to by a symlink 21 | LS_COLORS+="ln=target:" # Symbolic link 22 | LS_COLORS+="or=31;01" # Symbolic link pointing to a non-existent file 23 | 24 | export LS_COLORS 25 | 26 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 27 | 28 | # Enable color support. 29 | 30 | if [ -x /usr/bin/dircolors ]; then 31 | 32 | if test -r ~/.dircolors; then 33 | eval "$(dircolors -b ~/.dircolors)" 34 | fi 35 | 36 | alias dir="dir --color=auto" 37 | alias egrep="egrep --color=auto" 38 | alias fgrep="fgrep --color=auto" 39 | alias grep="grep --color=auto" 40 | alias ls="ls --color=auto" 41 | alias vdir="vdir --color=auto" 42 | 43 | fi 44 | -------------------------------------------------------------------------------- /src/shell/ubuntu/bash_aliases: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4 | 5 | # Lock screen. 6 | 7 | alias afk="gnome-screensaver-command --lock" 8 | 9 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10 | 11 | # Shorter commands for the `Advanced Packaging Tool` 12 | 13 | alias apti="sudo apt-get install" 14 | alias aptr="sudo apt-get remove" 15 | alias apts="sudo apt-cache search" 16 | alias aptu="sudo apt-get update \ 17 | && sudo apt-get upgrade" 18 | 19 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 20 | 21 | # Empty trash. 22 | 23 | alias empty-trash="rm -rf ~/.local/share/Trash/files/*" 24 | 25 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 26 | 27 | # Hide/Show desktop icons. 28 | 29 | alias hide-desktop-icons="gsettings set org.gnome.desktop.background show-desktop-icons false" 30 | alias show-desktop-icons="gsettings set org.gnome.desktop.background show-desktop-icons true" 31 | 32 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 33 | 34 | # Open from the terminal. 35 | 36 | alias o="xdg-open" 37 | 38 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 39 | 40 | # Update applications and CLTs. 41 | 42 | alias u="sudo apt-get update \ 43 | && sudo apt-get upgrade" 44 | -------------------------------------------------------------------------------- /src/os/preferences/macos/keyboard.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n Keyboard\n\n" 9 | 10 | execute "defaults write -g AppleKeyboardUIMode -int 3" \ 11 | "Enable full keyboard access for all controls" 12 | 13 | execute "defaults write -g ApplePressAndHoldEnabled -bool false" \ 14 | "Disable press-and-hold in favor of key repeat" 15 | 16 | execute "defaults write -g 'InitialKeyRepeat_Level_Saved' -int 10" \ 17 | "Set delay until repeat" 18 | 19 | execute "defaults write -g KeyRepeat -int 1" \ 20 | "Set the key repeat rate to fast" 21 | 22 | execute "defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false" \ 23 | "Disable automatic capitalization" 24 | 25 | execute "defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false" \ 26 | "Disable automatic correction" 27 | 28 | execute "defaults write -g NSAutomaticPeriodSubstitutionEnabled -bool false" \ 29 | "Disable automatic period substitution" 30 | 31 | execute "defaults write -g NSAutomaticDashSubstitutionEnabled -bool false" \ 32 | "Disable smart dashes" 33 | 34 | execute "defaults write -g NSAutomaticQuoteSubstitutionEnabled -bool false" \ 35 | "Disable smart quotes" 36 | 37 | execute "defaults write com.apple.HIToolbox AppleFnUsageType -int 2" \ 38 | "Remap the emoji picker to the Fn key" 39 | -------------------------------------------------------------------------------- /src/shell/inputrc: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Readline library configuration options. 4 | # http://ss64.com/bash/syntax-inputrc.html 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | # If there are multiple matches for completion, 9 | # make TAB cycle through them. 10 | 11 | TAB: menu-complete 12 | 13 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 14 | 15 | # Searching files via partial match. 16 | 17 | # ↑ 18 | "\e[A":history-search-backward 19 | # ↓ 20 | "\e[B":history-search-forward 21 | 22 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 23 | 24 | # Disable beeping and window flashing. 25 | 26 | set bell-style none 27 | 28 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 29 | 30 | # Use the `vi` set of key bindings (default is `emacs`). 31 | 32 | set editing-mode vi 33 | 34 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 35 | 36 | # Use case-insensitive TAB autocompletion. 37 | 38 | set completion-ignore-case on 39 | 40 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 41 | 42 | # Perform partial completion on the first Tab press, and 43 | # only start cycling full results on the second Tab press. 44 | 45 | set menu-complete-display-prefix on 46 | 47 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 48 | 49 | # Display a list of the matching files 50 | 51 | set show-all-if-ambiguous on 52 | -------------------------------------------------------------------------------- /src/shell/bash_profile: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4 | 5 | source_bash_files() { 6 | declare -r CURRENT_DIRECTORY="$(pwd)" 7 | 8 | declare -r -a FILES_TO_SOURCE=( 9 | "bash_init" 10 | 11 | "bash_aliases" 12 | "bash_autocompletion" 13 | "bash_exports" 14 | "bash_functions" 15 | "bash_options" 16 | "bash_prompt" 17 | 18 | "bash.local" # For local settings that should 19 | # not be under version control. 20 | ) 21 | 22 | local file="" 23 | local i="" 24 | 25 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 26 | 27 | cd "$(dirname "$(readlink "${BASH_SOURCE[0]}")")" \ 28 | && . "../os/utils.sh" 29 | 30 | # shellcheck disable=SC2034 31 | declare -r OS="$(get_os)" 32 | 33 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 34 | 35 | for i in ${!FILES_TO_SOURCE[*]}; do 36 | 37 | file="$HOME/.${FILES_TO_SOURCE[$i]}" 38 | 39 | [ -r "$file" ] \ 40 | && . "$file" 41 | 42 | done 43 | 44 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 45 | 46 | cd "$CURRENT_DIRECTORY" 47 | 48 | } 49 | 50 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 51 | 52 | source_bash_files 53 | unset -f source_bash_files 54 | 55 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 56 | 57 | # Clear system messages (system copyright notice, the date 58 | # and time of the last login, the message of the day, etc.). 59 | 60 | clear 61 | -------------------------------------------------------------------------------- /src/git/gitignore: -------------------------------------------------------------------------------- 1 | # Useful `.gitignore` templates: 2 | # https://github.com/github/gitignore 3 | 4 | # ---------------------------------------------------------------------- 5 | # | Linux | 6 | # ---------------------------------------------------------------------- 7 | 8 | *~ 9 | 10 | 11 | # ---------------------------------------------------------------------- 12 | # | Miscellaneous | 13 | # ---------------------------------------------------------------------- 14 | 15 | # Node.js, npm, and yarn. 16 | 17 | node_modules 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | 22 | 23 | # ---------------------------------------------------------------------- 24 | # | macOS | 25 | # ---------------------------------------------------------------------- 26 | 27 | ._* 28 | .AppleDouble 29 | .DS_Store 30 | .localized 31 | .LSOverride 32 | .Spotlight-V100 33 | .Trashes 34 | 35 | 36 | # ---------------------------------------------------------------------- 37 | # | Vim | 38 | # ---------------------------------------------------------------------- 39 | 40 | %* 41 | *.sw[a-z] 42 | *.un~ 43 | .netrwhist 44 | Session.vim 45 | 46 | 47 | # ---------------------------------------------------------------------- 48 | # | Windows | 49 | # ---------------------------------------------------------------------- 50 | 51 | Desktop.ini 52 | ehthumbs.db 53 | Thumbs.db 54 | -------------------------------------------------------------------------------- /src/os/preferences/macos/set_terminal_theme.applescript: -------------------------------------------------------------------------------- 1 | #!/usr/bin/osascript 2 | 3 | tell application "Terminal" 4 | 5 | local allOpenedWindows 6 | local initialOpenedWindows 7 | local windowID 8 | 9 | set themeName to "Solarized Dark" 10 | 11 | (* Store the IDs of all the open terminal windows. *) 12 | set initialOpenedWindows to id of every window 13 | 14 | (* Open the custom theme so that it gets added to the list 15 | of available terminal themes (note: this will open two 16 | additional terminal windows). *) 17 | do shell script "open '" & themeName & ".terminal'" 18 | 19 | (* Wait a little bit to ensure that the custom theme is added. *) 20 | delay 1 21 | 22 | (* Set the custom theme as the default terminal theme. *) 23 | set default settings to settings set themeName 24 | 25 | (* Get the IDs of all the currently opened terminal windows. *) 26 | set allOpenedWindows to id of every window 27 | 28 | repeat with windowID in allOpenedWindows 29 | 30 | (* Close the additional windows that were opened in order 31 | to add the custom theme to the list of terminal themes. *) 32 | if initialOpenedWindows does not contain windowID then 33 | close (every window whose id is windowID) 34 | 35 | (* Change the theme for the initial opened terminal windows 36 | to remove the need to close them in order for the custom 37 | theme to be applied. *) 38 | else 39 | set current settings of tabs of (every window whose id is windowID) to settings set themeName 40 | end if 41 | 42 | end repeat 43 | 44 | end tell 45 | -------------------------------------------------------------------------------- /src/os/installs/ubuntu/utils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | add_key() { 9 | 10 | wget -qO - "$1" | sudo apt-key add - &> /dev/null 11 | # │└─ write output to file 12 | # └─ don't show output 13 | 14 | } 15 | 16 | add_ppa() { 17 | sudo add-apt-repository -y ppa:"$1" &> /dev/null 18 | } 19 | 20 | add_to_source_list() { 21 | sudo sh -c "printf 'deb $1' >> '/etc/apt/sources.list.d/$2'" 22 | } 23 | 24 | autoremove() { 25 | 26 | # Remove packages that were automatically installed to satisfy 27 | # dependencies for other packages and are no longer needed. 28 | 29 | execute \ 30 | "sudo apt-get autoremove -qqy" \ 31 | "APT (autoremove)" 32 | 33 | } 34 | 35 | install_package() { 36 | 37 | declare -r EXTRA_ARGUMENTS="$3" 38 | declare -r PACKAGE="$2" 39 | declare -r PACKAGE_READABLE_NAME="$1" 40 | 41 | if ! package_is_installed "$PACKAGE"; then 42 | execute "sudo apt-get install --allow-unauthenticated -qqy $EXTRA_ARGUMENTS $PACKAGE" "$PACKAGE_READABLE_NAME" 43 | # suppress output ─┘│ 44 | # assume "yes" as the answer to all prompts ──┘ 45 | else 46 | print_success "$PACKAGE_READABLE_NAME" 47 | fi 48 | 49 | } 50 | 51 | package_is_installed() { 52 | dpkg -s "$1" &> /dev/null 53 | } 54 | 55 | update() { 56 | 57 | # Resynchronize the package index files from their sources. 58 | 59 | execute \ 60 | "sudo apt-get update -qqy" \ 61 | "APT (update)" 62 | 63 | } 64 | 65 | upgrade() { 66 | 67 | # Install the newest versions of all packages installed. 68 | 69 | execute \ 70 | "export DEBIAN_FRONTEND=\"noninteractive\" \ 71 | && sudo apt-get -o Dpkg::Options::=\"--force-confnew\" upgrade -qqy" \ 72 | "APT (upgrade)" 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/os/installs/macos/bash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | change_default_bash() { 10 | local newShellPath="" 11 | local brewPrefix="" 12 | 13 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 14 | 15 | brewPrefix="$(brew_prefix)" \ 16 | || return 1 17 | 18 | newShellPath="$brewPrefix/bin/bash" \ 19 | 20 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 21 | 22 | # Add the path of the `Bash` version installed through `Homebrew` 23 | # to the list of login shells from the `/etc/shells` file. 24 | # 25 | # This needs to be done because applications use this file to 26 | # determine whether a shell is valid (e.g.: `chsh` consults the 27 | # `/etc/shells` to determine whether an unprivileged user may 28 | # change the login shell for her own account). 29 | # 30 | # http://www.linuxfromscratch.org/blfs/view/7.4/postlfs/etcshells.html 31 | 32 | if ! grep "$newShellPath" < /etc/shells &> /dev/null; then 33 | execute \ 34 | "printf '%s\n' '$newShellPath' | sudo tee -a /etc/shells" \ 35 | "Add '$newShellPath' in '/etc/shells'" \ 36 | || return 1 37 | fi 38 | 39 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 40 | 41 | # Set latest version of `Bash` as the default 42 | # (macOS uses by default an older version of `Bash`). 43 | 44 | chsh -s "$newShellPath" &> /dev/null 45 | print_result $? "Make OS use the latest version of Bash" 46 | 47 | } 48 | 49 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 50 | 51 | main() { 52 | 53 | print_in_purple "\n Bash\n\n" 54 | 55 | brew_install "Bash" "bash" \ 56 | && change_default_bash 57 | 58 | brew_install "Bash Completion 2" "bash-completion@2" 59 | 60 | } 61 | 62 | main 63 | -------------------------------------------------------------------------------- /src/os/create_local_config_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | create_bash_local() { 9 | 10 | declare -r FILE_PATH="$HOME/.bash.local" 11 | 12 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 13 | 14 | if [ ! -e "$FILE_PATH" ] || [ -z "$FILE_PATH" ]; then 15 | 16 | DOTFILES_BIN_DIR="$(dirname "$(pwd)")/bin/" 17 | 18 | printf "%s\n" \ 19 | "#!/bin/bash 20 | 21 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 22 | 23 | # Set PATH additions. 24 | 25 | PATH=\"$DOTFILES_BIN_DIR:\$PATH\" 26 | 27 | export PATH" \ 28 | >> "$FILE_PATH" 29 | fi 30 | 31 | print_result $? "$FILE_PATH" 32 | 33 | } 34 | 35 | create_gitconfig_local() { 36 | 37 | declare -r FILE_PATH="$HOME/.gitconfig.local" 38 | 39 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 40 | 41 | if [ ! -e "$FILE_PATH" ] || [ -z "$FILE_PATH" ]; then 42 | 43 | printf "%s\n" \ 44 | "[commit] 45 | 46 | # Sign commits using GPG. 47 | # https://help.github.com/articles/signing-commits-using-gpg/ 48 | 49 | # gpgsign = true 50 | 51 | 52 | [user] 53 | 54 | name = 55 | email = 56 | # signingkey =" \ 57 | >> "$FILE_PATH" 58 | fi 59 | 60 | print_result $? "$FILE_PATH" 61 | 62 | } 63 | 64 | create_vimrc_local() { 65 | 66 | declare -r FILE_PATH="$HOME/.vimrc.local" 67 | 68 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 69 | 70 | if [ ! -e "$FILE_PATH" ]; then 71 | printf "" >> "$FILE_PATH" 72 | fi 73 | 74 | print_result $? "$FILE_PATH" 75 | 76 | } 77 | 78 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 79 | 80 | main() { 81 | 82 | print_in_purple "\n • Create local config files\n\n" 83 | 84 | create_bash_local 85 | create_gitconfig_local 86 | create_vimrc_local 87 | 88 | } 89 | 90 | main 91 | -------------------------------------------------------------------------------- /src/shell/bash_options: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Bash options. 4 | # https://www.gnu.org/software/bash/manual/bashref.html#The-Shopt-Builtin 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | # Enable `vi` editing mode. 9 | # https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Readline-vi-Mode 10 | 11 | set -o vi 12 | 13 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 14 | 15 | # Automatically prepend `cd` to directory names. 16 | 17 | shopt -s autocd 18 | 19 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 20 | 21 | # Autocorrect typos in path names when using the `cd` command. 22 | 23 | shopt -s cdspell 24 | 25 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 26 | 27 | # Check the window size after each command and, if necessary, update 28 | # the values of `LINES` and `COLUMNS`. 29 | 30 | shopt -s checkwinsize 31 | 32 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 33 | 34 | # Save all lines of a multiple-line command in the same history entry. 35 | 36 | shopt -s cmdhist 37 | 38 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 39 | 40 | # Include filenames beginning with a "." in the filename expansion. 41 | 42 | shopt -s dotglob 43 | 44 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 45 | 46 | # Use extended pattern matching features. 47 | 48 | shopt -s extglob 49 | 50 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 51 | 52 | # Append to the history file rather then overwriting it. 53 | 54 | shopt -s histappend 55 | 56 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 57 | 58 | # Do not attempt to search the PATH for possible completions when 59 | # completion is attempted on an empty line. 60 | 61 | shopt -s no_empty_cmd_completion 62 | 63 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 64 | 65 | # Match filenames in a case-insensitive fashion when performing 66 | # filename expansion. 67 | 68 | shopt -s nocaseglob 69 | -------------------------------------------------------------------------------- /src/os/installs/macos/utils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | brew_install() { 9 | 10 | declare -r ARGUMENTS="$3" 11 | declare -r FORMULA="$2" 12 | declare -r FORMULA_READABLE_NAME="$1" 13 | declare -r TAP_VALUE="$4" 14 | 15 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 16 | 17 | # Check if `Homebrew` is installed. 18 | 19 | if ! cmd_exists "brew"; then 20 | print_error "$FORMULA_READABLE_NAME ('Homebrew' is not installed)" 21 | return 1 22 | fi 23 | 24 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 25 | 26 | # If `brew tap` needs to be executed, 27 | # check if it executed correctly. 28 | 29 | if [ -n "$TAP_VALUE" ]; then 30 | if ! brew_tap "$TAP_VALUE"; then 31 | print_error "$FORMULA_READABLE_NAME ('brew tap $TAP_VALUE' failed)" 32 | return 1 33 | fi 34 | fi 35 | 36 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 37 | 38 | # Install the specified formula. 39 | 40 | # shellcheck disable=SC2086 41 | if brew list "$FORMULA" &> /dev/null; then 42 | print_success "$FORMULA_READABLE_NAME" 43 | else 44 | execute \ 45 | "brew install $FORMULA $ARGUMENTS" \ 46 | "$FORMULA_READABLE_NAME" 47 | fi 48 | 49 | } 50 | 51 | brew_prefix() { 52 | 53 | local path="" 54 | 55 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 56 | 57 | if path="$(brew --prefix 2> /dev/null)"; then 58 | printf "%s" "$path" 59 | return 0 60 | else 61 | print_error "Homebrew (get prefix)" 62 | return 1 63 | fi 64 | 65 | } 66 | 67 | brew_tap() { 68 | brew tap "$1" &> /dev/null 69 | } 70 | 71 | brew_update() { 72 | 73 | execute \ 74 | "brew update" \ 75 | "Homebrew (update)" 76 | 77 | } 78 | 79 | brew_upgrade() { 80 | 81 | execute \ 82 | "brew upgrade" \ 83 | "Homebrew (upgrade)" 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/shell/macos/bash_aliases: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4 | 5 | # Lock screen. 6 | 7 | alias afk="osascript -e 'tell application \"System Events\" to sleep'" 8 | 9 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 10 | 11 | # Shorter commands for `Homebrew`. 12 | 13 | alias brewd="brew doctor" 14 | alias brewi="brew install" 15 | alias brewr="brew uninstall" 16 | alias brews="brew search" 17 | alias brewu="brew update --quiet \ 18 | && brew upgrade \ 19 | && brew cleanup" 20 | 21 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 22 | 23 | # Clear DNS cache. 24 | 25 | alias clear-dns-cache="sudo dscacheutil -flushcache; \ 26 | sudo killall -HUP mDNSResponder" 27 | 28 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 29 | 30 | # Empty the trash, the main HDD and on all mounted volumes, 31 | # and clear Apple’s system logs to improve shell startup speed. 32 | 33 | alias empty-trash="sudo rm -frv /Volumes/*/.Trashes; \ 34 | sudo rm -frv ~/.Trash; \ 35 | sudo rm -frv /private/var/log/asl/*.asl; \ 36 | sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'" 37 | 38 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 39 | 40 | # Hide/Show desktop icons. 41 | 42 | alias hide-desktop-icons="defaults write com.apple.finder CreateDesktop -bool false \ 43 | && killall Finder" 44 | 45 | alias show-desktop-icons="defaults write com.apple.finder CreateDesktop -bool true \ 46 | && killall Finder" 47 | 48 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 49 | 50 | # Open from the terminal. 51 | 52 | alias o="open" 53 | 54 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 55 | 56 | # Update applications and CLTs. 57 | 58 | alias u="sudo softwareupdate --install --all \ 59 | && brew update \ 60 | && brew upgrade \ 61 | && brew cleanup" 62 | -------------------------------------------------------------------------------- /src/os/preferences/macos/safari.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n Safari\n\n" 9 | 10 | execute "defaults write com.apple.Safari AutoOpenSafeDownloads -bool false" \ 11 | "Disable opening 'safe' files automatically" 12 | 13 | execute "defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true" \ 14 | "Set backspace key to go to the previous page in history" 15 | 16 | execute "defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true && \ 17 | defaults write com.apple.Safari IncludeDevelopMenu -bool true && \ 18 | defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true" \ 19 | "Enable the 'Develop' menu and the 'Web Inspector'" 20 | 21 | execute "defaults write com.apple.Safari EnableEnhancedPrivacyInPrivateBrowsing -bool true && 22 | defaults write com.apple.Safari EnableEnhancedPrivacyInRegularBrowsing -bool true " \ 23 | "Use advanced tracking and fingerprinting protection in all browsing." 24 | 25 | execute "defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false" \ 26 | "Set search type to 'Contains' instead of 'Starts With'" 27 | 28 | execute "defaults write com.apple.Safari HomePage -string 'about:blank'" \ 29 | "Set home page to 'about:blank'" 30 | 31 | execute "defaults write com.apple.Safari IncludeInternalDebugMenu -bool true" \ 32 | "Enable 'Debug' menu" 33 | 34 | execute "defaults write com.apple.Safari ShowFavoritesBar -bool false" \ 35 | "Hide bookmarks bar by default" 36 | 37 | execute "defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true" \ 38 | "Show the full URL in the address bar" 39 | 40 | execute "defaults write com.apple.Safari SuppressSearchSuggestions -bool true && \ 41 | defaults write com.apple.Safari UniversalSearchEnabled -bool false" \ 42 | "Don’t send search queries to Apple" 43 | 44 | execute "defaults write -g WebKitDeveloperExtras -bool true" \ 45 | "Add a context menu item for showing the 'Web Inspector' in web views" 46 | 47 | execute "defaults write com.apple.Safari WebKitInitialTimedLayoutDelay 0.25" \ 48 | "Disable the standard delay in rendering a web page." 49 | 50 | killall "Safari" &> /dev/null 51 | -------------------------------------------------------------------------------- /src/os/installs/macos/xcode.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | agree_with_xcode_licence() { 9 | 10 | # Automatically agree to the terms of the `Xcode` license. 11 | # https://github.com/alrra/dotfiles/issues/10 12 | 13 | sudo xcodebuild -license accept &> /dev/null 14 | print_result $? "Agree to the terms of the Xcode licence" 15 | 16 | } 17 | 18 | are_xcode_command_line_tools_installed() { 19 | xcode-select --print-path &> /dev/null 20 | } 21 | 22 | install_xcode() { 23 | 24 | # If necessary, prompt user to install `Xcode`. 25 | 26 | if ! is_xcode_installed; then 27 | open "macappstores://itunes.apple.com/en/app/xcode/id497799835" 28 | fi 29 | 30 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 31 | 32 | # Wait until `Xcode` is installed. 33 | 34 | execute \ 35 | "until is_xcode_installed; do \ 36 | sleep 5; \ 37 | done" \ 38 | "Install Xcode.app" 39 | 40 | } 41 | 42 | install_xcode_command_line_tools() { 43 | 44 | # If necessary, prompt user to install 45 | # the `Xcode Command Line Tools`. 46 | 47 | xcode-select --install &> /dev/null 48 | 49 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 50 | 51 | # Wait until the `Xcode Command Line Tools` are installed. 52 | 53 | execute \ 54 | "until are_xcode_command_line_tools_installed; do \ 55 | sleep 5; \ 56 | done" \ 57 | "Install Xcode Command Line Tools" 58 | 59 | } 60 | 61 | is_xcode_installed() { 62 | [ -d "/Applications/Xcode.app" ] 63 | } 64 | 65 | set_xcode_developer_directory() { 66 | 67 | # Point the `xcode-select` developer directory to 68 | # the appropriate directory from within `Xcode.app`. 69 | # 70 | # https://github.com/alrra/dotfiles/issues/13 71 | 72 | sudo xcode-select -switch "/Applications/Xcode.app/Contents/Developer" &> /dev/null 73 | print_result $? "Make 'xcode-select' developer directory point to the appropriate directory from within Xcode.app" 74 | 75 | } 76 | 77 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 78 | 79 | main() { 80 | 81 | print_in_purple " Xcode\n\n" 82 | 83 | install_xcode_command_line_tools 84 | install_xcode 85 | set_xcode_developer_directory 86 | agree_with_xcode_licence 87 | 88 | } 89 | 90 | main 91 | -------------------------------------------------------------------------------- /src/os/create_symbolic_links.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | create_symlinks() { 9 | 10 | declare -a FILES_TO_SYMLINK=( 11 | 12 | "shell/bash_aliases" 13 | "shell/bash_autocompletion" 14 | "shell/bash_exports" 15 | "shell/bash_functions" 16 | "shell/bash_init" 17 | "shell/bash_logout" 18 | "shell/bash_options" 19 | "shell/bash_profile" 20 | "shell/bash_prompt" 21 | "shell/bashrc" 22 | "shell/curlrc" 23 | "shell/inputrc" 24 | 25 | "git/gitattributes" 26 | "git/gitconfig" 27 | "git/gitignore" 28 | 29 | "tmux/tmux.conf" 30 | 31 | "vim/vim" 32 | "vim/vimrc" 33 | 34 | ) 35 | 36 | local i="" 37 | local sourceFile="" 38 | local targetFile="" 39 | local skipQuestions=false 40 | 41 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 42 | 43 | skip_questions "$@" \ 44 | && skipQuestions=true 45 | 46 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 47 | 48 | for i in "${FILES_TO_SYMLINK[@]}"; do 49 | 50 | sourceFile="$(cd .. && pwd)/$i" 51 | targetFile="$HOME/.$(printf "%s" "$i" | sed "s/.*\/\(.*\)/\1/g")" 52 | 53 | if [ ! -e "$targetFile" ] || $skipQuestions; then 54 | 55 | execute \ 56 | "ln -fs $sourceFile $targetFile" \ 57 | "$targetFile → $sourceFile" 58 | 59 | elif [ "$(readlink "$targetFile")" == "$sourceFile" ]; then 60 | print_success "$targetFile → $sourceFile" 61 | else 62 | 63 | if ! $skipQuestions; then 64 | 65 | ask_for_confirmation "'$targetFile' already exists, do you want to overwrite it?" 66 | if answer_is_yes; then 67 | 68 | rm -rf "$targetFile" 69 | 70 | execute \ 71 | "ln -fs $sourceFile $targetFile" \ 72 | "$targetFile → $sourceFile" 73 | 74 | else 75 | print_error "$targetFile → $sourceFile" 76 | fi 77 | 78 | fi 79 | 80 | fi 81 | 82 | done 83 | 84 | } 85 | 86 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 87 | 88 | main() { 89 | print_in_purple "\n • Create symbolic links\n\n" 90 | create_symlinks "$@" 91 | } 92 | 93 | main "$@" 94 | -------------------------------------------------------------------------------- /src/os/preferences/macos/dock.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n Dock\n\n" 9 | 10 | execute "defaults write com.apple.dock autohide -bool true" \ 11 | "Automatically hide/show the Dock" 12 | 13 | execute "defaults write com.apple.dock autohide-delay -float 0" \ 14 | "Disable the hide Dock delay" 15 | 16 | execute "defaults write com.apple.dock enable-spring-load-actions-on-all-items -bool true" \ 17 | "Enable spring loading for all Dock items" 18 | 19 | execute "defaults write com.apple.dock expose-animation-duration -float 0.1" \ 20 | "Make all Mission Control related animations faster." 21 | 22 | execute "defaults write com.apple.dock expose-group-by-app -bool false" \ 23 | "Do not group windows by application in Mission Control" 24 | 25 | execute "defaults write com.apple.dock launchanim -bool false" \ 26 | "Disable the opening of an application from the Dock animations." 27 | 28 | execute "defaults write com.apple.dock mineffect -string 'scale'" \ 29 | "Change minimize/maximize window effect" 30 | 31 | execute "defaults write com.apple.dock minimize-to-application -bool true" \ 32 | "Reduce clutter by minimizing windows into their application icons" 33 | 34 | execute "defaults write com.apple.dock mru-spaces -bool false" \ 35 | "Do not automatically rearrange spaces based on most recent use" 36 | 37 | execute "defaults write com.apple.dock persistent-apps -array && \ 38 | defaults write com.apple.dock persistent-others -array " \ 39 | "Wipe all app icons" 40 | 41 | execute "defaults write com.apple.dock show-process-indicators -bool true" \ 42 | "Show indicator lights for open applications" 43 | 44 | execute "defaults write com.apple.dock show-recents -bool false" \ 45 | "Do not show recent applications in Dock" 46 | 47 | execute "defaults write com.apple.dock showhidden -bool true" \ 48 | "Make icons of hidden applications translucent" 49 | 50 | execute "defaults write com.apple.dock tilesize -int 60" \ 51 | "Set icon size" 52 | 53 | execute "defaults write com.apple.dock wvous-tr-corner -int 0" \ 54 | "Disable top right hot corner" 55 | 56 | execute "defaults write com.apple.dock wvous-tl-corner -int 0" \ 57 | "Disable top left hot corner" 58 | 59 | execute "defaults write com.apple.dock wvous-bl-corner -int 0" \ 60 | "Disable bottom left hot corner" 61 | 62 | execute "defaults write com.apple.dock wvous-br-corner -int 0" \ 63 | "Disable bottom right hot corner" 64 | 65 | killall "Dock" &> /dev/null 66 | -------------------------------------------------------------------------------- /src/os/installs/macos/homebrew.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" \ 5 | && . "./utils.sh" 6 | 7 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 8 | 9 | add_to_path() { 10 | 11 | # Check if `brew` is available. 12 | 13 | if command -v brew &> /dev/null; then 14 | return 15 | fi 16 | 17 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 18 | 19 | # If not, add it to the PATH. 20 | 21 | HARDWARE="$(uname -m)" 22 | brewPrefix="" 23 | 24 | if [ "$HARDWARE" == "arm64" ]; then 25 | brewPrefix="/opt/homebrew" 26 | elif [ "$HARDWARE" == "x86_64" ]; then 27 | brewPrefix="/usr/local" 28 | else 29 | print_error "Homebrew is only supported on Intel and ARM processors!" 30 | fi 31 | 32 | update_local_shell_configs "export PATH=\"$brewPrefix/bin:\$PATH\" # Homebrew" 33 | } 34 | 35 | get_git_config_file_path() { 36 | 37 | local path="" 38 | 39 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 40 | 41 | if path="$(brew --repository 2> /dev/null)/.git/config"; then 42 | printf "%s" "$path" 43 | return 0 44 | else 45 | print_error "Get config file path" 46 | return 1 47 | fi 48 | 49 | } 50 | 51 | install() { 52 | 53 | if ! cmd_exists "brew"; then 54 | ask_for_sudo 55 | printf "\n" | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" &> /dev/null 56 | # └─ simulate the ENTER keypress 57 | fi 58 | 59 | print_result $? "Install" 60 | 61 | } 62 | 63 | opt_out_of_analytics() { 64 | 65 | local path="" 66 | 67 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 68 | 69 | # Try to get the path of the `Homebrew` git config file. 70 | 71 | path="$(get_git_config_file_path)" \ 72 | || return 1 73 | 74 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 75 | 76 | # Opt-out of Homebrew's analytics. 77 | # https://github.com/Homebrew/brew/blob/0c95c60511cc4d85d28f66b58d51d85f8186d941/share/doc/homebrew/Analytics.md#opting-out 78 | 79 | if [ "$(git config --file="$path" --get homebrew.analyticsdisabled)" != "true" ]; then 80 | git config --file="$path" --replace-all homebrew.analyticsdisabled true &> /dev/null 81 | print_result $? "Opt-out of analytics" 82 | fi 83 | 84 | } 85 | 86 | update() { 87 | execute \ 88 | "brew update" \ 89 | "Update" 90 | } 91 | 92 | upgrade() { 93 | execute \ 94 | "brew upgrade" \ 95 | "Upgrade" 96 | } 97 | 98 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 99 | 100 | main() { 101 | 102 | print_in_purple "\n Homebrew\n\n" 103 | 104 | install 105 | add_to_path 106 | opt_out_of_analytics 107 | 108 | update 109 | upgrade 110 | } 111 | 112 | main 113 | -------------------------------------------------------------------------------- /src/os/set_github_ssh_key.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | add_ssh_configs() { 9 | 10 | printf "%s\n" \ 11 | "Host github.com" \ 12 | " IdentityFile $1" \ 13 | " LogLevel ERROR" >> ~/.ssh/config 14 | 15 | print_result $? "Add SSH configs" 16 | 17 | } 18 | 19 | copy_public_ssh_key_to_clipboard () { 20 | 21 | if cmd_exists "pbcopy"; then 22 | 23 | pbcopy < "$1" 24 | print_result $? "Copy public SSH key to clipboard" 25 | 26 | elif cmd_exists "xclip"; then 27 | 28 | xclip -selection clip < "$1" 29 | print_result $? "Copy public SSH key to clipboard" 30 | 31 | else 32 | print_warning "Please copy the public SSH key ($1) to clipboard" 33 | fi 34 | 35 | } 36 | 37 | generate_ssh_keys() { 38 | 39 | ask "Please provide an email address: " && printf "\n" 40 | ssh-keygen -t rsa -b 4096 -C "$(get_answer)" -f "$1" 41 | 42 | print_result $? "Generate SSH keys" 43 | 44 | } 45 | 46 | open_github_ssh_page() { 47 | 48 | declare -r GITHUB_SSH_URL="https://github.com/settings/ssh" 49 | 50 | # The order of the following checks matters 51 | # as on Ubuntu there is also a utility called `open`. 52 | 53 | if cmd_exists "xdg-open"; then 54 | xdg-open "$GITHUB_SSH_URL" 55 | elif cmd_exists "open"; then 56 | open "$GITHUB_SSH_URL" 57 | else 58 | print_warning "Please add the public SSH key to GitHub ($GITHUB_SSH_URL)" 59 | fi 60 | 61 | } 62 | 63 | set_github_ssh_key() { 64 | 65 | local sshKeyFileName="$HOME/.ssh/github" 66 | 67 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 68 | 69 | # If there is already a file with that 70 | # name, generate another, unique, file name. 71 | 72 | if [ -f "$sshKeyFileName" ]; then 73 | sshKeyFileName="$(mktemp -u "$HOME/.ssh/github_XXXXX")" 74 | fi 75 | 76 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 77 | 78 | generate_ssh_keys "$sshKeyFileName" 79 | add_ssh_configs "$sshKeyFileName" 80 | copy_public_ssh_key_to_clipboard "${sshKeyFileName}.pub" 81 | open_github_ssh_page 82 | test_ssh_connection \ 83 | && rm "${sshKeyFileName}.pub" 84 | 85 | } 86 | 87 | test_ssh_connection() { 88 | 89 | while true; do 90 | 91 | ssh -T git@github.com &> /dev/null 92 | [ $? -eq 1 ] && break 93 | 94 | sleep 5 95 | 96 | done 97 | 98 | } 99 | 100 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 101 | 102 | main() { 103 | 104 | print_in_purple "\n • Set up GitHub SSH keys\n\n" 105 | 106 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 107 | 108 | if ! is_git_repository; then 109 | print_error "Not a Git repository" 110 | exit 1 111 | fi 112 | 113 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 114 | 115 | ssh -T git@github.com &> /dev/null 116 | 117 | if [ $? -ne 1 ]; then 118 | set_github_ssh_key 119 | fi 120 | 121 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 122 | 123 | print_result $? "Set up GitHub SSH keys" 124 | 125 | } 126 | 127 | main 128 | -------------------------------------------------------------------------------- /src/shell/bash_exports: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Bash Variables. 4 | # https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | # Stop the macOS Terminal from showing a warning 9 | # message when Zsh is not the default shell. 10 | # 11 | # https://support.apple.com/en-us/HT208050 12 | 13 | export BASH_SILENCE_DEPRECATION_WARNING=1 14 | 15 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 16 | 17 | # Make `vim` the default editor. 18 | 19 | export EDITOR="vim" 20 | 21 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 22 | 23 | # Ignore commands that start with spaces and duplicates. 24 | 25 | export HISTCONTROL=ignoreboth 26 | 27 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 28 | 29 | # Increase the maximum number of lines of history 30 | # persisted in the history file (default value is 500). 31 | 32 | export HISTFILESIZE=10000 33 | 34 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 35 | 36 | # Don't add certain commands to the history file. 37 | 38 | export HISTIGNORE="&:[bf]g:c:clear:history:exit:q:pwd:* --help" 39 | 40 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 41 | 42 | # Increase the maximum number of commands recorded 43 | # in the command history (default value is 500). 44 | 45 | export HISTSIZE=10000 46 | 47 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 48 | 49 | # Prefer US English and use UTF-8 encoding. 50 | 51 | export LANG="en_US" 52 | export LC_ALL="en_US.UTF-8" 53 | 54 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 55 | 56 | # Use custom `less` colors for `man` pages. 57 | 58 | export LESS_TERMCAP_md="$(tput bold 2> /dev/null; tput setaf 2 2> /dev/null)" 59 | export LESS_TERMCAP_me="$(tput sgr0 2> /dev/null)" 60 | 61 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 62 | 63 | # Don't clear the screen after quitting a `man` page. 64 | 65 | export MANPAGER="less -X" 66 | 67 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 68 | 69 | # Enable the module compile cache for the Node.js instance. 70 | # 71 | # https://nodejs.org/api/cli.html#node_compile_cachedir 72 | # https://nodejs.org/en/blog/release/v22.1.0#module-implement-node_compile_cache-for-automatic-on-disk-code-caching 73 | 74 | export NODE_COMPILE_CACHE="$HOME/.cache/node_compile_cache" 75 | 76 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 77 | 78 | # Increase the maximum number of lines of history persisted 79 | # in the `Node` REPL history file (default value is 1000). 80 | # 81 | # https://github.com/nodejs/node/blob/c948877688ff2b6a37f2c88724b656aae495c7b2/doc/api/repl.md#persistent-history 82 | 83 | export NODE_REPL_HISTORY_SIZE=10000 84 | 85 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 86 | 87 | # If not set, make new shells get the history lines from all previous 88 | # shells instead of the default "last window closed" history. 89 | 90 | if ! printf "%s" "$PROMPT_COMMAND" | grep "history -a" &> /dev/null; then 91 | export PROMPT_COMMAND="history -a; $PROMPT_COMMAND" 92 | fi 93 | 94 | # Remove `update_terminal_cwd` from the `PROMPT_COMMAND` 95 | # environment variable if it doesn't exist in the current shell. 96 | # 97 | # On macOS `update_terminal_cwd` is added to the `PROMPT_COMMAND` 98 | # environment variable however, `/etc/bashrc_Apple_Terminal` 99 | # that contains the shell function definition is only executed 100 | # for `Terminal.app`. Other terminals (e.g.: VS Code's terminal) 101 | # will not have the shell function, hence, they will show the 102 | # 103 | # bash: update_terminal_cwd: command not found 104 | # 105 | # error everytime the prompt is displayed. 106 | 107 | if printf "%s" "$PROMPT_COMMAND" | grep "update_terminal_cwd" &> /dev/null && 108 | ! command -v update_terminal_cwd &> /dev/null; then 109 | export PROMPT_COMMAND="$(printf "%s" "$PROMPT_COMMAND" | sed 's/\(.*\)update_terminal_cwd;*\(.*\)/\1\2/g')" 110 | fi 111 | 112 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 113 | 114 | # Make Python use UTF-8 encoding for output to stdin/stdout/stderr. 115 | 116 | export PYTHONIOENCODING="UTF-8" 117 | -------------------------------------------------------------------------------- /src/tmux/tmux.conf: -------------------------------------------------------------------------------- 1 | # tmux settings 2 | # http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man1/tmux.1#x4f5054494f4e53 3 | 4 | 5 | # ---------------------------------------------------------------------- 6 | # | General Settings | 7 | # ---------------------------------------------------------------------- 8 | 9 | # Make window index start at 1 10 | set -g base-index 1 11 | 12 | # Make pane index start at 1 13 | setw -g pane-base-index 1 14 | 15 | # Remove delay when sending commands 16 | # (default is 500 milliseconds) 17 | set -sg escape-time 1 18 | 19 | 20 | # ---------------------------------------------------------------------- 21 | # | Key Mappings | 22 | # ---------------------------------------------------------------------- 23 | 24 | # Change the key combination for the PREFIX key to `ctrl-a` 25 | set -g prefix C-a 26 | unbind-key C-b 27 | 28 | # Make tmux send the PREFIX to an application running 29 | # within tmux simply by pressing PREFIX key twice 30 | bind C-a send-prefix 31 | 32 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 33 | 34 | # Use vim keybindings in copy mode 35 | setw -g mode-keys vi 36 | 37 | # Workaround for accessing macOS' pasteboard 38 | # https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard 39 | 40 | if-shell \ 41 | 'test "$(uname -s)" = Darwin' \ 42 | 'set-option -g default-command "exec reattach-to-user-namespace -l $SHELL"' 43 | 44 | # Remap the copy & paste keys to work as in vim 45 | unbind [ 46 | bind Escape copy-mode 47 | unbind p 48 | bind p paste-buffer 49 | bind-key -T copy-mode-vi "v" send-keys -X begin-selection 50 | bind-key -T copy-mode-vi "y" send-keys -X copy-selection 51 | 52 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 53 | 54 | # [ PREFIX + - ] Split window horizontally 55 | bind - split-window -v 56 | 57 | # [ PREFIX + | ] Split window vertically 58 | bind | split-window -h 59 | 60 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 61 | 62 | # [ PREFIX + h/j/k/l ] Move from pane to pane 63 | bind h select-pane -L 64 | bind j select-pane -D 65 | bind k select-pane -U 66 | bind l select-pane -R 67 | 68 | # [ PREFIX + H/J/K/L ] Resize pane 69 | bind -r H resize-pane -L 5 70 | bind -r J resize-pane -D 5 71 | bind -r K resize-pane -U 5 72 | bind -r L resize-pane -R 5 73 | 74 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 75 | 76 | # [ PREFIX + r ] Reload tmux config 77 | bind r source-file ~/.tmux.conf \; display "tmux configs reloaded" 78 | 79 | 80 | # ---------------------------------------------------------------------- 81 | # | Status bar | 82 | # ---------------------------------------------------------------------- 83 | 84 | # Notified when something happens in one of the other windows 85 | setw -g monitor-activity on 86 | set -g visual-activity on 87 | 88 | # Periodically refresh the status bar 89 | set -g status-interval 60 90 | 91 | # Customize what is displayed 92 | set -g status-justify left 93 | set -g status-left-length 50 94 | set -g status-left " #S / " 95 | # └─ current session name 96 | set -g status-right " %R " 97 | # └─ current time 98 | 99 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 100 | 101 | # Default colors 102 | set -g status-bg green 103 | set -g status-fg black 104 | 105 | # Colors for window list 106 | setw -g window-status-style fg=black,bg=green,dim 107 | 108 | # Colors for active window 109 | setw -g window-status-current-style fg=black,bg=yellow,dim 110 | 111 | 112 | # ---------------------------------------------------------------------- 113 | # | Visual Styling | 114 | # ---------------------------------------------------------------------- 115 | 116 | # Display things in 256 colors 117 | set -g default-terminal "screen-256color" 118 | 119 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 120 | 121 | # Command Line 122 | set -g message-style fg=black,bg=green,dim 123 | 124 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 125 | 126 | # Pane divider 127 | set -g pane-active-border-style bg=default,fg=green 128 | set -g pane-border-style bg=default,fg=colour244 129 | -------------------------------------------------------------------------------- /src/os/preferences/macos/finder.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n Finder\n\n" 9 | 10 | execute "defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true && \ 11 | defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true && \ 12 | defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true" \ 13 | "Automatically open a new Finder window when a volume is mounted" 14 | 15 | execute "defaults write com.apple.finder _FXShowPosixPathInTitle -bool true" \ 16 | "Use full POSIX path as window title" 17 | 18 | execute "defaults write com.apple.finder DisableAllAnimations -bool true" \ 19 | "Disable all animations" 20 | 21 | execute "defaults write com.apple.finder WarnOnEmptyTrash -bool false" \ 22 | "Disable the warning before emptying the Trash" 23 | 24 | execute "defaults write com.apple.finder FXDefaultSearchScope -string 'SCcf'" \ 25 | "Search the current directory by default" 26 | 27 | execute "defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false" \ 28 | "Disable warning when changing a file extension" 29 | 30 | execute "defaults write com.apple.finder FXPreferredViewStyle -string 'Nlsv'" \ 31 | "Use list view in all Finder windows by default" 32 | 33 | execute "defaults write com.apple.finder NewWindowTarget -string 'PfDe' && \ 34 | defaults write com.apple.finder NewWindowTargetPath -string 'file://$HOME/Desktop/'" \ 35 | "Set 'Desktop' as the default location for new Finder windows" 36 | 37 | execute "defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true && \ 38 | defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true && \ 39 | defaults write com.apple.finder ShowMountedServersOnDesktop -bool true && \ 40 | defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true" \ 41 | "Show icons for hard drives, servers, and removable media on the desktop" 42 | 43 | execute "defaults write com.apple.finder ShowRecentTags -bool false" \ 44 | "Do not show recent tags" 45 | 46 | execute "defaults write -g AppleShowAllExtensions -bool true" \ 47 | "Show all filename extensions" 48 | 49 | execute "/usr/libexec/PlistBuddy -c 'Set :DesktopViewSettings:IconViewSettings:iconSize 72' ~/Library/Preferences/com.apple.finder.plist && \ 50 | /usr/libexec/PlistBuddy -c 'Set :StandardViewSettings:IconViewSettings:iconSize 72' ~/Library/Preferences/com.apple.finder.plist" \ 51 | "Set icon size" 52 | 53 | execute "/usr/libexec/PlistBuddy -c 'Set :DesktopViewSettings:IconViewSettings:gridSpacing 1' ~/Library/Preferences/com.apple.finder.plist && \ 54 | /usr/libexec/PlistBuddy -c 'Set :StandardViewSettings:IconViewSettings:gridSpacing 1' ~/Library/Preferences/com.apple.finder.plist" \ 55 | "Set icon grid spacing size" 56 | 57 | execute "/usr/libexec/PlistBuddy -c 'Set :DesktopViewSettings:IconViewSettings:textSize 13' ~/Library/Preferences/com.apple.finder.plist && \ 58 | /usr/libexec/PlistBuddy -c 'Set :StandardViewSettings:IconViewSettings:textSize 13' ~/Library/Preferences/com.apple.finder.plist" \ 59 | "Set icon label text size" 60 | 61 | execute "/usr/libexec/PlistBuddy -c 'Set :DesktopViewSettings:IconViewSettings:labelOnBottom true' ~/Library/Preferences/com.apple.finder.plist && \ 62 | /usr/libexec/PlistBuddy -c 'Set :StandardViewSettings:IconViewSettings:labelOnBottom true' ~/Library/Preferences/com.apple.finder.plist" \ 63 | "Set icon label position" 64 | 65 | execute "/usr/libexec/PlistBuddy -c 'Set :DesktopViewSettings:IconViewSettings:showItemInfo true' ~/Library/Preferences/com.apple.finder.plist && \ 66 | /usr/libexec/PlistBuddy -c 'Set :StandardViewSettings:IconViewSettings:showItemInfo true' ~/Library/Preferences/com.apple.finder.plist" \ 67 | "Show item info" 68 | 69 | execute "/usr/libexec/PlistBuddy -c 'Set :DesktopViewSettings:IconViewSettings:arrangeBy none' ~/Library/Preferences/com.apple.finder.plist && \ 70 | /usr/libexec/PlistBuddy -c 'Set :StandardViewSettings:IconViewSettings:arrangeBy none' ~/Library/Preferences/com.apple.finder.plist" \ 71 | "Set sort method" 72 | 73 | killall "Finder" &> /dev/null 74 | 75 | # Starting with Mac OS X Mavericks preferences are cached, 76 | # so in order for things to get properly set using `PlistBuddy`, 77 | # the `cfprefsd` process also needs to be killed. 78 | # 79 | # https://github.com/alrra/dotfiles/commit/035dda057ddc6013ba21db3d2c30eeb51ba8f200 80 | 81 | killall "cfprefsd" &> /dev/null 82 | -------------------------------------------------------------------------------- /src/os/preferences/macos/ui_and_ux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd "$(dirname "${BASH_SOURCE[0]}")" \ 4 | && . "../../utils.sh" 5 | 6 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 7 | 8 | print_in_purple "\n UI & UX\n\n" 9 | 10 | execute "defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true && \ 11 | defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true" \ 12 | "Avoid creating '.DS_Store' files on network or USB volumes" 13 | 14 | execute "defaults write com.apple.menuextra.battery ShowPercent -string 'NO'" \ 15 | "Hide battery percentage from the menu bar" 16 | 17 | execute "sudo defaults write /Library/Preferences/com.apple.loginwindow showInputMenu -bool true" \ 18 | "Show language menu in the top right corner of the boot screen" 19 | 20 | execute "defaults write com.apple.CrashReporter UseUNC 1" \ 21 | "Make crash reports appear as notifications" 22 | 23 | execute "defaults write com.apple.LaunchServices LSQuarantine -bool false" \ 24 | "Disable 'Are you sure you want to open this application?' dialog" 25 | 26 | execute "defaults write com.apple.print.PrintingPrefs 'Quit When Finished' -bool true" \ 27 | "Automatically quit the printer app once the print jobs are completed" 28 | 29 | execute "defaults write com.apple.screencapture disable-shadow -bool true" \ 30 | "Disable shadow in screenshots" 31 | 32 | execute "defaults write com.apple.screencapture location -string '$HOME/Desktop'" \ 33 | "Save screenshots to the Desktop" 34 | 35 | execute "defaults write com.apple.screencapture show-thumbnail -bool false" \ 36 | "Do not show thumbnail" 37 | 38 | execute "defaults write com.apple.screencapture type -string 'png'" \ 39 | "Save screenshots as PNGs" 40 | 41 | execute "defaults write com.apple.screensaver askForPassword -int 1 && \ 42 | defaults write com.apple.screensaver askForPasswordDelay -int 0"\ 43 | "Require password immediately after into sleep or screen saver mode" 44 | 45 | execute "defaults write -g AppleFontSmoothing -int 2" \ 46 | "Enable subpixel font rendering on non-Apple LCDs" 47 | 48 | execute "defaults write -g AppleShowScrollBars -string 'Always'" \ 49 | "Always show scrollbars" 50 | 51 | execute "defaults write -g NSAutomaticWindowAnimationsEnabled -bool false" \ 52 | "Disable window opening and closing animations." 53 | 54 | execute "defaults write -g NSDisableAutomaticTermination -bool true" \ 55 | "Disable automatic termination of inactive apps" 56 | 57 | execute "defaults write -g NSNavPanelExpandedStateForSaveMode -bool true" \ 58 | "Expand save panel by default" 59 | 60 | execute "defaults write -g NSTableViewDefaultSizeMode -int 2" \ 61 | "Set sidebar icon size to medium" 62 | 63 | execute "defaults write -g NSUseAnimatedFocusRing -bool false" \ 64 | "Disable the over-the-top focus ring animation" 65 | 66 | execute "defaults write -g NSWindowResizeTime -float 0.001" \ 67 | "Accelerated playback when adjusting the window size." 68 | 69 | execute "defaults write -g PMPrintingExpandedStateForPrint -bool true" \ 70 | "Expand print panel by default" 71 | 72 | execute "defaults write -g QLPanelAnimationDuration -float 0" \ 73 | "Disable opening a Quick Look window animations." 74 | 75 | execute "defaults write com.apple.systempreferences NSQuitAlwaysKeepsWindows -bool false" \ 76 | "Disable resume system-wide" 77 | 78 | execute "sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string 'Laptop' && \ 79 | sudo scutil --set ComputerName 'laptop' && \ 80 | sudo scutil --set HostName 'laptop' && \ 81 | sudo scutil --set LocalHostName 'laptop'" \ 82 | "Set computer name" 83 | 84 | execute "sudo systemsetup -setrestartfreeze on" \ 85 | "Restart automatically if the computer freezes" 86 | 87 | execute "sudo defaults write /Library/Preferences/com.apple.Bluetooth.plist ControllerPowerState 0 && \ 88 | sudo launchctl unload /System/Library/LaunchDaemons/com.apple.blued.plist && \ 89 | sudo launchctl load /System/Library/LaunchDaemons/com.apple.blued.plist" \ 90 | "Turn Bluetooth off" 91 | 92 | execute "for domain in ~/Library/Preferences/ByHost/com.apple.systemuiserver.*; do 93 | sudo defaults write \"\${domain}\" dontAutoLoad -array \ 94 | '/System/Library/CoreServices/Menu Extras/TimeMachine.menu' \ 95 | '/System/Library/CoreServices/Menu Extras/Volume.menu' 96 | done \ 97 | && sudo defaults write com.apple.systemuiserver menuExtras -array \ 98 | '/System/Library/CoreServices/Menu Extras/Bluetooth.menu' \ 99 | '/System/Library/CoreServices/Menu Extras/AirPort.menu' \ 100 | '/System/Library/CoreServices/Menu Extras/Battery.menu' \ 101 | '/System/Library/CoreServices/Menu Extras/Clock.menu' 102 | " \ 103 | "Hide Time Machine and Volume icons from the menu bar" 104 | 105 | killall "SystemUIServer" &> /dev/null 106 | -------------------------------------------------------------------------------- /src/bin/get-compression-heatmap: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # DESCRIPTION: 4 | # 5 | # Generate compression efficiency heatmap images for files / URLs. 6 | # 7 | # USAGE: 8 | # 9 | # get-compression-heatmap URL/FILE ... 10 | # 11 | # USEFUL LINKS: 12 | # 13 | # http://encode.ru/threads/1725-pngthermal-pseudo-thermal-view-of-create_heatmap_for_png-compression-efficiency 14 | # http://encode.ru/threads/1889-gzthermal-pseudo-thermal-view-of-Gzip-Deflate-compression-efficiency 15 | 16 | # ---------------------------------------------------------------------- 17 | 18 | declare gzthermal="" 19 | declare pngthermal="" 20 | 21 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 22 | 23 | cmd_exists() { 24 | command -v "$1" &> /dev/null 25 | } 26 | 27 | compress_file() { 28 | cat "$1" | tee >(gzip > "$2") &> /dev/null 29 | } 30 | 31 | create_heatmap_for_file() { 32 | 33 | local tmpFile="$1" 34 | 35 | if [ "$(get_file_mime_type "$1")" != "application/x-gzip" ]; then 36 | tmpFile="$(create_tmp_file)" 37 | compress_file "$1" "$tmpFile" 38 | fi \ 39 | && "${gzthermal}" "$tmpFile" \ 40 | && mv "gzthermal-result.png" "$2" 41 | # └─ this cannot be changed :( 42 | 43 | } 44 | 45 | create_heatmap_for_png() { 46 | "${pngthermal}" "$1" "$2" 47 | } 48 | 49 | create_heatmap_for_webpage() { 50 | 51 | declare -r -a CURL_DEFAULT_OPTIONS=( 52 | --connect-timeout 30 53 | --header "Accept-Encoding: gzip, deflate" 54 | --header "Cache-Control: no-cache" # Prevent intermediate 55 | # proxies from caching 56 | # the response. 57 | 58 | --location # If the page was moved 59 | # to a different location, 60 | # redo the request. 61 | --max-time 150 62 | --show-error 63 | --silent 64 | --user-agent "Mozilla/5.0 Gecko" # Send a fake UA string 65 | # for sites that sniff 66 | # it instead of using the 67 | # Accept-Encoding header. 68 | ) 69 | 70 | local tmpFile="$(create_tmp_file)" 71 | 72 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 73 | 74 | # Try to get the compressed version of the page, and if the 75 | # page isn't served compressed, `create_heatmap_for_file` will 76 | # take care of compressing it. 77 | 78 | curl "${CURL_DEFAULT_OPTIONS[@]}" "$1" &> /dev/null 1> "$tmpFile" \ 79 | && create_heatmap_for_file "$tmpFile" "$2" 80 | 81 | } 82 | 83 | create_tmp_file() { 84 | printf "%s" "$(mktemp /tmp/XXXXX)" 85 | } 86 | 87 | get_file_mime_type() { 88 | printf "%s" "$(file "$1" --brief --mime-type)" 89 | } 90 | 91 | get_image_name() { 92 | printf "%s.png" "$(printf "%s" "$1" | sed 's/[^a-zA-Z0-9]/-/g')" 93 | } 94 | 95 | get_script_path() { 96 | 97 | declare -r os_name="$(uname -s)" 98 | local path="$1" 99 | 100 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 101 | 102 | if [ "$os_name" == "Darwin" ]; then 103 | path="$path/macos" 104 | elif [ "$os_name" == "Linux" ]; then 105 | path="$path/linux" 106 | 107 | if [ "$(uname -m)" == "x86_64" ]; then 108 | path="${path}-64" 109 | else 110 | path="${path}-31" 111 | fi 112 | fi 113 | 114 | printf "%s" "$(dirname "${BASH_SOURCE[0]}")/$path" 115 | 116 | } 117 | 118 | open_image() { 119 | 120 | # The order of the following checks matters as 121 | # on Ubuntu there is also a utility called `open`. 122 | 123 | if cmd_exists "xdg-open"; then 124 | xdg-open "$1" 125 | elif cmd_exists "open"; then 126 | open "$1" 127 | fi 128 | 129 | } 130 | 131 | print_error() { 132 | printf " [✖] %s\n" "$1" 133 | } 134 | 135 | print_result() { 136 | 137 | if [ "$1" -eq 0 ]; then 138 | print_success "$2" 139 | else 140 | print_error "$2" 141 | fi 142 | 143 | return "$1" 144 | 145 | } 146 | 147 | print_success() { 148 | printf " [✔] %s\n" "$1" 149 | } 150 | 151 | # ---------------------------------------------------------------------- 152 | 153 | main() { 154 | 155 | # Check if `cURL` is installed 156 | 157 | if ! cmd_exists "curl"; then 158 | printf "cURL is required, please install it!\n" 159 | exit 1 160 | fi 161 | 162 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 163 | 164 | local imageFile="" 165 | 166 | gzthermal="$(get_script_path "gzthermal")" 167 | pngthermal="$(get_script_path "pngthermal")" 168 | 169 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 170 | 171 | while [ $# -ne 0 ]; do 172 | 173 | imageFile="$(get_image_name "$1")" 174 | 175 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 176 | 177 | # Check if the current command 178 | # line argument is a local file. 179 | 180 | if [ -f "$1" ]; then 181 | 182 | if [ "$(get_file_mime_type "$1")" != "image/png" ]; then 183 | create_heatmap_for_file "$1" "$imageFile" 184 | else 185 | create_heatmap_for_png "$1" "$imageFile" 186 | fi 187 | 188 | # If it's not, assume it is a URL. 189 | 190 | else 191 | create_heatmap_for_webpage "$1" "$imageFile" 192 | fi 193 | 194 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 195 | 196 | print_result $? "$1" \ 197 | && open_image "$imageFile" 198 | 199 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 200 | 201 | # Opening too many images really 202 | # quickly makes macOS' Preview crash. 203 | 204 | sleep 0.2 205 | 206 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 207 | 208 | shift 209 | 210 | done 211 | 212 | } 213 | 214 | main "$@" 215 | -------------------------------------------------------------------------------- /src/shell/bash_prompt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4 | 5 | enable_color_support() { 6 | 7 | if [[ $COLORTERM == gnome-* && $TERM == xterm ]] \ 8 | && infocmp gnome-256color &> /dev/null; then 9 | export TERM="gnome-256color" 10 | elif infocmp xterm-256color &> /dev/null; then 11 | export TERM="xterm-256color" 12 | fi 13 | 14 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 15 | 16 | # Load OS specific color support. 17 | 18 | . "$OS/bash_colors" 19 | 20 | } 21 | 22 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 23 | 24 | # [!] Don't break this function into smaller, more specialized ones 25 | # as you will only pollute the global space even more. This function 26 | # cannot be unset because it's called every time the prompt string 27 | # is shown. 28 | 29 | get_git_repository_details() { 30 | 31 | local branchName="" 32 | local tmp="" 33 | 34 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 35 | 36 | # Check if the current directory is in a Git repository. 37 | 38 | ! git rev-parse &>/dev/null \ 39 | && return 40 | 41 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 42 | 43 | # Check if in `.git/` directory (some of the following 44 | # checks don't make sense/won't work in the `.git` directory). 45 | 46 | [ "$(git rev-parse --is-inside-git-dir)" == "true" ] \ 47 | && return 48 | 49 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 50 | 51 | # Check for uncommitted changes in the index. 52 | 53 | if ! git diff --quiet --ignore-submodules --cached; then 54 | tmp="$tmp+"; 55 | fi 56 | 57 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 58 | 59 | # Check for unstaged changes. 60 | 61 | if ! git diff-files --quiet --ignore-submodules --; then 62 | tmp="$tmp!"; 63 | fi 64 | 65 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 66 | 67 | # Check for untracked files. 68 | 69 | if [ -n "$(git ls-files --others --exclude-standard)" ]; then 70 | tmp="$tmp?"; 71 | fi 72 | 73 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 74 | 75 | # Check for stashed files. 76 | 77 | if git rev-parse --verify refs/stash &>/dev/null; then 78 | tmp="$tmp$"; 79 | fi 80 | 81 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 82 | 83 | [ -n "$tmp" ] \ 84 | && tmp=" [$tmp]" 85 | 86 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 87 | 88 | branchName="$( printf "%s" "$( git rev-parse --abbrev-ref HEAD 2> /dev/null \ 89 | || git rev-parse --short HEAD 2> /dev/null \ 90 | || printf " (unknown)" )" | \ 91 | tr -d "\n" )" 92 | 93 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 94 | 95 | printf "%s" "$1$branchName$tmp" 96 | 97 | } 98 | 99 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 100 | 101 | set_prompts() { 102 | 103 | local bold=$(tput bold 2> /dev/null) 104 | local reset=$(tput sgr0 2> /dev/null) 105 | 106 | local cyan="" 107 | local green="" 108 | local orange="" 109 | local white="" 110 | local yellow="" 111 | 112 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 113 | 114 | if [ "$(tput colors 2> /dev/null || printf "0")" -ge 256 ]; then 115 | 116 | # Solarized colors. 117 | # https://github.com/altercation/solarized/tree/master/iterm2-colors-solarized#the-values 118 | 119 | cyan=$(tput setaf 37) 120 | green=$(tput setaf 64) 121 | orange=$(tput setaf 166) 122 | white=$(tput setaf 15) 123 | yellow=$(tput setaf 136) 124 | 125 | fi 126 | 127 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 128 | 129 | # Prompt Statement variables. 130 | # http://ss64.com/bash/syntax-prompt.html 131 | 132 | # ------------------------------------------------------------------ 133 | # | PS1 - Default interactive prompt | 134 | # ------------------------------------------------------------------ 135 | 136 | PS1="\[\033]0;\W\007\]" # Terminal title (set to the 137 | # current working directory) 138 | 139 | PS1+="$reset$bold" 140 | PS1+="$orange\u" # Username 141 | PS1+="$white@" 142 | PS1+="$yellow\h" # Host 143 | PS1+="$white: " 144 | PS1+="$green\w" # Working directory 145 | PS1+="\$(get_git_repository_details \"$white on $cyan\")" 146 | PS1+="\n" 147 | PS1+="\[$reset\]\[$white\]$ \[$reset\]" 148 | 149 | export PS1 150 | 151 | # ------------------------------------------------------------------ 152 | # | PS2 - Continuation interactive prompt | 153 | # ------------------------------------------------------------------ 154 | 155 | PS2="⚡ " 156 | 157 | export PS2 158 | 159 | # ------------------------------------------------------------------ 160 | # | PS4 - Debug prompt | 161 | # ------------------------------------------------------------------ 162 | 163 | # e.g: 164 | # 165 | # The GNU `date` command has the `%N` interpreted sequence while 166 | # other implementations don't (on macOS `gdate` can be used instead 167 | # of the native `date` if the `coreutils` package has been installed). 168 | # 169 | # local dateCmd="" 170 | # 171 | # if [ "$(date +%N)" != "N" ] || \ 172 | # [ ! -x "$(command -v "gdate")" ]; then 173 | # dateCmd="date +%s.%N" 174 | # else 175 | # dateCmd="gdate +%s.%N" 176 | # fi 177 | # 178 | # PS4="+$( tput cr && tput cuf 6 && 179 | # printf "$yellow %s $green%6s $reset" "$($dateCmd)" "[$LINENO]" )" 180 | # 181 | # PS4 output: 182 | # 183 | # ++ 1357074705.875970000 [123] '[' 1 == 0 ']' 184 | # └──┬─┘└────┬───┘ └───┬───┘ └──┬─┘ └──────┬─────┘ 185 | # │ │ │ │ │ 186 | # │ │ │ │ └─ command 187 | # │ │ │ └─ line number 188 | # │ │ └─ nanoseconds 189 | # │ └─ seconds since 1970-01-01 00:00:00 UTC 190 | # └─ depth-level of the subshell 191 | 192 | PS4="+$( tput cr 2> /dev/null; 193 | tput cuf 6 2> /dev/null; 194 | printf "%s" "$reset" )" 195 | 196 | export PS4 197 | 198 | } 199 | 200 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 201 | 202 | main() { 203 | enable_color_support 204 | set_prompts 205 | } 206 | 207 | main 208 | 209 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 210 | 211 | # Cleanup. 212 | 213 | unset -f enable_color_support 214 | unset -f main 215 | unset -f set_prompts 216 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [Cătălin][repo]’s dotfiles 2 | 3 | [![CI status for macOS][ci badge macos]][ci link macos] 4 | [![CI status for Ubuntu][ci badge ubuntu]][ci link ubuntu] 5 | 6 | These are the base dotfiles that I start with when I set up 7 | a new environment (for more specific local needs I use the 8 | [`*.local`](#local-settings) files). 9 | 10 | ## Table of Contents 11 | 12 | * [🔧 Setup](#setup) 13 | * [📸 Screenshots](#screenshots) 14 | * [🔁 Git](#git) 15 | * [⌨️ Vim](#vim) 16 | * [💄 Customize](#customize) 17 | * [🔀 Forks](#forks) 18 | * [🌐 Local Settings](#local-settings) 19 | * [🐚 `~/.bash.local`](#bashlocal) 20 | * [🔁 `~/.gitconfig.local`](#gitconfiglocal) 21 | * [⌨️ `~/.vimrc.local`](#vimrclocal) 22 | * [↕️ Update](#update) 23 | * [📑 License](#license) 24 | 25 | ## Setup 26 | 27 | To set up the dotfiles run the appropriate snippet in the terminal: 28 | 29 | > [!CAUTION] 30 | > __DO NOT__ run the setup script if you do not fully understand 31 | > [what it does][setup]. Seriously, __DON'T__! 32 | 33 | | OS | Snippet | 34 | |:---|:---| 35 | | macOS | `bash -c "$(curl -LsS https://raw.github.com/alrra/dotfiles/main/src/os/setup.sh)"` | 36 | | Ubuntu | `bash -c "$(wget -qO - https://raw.github.com/alrra/dotfiles/main/src/os/setup.sh)"` | 37 | 38 | That's it! ✨ 39 | 40 | The setup process will: 41 | 42 | * Download the dotfiles on your computer 43 | (by default it will suggest `~/projects/dotfiles`). 44 | * [Symlink][symlink] the [Git], [shell], [tmux], 45 | and [Vim] related files. 46 | * Install applications / command-line tools for 47 | [macOS][install macos] / [Ubuntu][install ubuntu]. 48 | * Set custom [macOS][preferences macos] / 49 | [Ubuntu][preferences ubuntu] preferences. 50 | * Install the [Vim][vim plugins] and 51 | [VS Code][vscode plugins] plugins. 52 | 53 | Setup process in action: 54 | 55 | 56 | |