{"id":20047026,"url":"https://github.com/bartste/dotfiles-windows","last_synced_at":"2025-05-05T10:31:09.050Z","repository":{"id":39365769,"uuid":"436931248","full_name":"BartSte/dotfiles-windows","owner":"BartSte","description":"My dotfiles for windows 11","archived":false,"fork":false,"pushed_at":"2025-03-11T05:08:34.000Z","size":17856,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-05T02:48:59.406Z","etag":null,"topics":["chocolately","powershell","vim","vscode","windows-11"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BartSte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-10T10:01:19.000Z","updated_at":"2025-03-11T05:08:37.000Z","dependencies_parsed_at":"2023-09-29T08:21:48.024Z","dependency_job_id":"f6972140-9916-42f4-aa53-9a0237380dde","html_url":"https://github.com/BartSte/dotfiles-windows","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BartSte%2Fdotfiles-windows","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BartSte%2Fdotfiles-windows/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BartSte%2Fdotfiles-windows/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BartSte%2Fdotfiles-windows/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BartSte","download_url":"https://codeload.github.com/BartSte/dotfiles-windows/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252480413,"owners_count":21754772,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chocolately","powershell","vim","vscode","windows-11"],"created_at":"2024-11-13T11:33:04.572Z","updated_at":"2025-05-05T10:31:09.042Z","avatar_url":"https://github.com/BartSte.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# Dotfiles BartSte\n\nThis readme is relevant for the following dotfiles repositories:\n\n- BartSte/dotfiles\n- BartSte/dotfiles-linux\n- BartSte/doffiles-windows\n\nPlease read the following sections to get started with this repository. The\nexamples below are writing in bash and powershell.\n\n## Dotfiles (cross-platform)\n\n- No initialization needed. It only contains static dotfiles. Typically, you\n  will not clone this repository by yourself, instead it will be cloned for you\n  by the `dotfiles-linux` or the `dotfiles-windows` repositories, as they depend\n  on it.\n\n### Neovim (`dotfiles/nvim`)\n\nSome directories of the neovim configuration could use some explanation:\n\n- `dotfiles/nvim/lua`:\n  - `helpers`: helper functions that are used in the other lua files.\n  - `plugins`: plugins that are loaded by lazy.nvim\n  - `config`: plugin configuration files.\n- `dotfiles/nvim/vim`: plugin configuration files in vimscript.\n- `dotfiles/nvim/plugin`: non-plugin configuration files that must be sourced\n  before `after/plugin`.\n- `dotfiles/nvim/after/plugin`: non-plugin configuration files.\n- `dotfiles/nvim/after/ftplugin`: configuration files that are loaded after the\n  filetype is detected.\n\n## Dotfiles-linux (Arch linux)\n\n### Installation\n\n- To initialize the repository run the following line in a bash shell:\n\n```bash\ncurl -O https://raw.githubusercontent.com/BartSte/dotfiles-linux/master/dotfiles-linux/initialize \u0026\u0026 bash ./initialize; rm ./initialize\n```\n\n- Complete the environment variables in `~/.dotfiles_config.sh`.\n- Run the script: `~/dotfiles-linux/main`\n- Afterwards, authenticate for:\n  - Mutt\n  - Khal \u0026 khalorg\n\n### Bitwarden\n\nI use Bitwarden to store my passwords. The Bitwarden CLI can be used to\nretrieve passwords from the command line. However, Bitwarden CLI has the issue\nthat is hangs for a second before it executes the command. Furthermore, a token\nneeds to be stored as an environment variable. Therefore, I use `rbw` which is\nthe unofficial Bitwarden CLI. The downside is that it is maintained by\nvolunteers which have limited time to fix bugs. As a solution, I created\n`bw-cli-get`, whick can be used to get entries from the bitwarden vault. By\ndefault, it uses `rbw`. If you set the environment variable `USE_BW_CLI`, then\nit will use the official Bitwarden CLI `bw`.\n\n### Mutt\n\nI have two email accounts: personal and work. On all my devices, I only use one\nof the two accounts. I have 1 muttrc file for both accounts. The differences in\nconfiguration are handled by calling my password manager (rbw). The following\nfields may be handled differently for each account:\n\n- password: this is the password of the email account\n- username: this is the username of the email account\n- domain: this is the domain of the email account\n- name: this is my real name\n- calendar: this is the calendar that is used by khal\n- contacts: this is the contacts that are used by khard\n- MuttImapAuth: this is the imap auth method\n- MuttClientId: this is the client id of the oauth2 script\n- MuttSmtpAuth: this is the smtp auth method\n- MuttPassword: this is the app password generated by Microsoft\n- Signature (is added to the notes section of rbw)\n\nWhich account I am using, is determined by setting the environment variable\n`MICROSOFTACCOUNT` to `MicrosoftPersonal` or `MicrosoftWork`. This variable is\nset in the `.dotfiles_config.sh` file that is created when initializing the\n`dotfiles-linux` repository.\n\nThe next sections explain the following:\n\n- Authentication: how to authenticate the email accounts.\n- Synchronization: how to sync the email accounts using IMAP and `mbsync`.\n- Sending: how to send emails using SMTP and `mutt_oauth2`.\n- Search: how to search through emails using `notmuch`.\n- Mailsync: 1 command to sync and index all emails.\n\n#### Authentication\n\nAuthentication can be done in three ways: using an app password (generated by\nthe email provider), using `davmail`, or using the `mutt_oauth2` script. The\napp password is the easiest way but is not supported by all email providers\nanymore. The oauth2 method is more complicated but is supported by most email\nproviders. Davmail is hard to setup, and it is difficult to debug when things\ngo wrong, so I use it as a last resort.\n\n##### App password\n\nFor my personal email account, I use an app password. This password can be\ngenerated by the email provider. Once it is obtained, it is added to the\npassword manager, at the field `MuttPassword`, which is supplied to the\n`imap_pass` and `smtp_pass` fields in the `.muttrc` file. Furthermore, the\n`MuttImapAuth` and `MuttSmtpAuth` fields are set to `login`.\n\n##### Davmail\n\nDavmail is a gateway that can be used to connect to exchange servers. It can be\nused to connect to the exchange server using, among others, IMAP.\n\nIn the past, I used davmail to connect to the exchange server. Now I use\n`mutt_oauth2`, but it is good to keep `davmail` as a backup option.\nFurthermore, davmail was also needed for khalorg and khard, so I had to\nset it up anyway. Initializing davmail can be done as follows:\n\n- The davmail configuration is located in the `dotfiles-linux/davmail` file. By\n  running the `main` script in this folder, the davmail configuration is copied\n  to the `~/.config/davmail` folder. Copying is needed because the davmail\n  stores tokens in the config file so we do not want to put this on git.\n\n- Next, run the following commands to start davmail:\n\n  ```bash\n  davmail ~/.config/davmail/davmail.properties\n  ```\n\n- Open another shell and run the following command:\n\n  ```bash\n  mbsync -a\n  ```\n\n- Head back to shell 1 and follow the instructions. If you are prompted with a\n  message that states that \"interactive\" mode is not supported, you can change\n  the davmail.properties setting `davmail.mode=O365Interactive` to\n  `davmail.mode=O365Manual`.\n\n- Once this step is succeeded, `mbsync` will start doing its work. The refresh\n  token is stored in the `~/.config/davmail/davmail.properties` file. If this\n  file is removed, the authentication process has to be repeated.\n\n##### Oauth2\n\nFor my work email account, I use oauth2 for synchronizing my mailbox (IMAP) and\nsending emails (SMTP) because the app password is not supported anymore.\n\nThe following steps are needed to get oauth2 working:\n\n- Checkout the `dotfiles-linux/bin/mutt_oauth2` script. This script is used\n  to initialize and refresh the oauth2 token.\n- I got the script working by registering an application at Azure as described\n  in the README at `dotfiles-linux/mutt/README.md`. I used the client_id from\n  the `overview` page. I added the client_id and my email address to the\n  password manager at the `MuttClientId` field. Next, I called the password\n  manager from the `mutt_oauth2` scrip.\n- I created 1 bash script that does the initialization for you:\n  `dotfiles-linux/mutt/init_mutt_oauth2`. This script can be called once to\n  initialize the `mutt_oauth2` script.\n- I also created 1 bash script that uses the correct token:\n  `dotfiles-linux/mutt/mutt_oauth2_with_token`.\n- The `mutt_oauth2_with_token` script is added to the `mbsync` config file to\n  enable imap authentication. See the section\n  [Synchronization](#synchronization).\n- The `mutt_oauth2_with_token` was also added `smtp_oauth_refresh_command` in\n  my `.muttrc` file, to enable smtp authentication. See the section\n  [Sending](#sending).\n\n#### Synchronization\n\nFor IMAP synchronization, there are basically two options: use the built-in\nIMAP synchronization of neomutt or use an external tool. When using the\nformer, the emails are not downloaded to your local machine. Instead, the\nemails are downloaded on the fly when you open a folder. This is not ideal\nwhen you want to search through your emails fast. Therefore, I use an external\ntool: `mbsync` (part of the `isync` package). This tool operates next to\nneomutt and downloads the emails to your local machine in `Maildir` format. I\nhave two config files for `mbsync`: `personal` and `work`. Based on the value\nof the environment variable `MICROSOFTACCOUNT`, the correct config file is\nused. The config files are located in `~/dotfiles-linux/isync`.\n\nFor my personal email account, I use an app password for authentication. For\nmy work email account, I use `mutt_oauth2` for authentication. To enable\nXOAUTH2 for `mbsync`, I added the following package from the AUR:\n`cyrus-sasl-xoauth2-git`.\n\n#### Sending\n\nFor sending emails, I use the built-in SMTP functionality of neomutt. The smtp\nurl is set in the `.muttrc` file and is dependent on the value of the\n`username` field in the password manager. Authentication is done using the\n`mutt_oauth2` script. The `mutt_oauth2` script is called by the\n`smtp_oauth_refresh_command` field in the `.muttrc` file. This field is set to\nthe `mutt_oauth2_with_token` script.\n\n#### Search\n\nFor searching through emails, I use `notmuch`. Neomutt has built-in support for\n`notmuch`, so it can be configured in the `.muttrc` file together with the\n`.notmuch-config` file. I added a keybinding to a global search to my `.muttrc`\nfile. This keybinding calls the `notmuch search` command and is bound to the\n`alt+A` key. The notmuch database can be updated by calling the `notmuch new`\ncommand.\n\n#### Mailsync\n\n`davmail`, `mbsync` and `notmuch` are combined into 1 command: `mailsync`.\nThis makes updating the emails easier. Note that no davmail is needed when\nusing an app password or `mutt_oauth2`, so it is only activated when a davmail\nconfig is presented as an argument.\n\n### khal \u0026 khalorg\n\nI use my work office calendar for all devices such that I have 1 calendar for\nall meetings. The calendar is synchronized with a local directory using\n`vdirsyncer`. This directory is then used by `khal` to interact with the\ncalendar. Since I like to use `org-mode`, I build an interface between `khal`\nand `org-mode` called `khalorg`.\n\n`vdirsyncer` can communicate with the exchange server using davmail. To initialize\ndavmail, see the [Davmail](#davmail) section. Once davmail is initialized, run\nthe following command to synchronize the calendar:\n\n```bash\n~/dotfiles-linux/khal/main\n~/dotfiles-linux/khalorg/main\nvdirsyncer discover\nmycalsync\n```\n\nhere, `mycalsync` is a script that combines `davmail`, `vdirsyncer`, `khalorg`.\nAs a results, it synchronizes my office calendar with a local org file that\nholds all my meetings as text.\n\n### khard\n\n`khard` is a contact manager that can be used to interact with the exchange\nserver when it is used in combination with `davmail` and `vdirsyncer`. Once you\nhave setup `davmail` and `vdirsyncer` as described in the sections above, `khard`\nwill also be synced when het `mycalsync` script is called. You can check if\n`khard` is working by running the following command:\n\n```bash\nkhard list\n```\n\n#### Setting up OpenVino + GPU\n\nI had some issue making OpenVino detect my GPU (Intel UHD Graphics 620). The\nfollowing solved the issue:\n\n```bash\nsudo pacman -S level-zero-headers level-zero-loader intel-graphics-compiler\nyay -S ocl-icd intel-opencl\n```\n\n#### Pinentry endless password input\n\nI need do set many passwords: login, rbw, mail. I want to set 1 password for\nall apps and I want to enter just 1 password. I still want to be able to use\npinentry for other apps in the future I guess. One hacky way could be:\n\n- Create a personal `pinentry` program and put it at the front of the PATH.\n- Check who is calling: if it is rbw or mail, echo the password (in the format\n  pinentry expects). Otherwise, call the real pinentry program.\n\n- Note, when possible, it is easier to do:\n\n```bash\nrbg get field | gpg --pinentry-mode loopback --batch --passphrase-fd 0 -d ./foo.txt.gpg\n```\n\nThis will read the password from stdin, instead of using pinentry. This cannot\nbe done when you have no access to the command that is calling gpg.\n\n### DNS\n\nCustom DNS servers are set manually. This is done by disabling the\n`systemd-resolved` service and enabling `NetworkManager`. Next, by setting\n`dns=none` in het `[main]` section of the `NetworkManager.conf` file, the\n`/etc/resolv.conf` file is not overwritten by `NetworkManager`. Now, we can\ndefine the DNS servers ourselves. These server will be used by all connections.\n\n### Productivity\n\nIn relation to the [dns](#dns) section, we can lock the DNS settings to prevent\nthem from being changed. This is useful when the dns servers act as an internet\nfilter, e.g., blocking pornographic websites. It works as follows:\n\n- The `/etc/sudoers` file is set to:\n\n  ```bash\n  Defaults!/usr/bin/chattr rootpw\n  %wheel ALL=(ALL) NOPASSWD: ALL, !/usr/bin/chattr\n  ```\n\n  Which means that the users in the wheel group can use `sudo` without a\n  password, except for the `chattr` command. This command can only be executed\n  from the root account.\n\n- By logging in to the root account and running the `lock` script, the following\n  files will be made immutable:\n\n  - `/etc/sudoers` -\u003e protects the `chattr` command\n  - `/etc/resolv.conf` -\u003e holds the DNS servers\n  - `/etc/NetworkManager/NetworkManager.conf` -\u003e holds the NetworkManager config\n\n  By setting the root password to a long complex password, it will discourage\n  you from changing the files.\n\n- The `unlock` script can be used to make the files mutable again. This script\n  can only be executed by the root account.\n\n### Dotfiles-windows (Windows 10 \u0026 11)\n\n- To initialize the repository copy the following line into powershell:\n\n```powershell\nSet-ExecutionPolicy Bypass -Scope Process -Force;\n[bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match \"S-1-5-32-544\");\n[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;\niex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/BartSte/dotfiles-windows/master/dotfiles-windows/initialize.ps1'))\n```\n\n- Complete the configuration file in `$HOME/dotfiles-windows/config.ps1`.\n- Run the script: `$HOME/dotfiles-windows/main.ps1`\n- All the subfolders of `$HOME/dotfiles-windows` are executed by calling the\n  `main.ps1` file, e.g., `$HOME/dotfiles-windows/powershell/main.ps1`.\n\n#### Alacritty\n\nAt the moment of this writing, Alacritty + tmux has issue rendering icons. This\nis because Alacritty does not use the newest version of conPTY and\nOpenConsole. Funny thing is, that when you install WezTerm on your machine, the\nissue is solved. This is because WezTerm uses the newest version of conPTY and\nOpenConsole. So you can either do this, or extract the conpty.dll and\nOpenConsole.exe from the WezTerm installation and place them around the\nalacritty.exe executable (and later remove wezterm).\n\n## Background\n\nThe following sections explain how the 3 repositories work together.\n\n### Bare repository\n\nThe text below was inspired on the following article of [atlassian](https://www.atlassian.com/git/tutorials/dotfiles). This article will also explain the difference between a normal repository and a bare repository.\n\nClone the project (dotfiles, dotfiles-linux, or dotfiles-windows) into a bare\nrepository. I will call the bare repository: `dotfiles.git`:\n\n```powershell\ngit clone --bare \u003cgit-repo-url\u003e $HOME/dotfiles.git\n```\n\nAdd the following alias to your .bashrc:\n\n```bash\nalias base='/usr/bin/git --git-dir=$HOME/dotfiles.git/ --work-tree=$HOME'\n```\n\nOr to your $PSHome/profile.ps1:\n\n```powershell\n${function:base} = { git.exe --git-dir=$HOME\\dotfiles.git\\ --work-tree=$HOME @args }\n```\n\nwhere `base` can be replaced by a name you prefer, while the folder\n`dotfiles.git` is the directory holding the bare repository.\n\nCheckout the actual content from the bare repository to your $HOME:\n\n```bash\nbase checkout\n```\n\nThe step above might fail with a message like:\n\n```\nerror: The following untracked working tree files would be overwritten by checkout:\n    README.md\n    .gitignore\nPlease move or remove them before you can switch branches.\nAborting\n```\n\nThis is because your `$HOME` folder might already have some stock configuration\nfiles which would be overwritten by git. The solution is simple: back up the\nfiles if you care about them, remove them if you don't care, and try again.\n\nSet the flag showUntrackedFiles to no on this specific (local) repository:\n\n```bash\nbase config --local status.showUntrackedFiles no\n```\n\nYou're done, from now on you can now type `base` commands to add and update\nyour dotfiles:\n\n```base\nbase status\nbase add README.md\nbase commit -m \"Add README.md\"\nbase push\n```\n\n### Multiple layers\n\nUsing a bare repository allows you to working on multiple repositories in the\nsame folder. For dotfiles this is typically the `$HOME` folder. As such, the\nrepositories `dotfiles` `dotfiles-linux`, and `dotfiles-windows` should all be\ncreated in a bare repository in the `$HOME` folder. I call them\n`\u003crepo-name\u003e.git`. Here, the repository `dotfiles.git` can be interpreted as\nthe base layer, containing dotfiles that are cross-platform. On top of that, a\nlinux layer can be added, i.e., the `dotfiles-linux.git` bare repository. As an\nexample, the following code adds a file `.foo` to the `dotfiles` repository\n(using the alias `base`), and a file `.bar` to the `dotfiles-linux` repostory\n(using the alias `lin`):\n\n```bash\nbase add .foo\nlin add .bar\nbase commit -m \"Add .foo\"\nlin commit -m \"Add .bar\"\nbase push\nlin push\n```\n\nYou will always need the base layer `dotfiles`. On top of that you can add an\nOS specific repostory: `dotfiles-linux` or `dotfiles-windows`.\n\n## References\n\nThis repos are inspired on the following projects:\n\n- [dotfiles for windows](https://github.com/jayharris/dotfiles-windows)\n- [polybar-connection](https://github.com/BartSte/polybar-collection)\n- [polybar-bluetooth](https://github.com/msaitz/polybar-bluetooth)\n- [mutt-oauth2](https://github.com/muttmua/mutt/blob/master/contrib/mutt_oauth2.py)\n- [tmux-sessionizer](https://github.com/ThePrimeagen/.dotfiles/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbartste%2Fdotfiles-windows","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbartste%2Fdotfiles-windows","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbartste%2Fdotfiles-windows/lists"}