refactor: delete old Ansible configuration

- Remove the Ansible files.
- Move the Nix files to the root level of the repository.

Refs: #39
This commit is contained in:
Oliver Davies 2022-12-20 19:58:39 +00:00
parent a2bded636e
commit 7235dc60dd
98 changed files with 28 additions and 1660 deletions

View file

@ -1,3 +0,0 @@
[defaults]
become = true
inventory = ./hosts.ini

View file

@ -1,47 +0,0 @@
default_roles:
- awesome-wm
- cargo
- copyq
- ctop
- dconf
- debugger
- delta
- discord
- docker
- filezilla
- flameshot
- fonts
- fzf
- git
- github-cli
- github-desktop
- gnome-tweak-tools
- google-chrome
- htop
- jq
- kdenlive
- mysql-client
- notion-app
- npm
- obs-studio
- pdf-arranger
- platformsh-cli
- pocketcasts
- postman
- projects
- pulumi
- pv
- ripgrep
- skype
- slack
- ssh
- stylua
- tldr
- tmux
- tmuxinator
- todoist
- tree
- vlc
- zoom
- zsh
- zsh-antigen

View file

@ -38,8 +38,9 @@
zoxide zoxide
# LSP # LSP
gopls
html-tidy html-tidy
nodePackages."@ansible/ansible-language-server" # nodePackages."@ansible/ansible-language-server"
nodePackages."@tailwindcss/language-server" nodePackages."@tailwindcss/language-server"
nodePackages.bash-language-server nodePackages.bash-language-server
nodePackages.dockerfile-language-server-nodejs nodePackages.dockerfile-language-server-nodejs
@ -71,11 +72,23 @@
owner = "phpactor"; owner = "phpactor";
repo = "phpactor"; repo = "phpactor";
rev = "master"; rev = "master";
sha256 = "j2rGPMiST85feqk5Nj4KrjxyhfbUjYEKAec+bzPEJZQ="; sha256 = "0bgfwidrlaqxnjmk14gqc8b0mxh0c5xf098qcjz9mvw236n88xl7";
};
};
vim-astro = pkgs.vimUtils.buildVimPlugin {
name = "vim-astro";
src = pkgs.fetchFromGitHub {
owner = "wuelnerdotexe";
repo = "vim-astro";
rev = "main";
sha256 = "HyQ4i/T1uQmGurBqCpo8+ESVSVPsTrLQBxLe2OEYjcY=";
}; };
}; };
in in
with pkgs.vimPlugins; [ with pkgs.vimPlugins; [
vim-astro
comment-nvim comment-nvim
git-worktree-nvim git-worktree-nvim
gitsigns-nvim gitsigns-nvim
@ -110,7 +123,6 @@
null-ls-nvim null-ls-nvim
nvim-lspconfig nvim-lspconfig
lsp-status-nvim lsp-status-nvim
phpactor
# Completion # Completion
cmp-buffer cmp-buffer
@ -135,13 +147,18 @@
telescope-nvim telescope-nvim
telescope-ui-select-nvim telescope-ui-select-nvim
# Git
# neogit
# Databases # Databases
vim-dadbod vim-dadbod
vim-dadbod-ui vim-dadbod-ui
vim-dadbod-completion vim-dadbod-completion
# Themes # Themes
catppuccin-nvim
nightfox-nvim nightfox-nvim
onehalf
]; ];
}; };

View file

@ -1,2 +0,0 @@
[localhost]
127.0.0.1 ansible_connection=local

View file

@ -1,23 +0,0 @@
---
- hosts: localhost
tasks:
- name: Set roles
ansible.builtin.set_fact:
roles: "{{ ansible_run_tags != ['all'] and ansible_run_tags or default_roles | difference(exclude_roles | default([])) }}"
tags:
- always
- name: Display roles
ansible.builtin.debug: "var=roles"
tags:
- always
- name: Run roles
ansible.builtin.include_role:
name: "{{ item }}"
apply:
tags:
- "{{ item }}"
with_items: "{{ roles }}"
tags:
- always

View file

@ -1,14 +0,0 @@
{
"nixpkgs": {
"branch": "release-21.05",
"description": "Nix Packages collection",
"homepage": "",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5f244caea76105b63d826911b2a1563d33ff1cdc",
"sha256": "1xlgynfw9svy7nvh9nkxsxdzncv9hg99gbvbwv3gmrhmzc3sar75",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/5f244caea76105b63d826911b2a1563d33ff1cdc.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}

View file

@ -1,194 +0,0 @@
# This file has been generated by Niv.
let
#
# The fetchers. fetch_<type> fetches specs of type <type>.
#
fetch_file = pkgs: name: spec:
let
name' = sanitizeName name + "-src";
in
if spec.builtin or true then
builtins_fetchurl { inherit (spec) url sha256; name = name'; }
else
pkgs.fetchurl { inherit (spec) url sha256; name = name'; };
fetch_tarball = pkgs: name: spec:
let
name' = sanitizeName name + "-src";
in
if spec.builtin or true then
builtins_fetchTarball { name = name'; inherit (spec) url sha256; }
else
pkgs.fetchzip { name = name'; inherit (spec) url sha256; };
fetch_git = name: spec:
let
ref =
if spec ? ref then spec.ref else
if spec ? branch then "refs/heads/${spec.branch}" else
if spec ? tag then "refs/tags/${spec.tag}" else
abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!";
submodules = if spec ? submodules then spec.submodules else false;
submoduleArg =
let
nixSupportsSubmodules = builtins.compareVersions builtins.nixVersion "2.4" >= 0;
emptyArgWithWarning =
if submodules == true
then
builtins.trace
(
"The niv input \"${name}\" uses submodules "
+ "but your nix's (${builtins.nixVersion}) builtins.fetchGit "
+ "does not support them"
)
{}
else {};
in
if nixSupportsSubmodules
then { inherit submodules; }
else emptyArgWithWarning;
in
builtins.fetchGit
({ url = spec.repo; inherit (spec) rev; inherit ref; } // submoduleArg);
fetch_local = spec: spec.path;
fetch_builtin-tarball = name: throw
''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`.
$ niv modify ${name} -a type=tarball -a builtin=true'';
fetch_builtin-url = name: throw
''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`.
$ niv modify ${name} -a type=file -a builtin=true'';
#
# Various helpers
#
# https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695
sanitizeName = name:
(
concatMapStrings (s: if builtins.isList s then "-" else s)
(
builtins.split "[^[:alnum:]+._?=-]+"
((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name)
)
);
# The set of packages used when specs are fetched using non-builtins.
mkPkgs = sources: system:
let
sourcesNixpkgs =
import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; };
hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath;
hasThisAsNixpkgsPath = <nixpkgs> == ./.;
in
if builtins.hasAttr "nixpkgs" sources
then sourcesNixpkgs
else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then
import <nixpkgs> {}
else
abort
''
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
add a package called "nixpkgs" to your sources.json.
'';
# The actual fetching function.
fetch = pkgs: name: spec:
if ! builtins.hasAttr "type" spec then
abort "ERROR: niv spec ${name} does not have a 'type' attribute"
else if spec.type == "file" then fetch_file pkgs name spec
else if spec.type == "tarball" then fetch_tarball pkgs name spec
else if spec.type == "git" then fetch_git name spec
else if spec.type == "local" then fetch_local spec
else if spec.type == "builtin-tarball" then fetch_builtin-tarball name
else if spec.type == "builtin-url" then fetch_builtin-url name
else
abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}";
# If the environment variable NIV_OVERRIDE_${name} is set, then use
# the path directly as opposed to the fetched source.
replace = name: drv:
let
saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name;
ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}";
in
if ersatz == "" then drv else
# this turns the string into an actual Nix path (for both absolute and
# relative paths)
if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}";
# Ports of functions for older nix versions
# a Nix version of mapAttrs if the built-in doesn't exist
mapAttrs = builtins.mapAttrs or (
f: set: with builtins;
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set))
);
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295
range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1);
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257
stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1));
# https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269
stringAsChars = f: s: concatStrings (map f (stringToCharacters s));
concatMapStrings = f: list: concatStrings (map f list);
concatStrings = builtins.concatStringsSep "";
# https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331
optionalAttrs = cond: as: if cond then as else {};
# fetchTarball version that is compatible between all the versions of Nix
builtins_fetchTarball = { url, name ? null, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchTarball;
in
if lessThan nixVersion "1.12" then
fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else
fetchTarball attrs;
# fetchurl version that is compatible between all the versions of Nix
builtins_fetchurl = { url, name ? null, sha256 }@attrs:
let
inherit (builtins) lessThan nixVersion fetchurl;
in
if lessThan nixVersion "1.12" then
fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; }))
else
fetchurl attrs;
# Create the final "sources" from the config
mkSources = config:
mapAttrs (
name: spec:
if builtins.hasAttr "outPath" spec
then abort
"The values in sources.json should not have an 'outPath' attribute"
else
spec // { outPath = replace name (fetch config.pkgs name spec); }
) config.sources;
# The "config" used by the fetchers
mkConfig =
{ sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null
, sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile)
, system ? builtins.currentSystem
, pkgs ? mkPkgs sources system
}: rec {
# The sources, i.e. the attribute set of spec name to spec
inherit sources;
# The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers
inherit pkgs;
};
in
mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); }

View file

@ -162,4 +162,12 @@ in
fonts.fonts = with pkgs; [ fonts.fonts = with pkgs; [
(nerdfonts.override { fonts = [ "FiraCode" "JetBrainsMono" ]; }) (nerdfonts.override { fonts = [ "FiraCode" "JetBrainsMono" ]; })
]; ];
services.cron = {
enable = true;
systemCronJobs = [
"0 9 * * * opdavies find ~/Downloads -daystart -mtime +2 -delete -print >> /tmp/cron.log"
];
};
} }

View file

@ -1,2 +0,0 @@
collections:
- name: community.general

View file

@ -1,7 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- awesome
state: latest
become: true

View file

@ -1,7 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- cargo
state: latest
become: true

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- com.github.hluk.copyq
method: user
state: present

View file

@ -1,7 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- ctop
state: latest
become: true

View file

@ -1,23 +0,0 @@
[org/gnome/desktop/wm/keybindings]
move-to-workspace-1=['<Shift><Super>Home', '<Shift><Super>1']
move-to-workspace-2=['<Shift><Super>2']
move-to-workspace-3=['<Shift><Super>3']
move-to-workspace-3=['<Shift><Super>3']
move-to-workspace-4=['<Shift><Super>4']
move-to-workspace-4=['<Shift><Super>4']
move-to-workspace-5=['<Shift><Super>5']
move-to-workspace-6=['<Shift><Super>6']
move-to-workspace-7=['<Shift><Super>7']
move-to-workspace-8=['<Shift><Super>8']
move-to-workspace-9=['<Shift><Super>9']
move-to-workspace-10=['<Shift><Super>0']
switch-to-workspace-1=['<Super>1']
switch-to-workspace-2=['<Super>2']
switch-to-workspace-3=['<Super>3']
switch-to-workspace-4=['<Super>4']
switch-to-workspace-5=['<Super>5']
switch-to-workspace-6=['<Super>6']
switch-to-workspace-7=['<Super>7']
switch-to-workspace-8=['<Super>8']
switch-to-workspace-9=['<Super>9']
switch-to-workspace-10=['<Super>0']

View file

@ -1,6 +0,0 @@
---
- name: Configure
ansible.builtin.file:
src: "{{ role_path }}/files/dconf-settings.ini"
dest: "{{ ansible_user_dir }}/.config/dconf-settings.ini"
state: link

View file

@ -1,4 +0,0 @@
---
- include_tasks: php.yaml
tags:
- debugger

View file

@ -1,22 +0,0 @@
---
- name: Clone
ansible.builtin.git:
depth: 1
dest: "{{ ansible_user_dir }}/build/vscode-php-debug"
force: yes
repo: https://github.com/xdebug/vscode-php-debug.git
single_branch: yes
register: clone
tags:
- debugger
- name: Install
ansible.builtin.command: |
npm install
npm run build
args:
chdir: "{{ ansible_user_dir }}/build/vscode-php-debug"
creates: "{{ ansible_user_dir }}/build/vscode-php-debug/out"
when: clone.changed
tags:
- debugger

View file

@ -1,3 +0,0 @@
---
dependencies:
- role: cargo

View file

@ -1,8 +0,0 @@
---
- name: Install
community.general.cargo:
name:
- git-delta
path: /usr/local
state: latest
become: true

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- com.discordapp.Discord
method: user
state: present

View file

@ -1,22 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- docker
- docker-compose
state: latest
become: yes
- name: Enable service
ansible.builtin.systemd:
enabled: yes
name: docker
state: started
become: yes
- name: Add to group
ansible.builtin.user:
append: yes
groups: docker
name: "{{ ansible_env['USER'] }}"
become: yes

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- org.filezillaproject.Filezilla
method: user
state: present

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- org.flameshot.Flameshot
method: user
state: present

View file

@ -1,14 +0,0 @@
---
- name: Download
ansible.builtin.get_url:
dest: "{{ font_item.dest }}"
url: "{{ font_item.url }}"
loop_control:
loop_var: font_item
loop:
- url: "https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/JetBrainsMono/Ligatures/Regular/complete/JetBrains%20Mono%20Regular%20Nerd%20Font%20Complete%20Mono.ttf?raw=true"
dest: /usr/share/fonts/truetype/JetBrainsMono Nerd Font Regular
- url: "https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/JetBrainsMono/Ligatures/Italic/complete/JetBrains%20Mono%20Italic%20Nerd%20Font%20Complete%20Mono.ttf?raw=true"
dest: /usr/share/fonts/truetype/JetBrainsMono Nerd Font Italic
become: true

View file

@ -1,7 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- fzf
state: latest
become: true

View file

@ -1,138 +0,0 @@
[alias]
aa = add --all
assume = update-index --assume-unchanged
assumed = !git ls-files -v | grep '^[hsmrck?]' | cut -c 3-
b = branch
browse = !gh repo view --web
ca = commit --amend --verbose
car = commit --amend --no-edit
cl = !hub clone
cl = !hub clone
co = checkout
compare = !hub compare
current-branch = rev-parse --abbrev-ref HEAD
dc = diff --color --word-diff --cached
df = diff --color --word-diff
dup = !git checkout develop && git fetch origin && echo && git sl develop..origin/develop && echo && git pull --quiet && git checkout -
fixup = commit --fixup
issues = !gh issue list --web
mup = !git master-to-main-wrapper checkout %BRANCH% && git fetch origin && echo && git sl %BRANCH%..origin/%BRANCH% && echo && git pull --quiet && git checkout -
nah = !git reset --hard && git clean -fd
no-ff = merge --no-ff
pl = pull
prune = remote prune origin
ps = push
pulls = !gh pr list --web
rbc = rebase --continue
rdup = !git dup && git rebase develop
remotes = remote -v
repush = !git pull --rebase && git push
ri = rebase --interactive
rid = !git rebase -i $(git merge-base develop HEAD)
rim = !git rebase -i $(git master-to-main-wrapper merge-base %BRANCH% HEAD)
rip = !git rebase -i $(git merge-base production HEAD)
ris = !git rebase -i $(git merge-base staging HEAD)
riu = !git rebase -i $(git rev-parse --abbrev-ref --symbolic-full-name @{u})
rmup = !git mup && git master-to-main-wrapper rebase %BRANCH%
sl = log --oneline --decorate -20
sla = log --oneline --decorate --graph --all -20
slap = log --oneline --decorate --graph --all
slp = log --oneline --decorate
staged = diff --staged
unassume = update-index --no-assume-unchanged
uncommit = reset --soft HEAD^
unstage = reset
upstream = rev-parse --abbrev-ref --symbolic-full-name @{u}
ureset = !git reset --hard $(git upstream)
wip = !git add . && git commit -m 'wip'
worktrees = "worktree list"
[branch]
autosetupmerge = true
autosetuprebase = always
[checkout]
defaultRemote = origin
[color]
branch = auto
diff = auto
status = auto
ui = true
[color "branch"]
current = red reverse
local = blue
remote = green
[color "diff"]
meta = yellow
frag = magenta
old = red bold
new = green
plain = white
[color "status"]
added = yellow
changed = green
untracked = cyan
[commit]
template = ~/.gitmessage
verbose = true
[core]
editor = nvim
excludesFile = ~/.gitignore-global
pager = delta
[delta]
line-numbers = true
[diff]
tool = vimdiff
[fetch]
prune = true
[gitsh]
nogreeting = true
[grep]
lineNumber = true
[help]
autocorrect = 1
[include]
path = ~/.gitconfig.local
[init]
templatedir = ~/.git_template
[merge]
ff = only
[rebase]
autosquash = true
autostash = true
[rerere]
enabled = true
[push]
default = upstream
[url "https://git.drupal.org/project/"]
insteadOf = do:
insteadOf = drupal:
[pull]
ff = only
rebase = true
[filter "lfs"]
process = git-lfs filter-process
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f

View file

@ -1,10 +0,0 @@
*
!*/
!/bin/**
!/tag-*/**
/tag-php/composer/.env
/tag-php/composer/auth.json
/tag-php/composer/bin/
/tag-php/composer/config/
/tag-php/composer/keys.*.pub
/**/*.zwc

View file

@ -1,43 +0,0 @@
# Ignore archive files.
*.7z
*.dmg
*.gz
*.iso
*.phar
*.phar.version
*.rar
*.tar
*.zip
# Ignore database exports.
*.*sql
# Ignore patch files and interdiffs.
*.patch
*.diff
*.rej
*.orig
interdiff*.txt
# Ignore Vagrant directories.
.vagrant/
# Ignore logs.
*.log
# Ignore IDE and text editor files.
.idea/
*.sublime-*
# Ignore temporary directories.
.php_cs.cache
tmp/
# Ignore Ansible Playbook retrys.
*.retry
# Ignore notes within projects.
.notes/
# Ignore directory level aliases
.aliases

View file

@ -1,16 +0,0 @@
# 50-character subject line
#
# 72-character wrapped longer description. This should answer:
#
# * Why was this change necessary?
# * How does it address the problem?
# * Are there any side effects?
#
# Include a link to the ticket, if any.
#
# Add co-authors if you worked on this code with others:
#
# Co-authored-by: Full Name <email@example.com>
# Co-authored-by: Full Name <email@example.com>

View file

@ -1,24 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- git
state: latest
become: true
- name: Configuration
ansible.builtin.file:
src: "{{ role_path }}/files/{{ git_config_item }}"
dest: "{{ ansible_user_dir }}/{{ git_config_item }}"
state: link
loop_control:
loop_var: git_config_item
with_items:
- .gitconfig
- .gitignore-global
- .gitmessage
- name: Local configuration
ansible.builtin.template:
src: gitconfig.local.j2
dest: "{{ ansible_user_dir }}/.gitconfig.local"

View file

@ -1,3 +0,0 @@
[user]
email = {{ git_user_email }}
name = {{ git_user_name }}

View file

@ -1,26 +0,0 @@
---
- name: Existing install
ansible.builtin.stat:
path: /usr/bin/gh
register: install
- name: Keyring
ansible.builtin.get_url:
dest: /usr/share/keyrings/githubcli-archive-keyring.gpg
mode: 644
url: https://cli.github.com/packages/githubcli-archive-keyring.gpg
when: not install.stat.exists
become: true
- name: Repository
ansible.builtin.apt_repository:
repo: "deb [arch=amd64 signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main"
when: not install.stat.exists
become: true
- name: Install
ansible.builtin.package:
name:
- gh
state: latest
become: true

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- io.github.shiftey.Desktop
method: user
state: present

View file

@ -1,7 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- gnome-tweaks
state: latest
become: true

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- com.google.Chrome
method: user
state: present

View file

@ -1,7 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- htop
state: latest
become: true

View file

@ -1,7 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- jq
state: latest
become: true

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- org.kde.kdenlive
method: user
state: present

View file

@ -1,7 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- mysql-client
state: latest
become: true

View file

@ -1,12 +0,0 @@
---
- name: Repository
ansible.builtin.apt_repository:
repo: "deb [trusted=yes] https://apt.fury.io/notion-repackaged/ /"
become: true
- name: Install
ansible.builtin.package:
name:
- notion-app
state: latest
become: true

View file

@ -1,7 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- npm
state: latest
become: true

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- com.obsproject.Studio
method: user
state: present

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- com.github.jeromerobert.pdfarranger
method: user
state: present

View file

@ -1,30 +0,0 @@
---
- name: Install dependencies
ansible.builtin.package:
name:
- php
state: latest
become: true
- name: Existing install
stat:
path: "{{ ansible_user_dir }}/.platformsh/bin/platform"
register: install
- name: Download installer
ansible.builtin.get_url:
dest: /tmp/platformsh-install.sh
mode: 0755
url: https://platform.sh/cli/installer
become: true
when: not install.stat.exists
- name: Execute installer
ansible.builtin.command: php /tmp/platformsh-install.sh
when: not install.stat.exists
- name: Remove platformsh-install.sh
ansible.builtin.file:
path: /tmp/platformsh-install.sh
state: absent
become: true

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- tech.feliciano.pocket-casts
method: user
state: present

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- com.getpostman.Postman
method: user
state: present

View file

@ -1,3 +0,0 @@
---
dependencies:
- role: ssh

View file

@ -1,22 +0,0 @@
---
- name: Create project directories
ansible.builtin.file:
path: "{{ project_directory_item }}"
state: directory
recurse: yes
loop_control:
loop_var: project_directory_item
with_items: "{{ project_directories | default([]) }}"
- name: Clone projects
ansible.builtin.git:
accept_hostkey: yes
bare: "{{ project_item.bare | default(true) }}"
clone: yes
dest: "{{ ansible_user_dir }}/Code/{{ project_item.dest }}"
repo: "{{ project_item.repo }}"
version: "{{ project_item.version | default('main') }}"
update: no
loop_control:
loop_var: project_item
with_items: "{{ project_projects | default([]) }}"

View file

@ -1,23 +0,0 @@
---
- name: Existing install
stat:
path: "{{ ansible_user_dir }}/.pulumi/bin/pulumi"
register: install
- name: Download installer
ansible.builtin.get_url:
dest: /tmp/pulumi-install.sh
mode: 0755
url: https://get.pulumi.com
become: true
when: not install.stat.exists
- name: Execute installer
ansible.builtin.command: sh /tmp/pulumi-install.sh
when: not install.stat.exists
- name: Remove pulumi-install.sh
ansible.builtin.file:
path: /tmp/pulumi-install.sh
state: absent
become: true

View file

@ -1,7 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- pv
state: latest
become: true

View file

@ -1,7 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- ripgrep
state: latest
become: true

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- com.skype.Client
method: user
state: present

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- com.slack.Slack
method: user
state: present

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- com.spotify.Client
method: user
state: present

View file

@ -1,18 +0,0 @@
---
- name: Copy SSH keys
copy:
content: "{{ ssh_key_item.value }}"
dest: "{{ ansible_user_dir }}/.ssh/{{ ssh_key_item.key }}"
mode: 0400
loop_control:
loop_var: ssh_key_item
no_log: true
with_items: "{{ ssh_key | default({}) | dict2items }}"
- name: Create SSH configuration file
ansible.builtin.copy:
content: "{{ ssh_config }}"
dest: "{{ ansible_user_dir }}/.ssh/config"
mode: 0400
no_log: true
when: ssh_config is defined

View file

@ -1,3 +0,0 @@
---
dependencies:
- role: cargo

View file

@ -1,8 +0,0 @@
---
- name: Install
community.general.cargo:
name:
- stylua
path: /usr/local
state: latest
become: true

View file

@ -1,7 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- tldr
state: latest
become: true

View file

@ -1,95 +0,0 @@
unbind C-b
set -g prefix C-s
bind C-s send-prefix
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
bind-key -n C-h select-pane -L
bind-key -n C-j select-pane -D
bind-key -n C-k select-pane -U
bind-key -n C-l select-pane -R
set-option -g status-keys "emacs"
set-option -g default-terminal "xterm-256color"
set-option -ga terminal-overrides ",*256col*:Tc"
bind-key h split-window -v -c '#{pane_current_path}'
bind-key v split-window -h -c '#{pane_current_path}'
bind -n S-Left resize-pane -L 2
bind -n S-Right resize-pane -R 2
bind -n S-Down resize-pane -D 1
bind -n S-Up resize-pane -U 1
bind -n C-Left resize-pane -L 10
bind -n C-Right resize-pane -R 10
bind -n C-Down resize-pane -D 5
bind -n C-Up resize-pane -U 5
set-option -g status-left-length 50
set-option -g status-right ""
bind c new-window -c "#{pane_current_path}"
set -g base-index 1
set -g renumber-windows on
# Break a pane into a new window.
bind-key b break-pane -d
bind-key C-j choose-tree
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup 'v' to begin selection as in Vim
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-pipe "reattach-to-user-namespace pbcopy"
# Update default binding of `Enter` to also use copy-pipe
unbind -T copy-mode-vi Enter
bind-key -T copy-mode-vi 'Enter' send -X copy-pipe "reattach-to-user-namespace pbcopy"
bind C-j split-window -v "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t"
bind-key C-b send-keys 'tat && exit' 'C-m'
bind-key K run-shell 'tmux switch-client -n \; kill-session -t "$(tmux display-message -p "#S")" || tmux kill-session'
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
# Allow clearing screen with ctrl-l by using <prefix> C-l
bind C-l send-keys 'C-l'
bind C-k send-keys 'C-k'
# Enable mouse support.
setw -g mouse on
# Remove delay when switching Vim modes.
set -sg escape-time 0
# Plugins
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tpm'
# Initialize TMUX plugin manager
run '~/.tmux/plugins/tpm/tpm'

View file

@ -1,18 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- tmux
state: latest
become: true
- name: Directory
ansible.builtin.file:
path: "{{ ansible_user_dir }}/.config/tmux"
state: directory
- name: Configuration
ansible.builtin.file:
src: "{{ role_path }}/files/tmux.conf"
dest: "{{ ansible_user_dir }}/.config/tmux/tmux.conf"
state: link

View file

@ -1,27 +0,0 @@
---
- name: Dependencies
ansible.builtin.package:
name: ruby
state: latest
become: true
- name: Install
community.general.gem:
bindir: "{{ ansible_user_dir }}/.local/bin"
name: tmuxinator
state: latest
- name: Configuration
ansible.builtin.file:
path: "{{ ansible_user_dir }}/.config/tmuxinator"
state: directory
- name: Copy configuration files
copy:
content: "{{ tmuxinator_config_file.value }}"
dest: "{{ ansible_user_dir }}/.config/tmuxinator/{{ tmuxinator_config_file.key }}.yml"
mode: 0644
loop_control:
loop_var: tmuxinator_config_file
no_log: true
with_items: "{{ tmuxinator_config | default({}) | dict2items }}"

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- com.todoist.Todoist
method: user
state: present

View file

@ -1,7 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- tree
state: latest
become: true

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- org.videolan.VLC
method: user
state: present

View file

@ -1,7 +0,0 @@
---
- name: Install
community.general.flatpak:
name:
- us.zoom.Zoom
method: user
state: present

View file

@ -1,5 +0,0 @@
---
- name: Download
get_url:
dest: ~/.antigen.zsh
url: https://raw.githubusercontent.com/zsh-users/antigen/master/bin/antigen.zsh

View file

@ -1,7 +0,0 @@
export EDITOR=nvim
export ZDOTDIR="$HOME/.config/zsh"
PROMPT_EOL_MARK=''
TERM=xterm-256color
WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'
ZLE_REMOVE_SUFFIX_CHARS=''

View file

@ -1,28 +0,0 @@
for function in $ZDOTDIR/functions/*; do
source "${function}"
done
sources=(
'aliases'
'colour'
'functions'
'fzf'
'general'
'history'
'navigation'
'nvm'
'options'
'path'
'platformsh'
'plugins'
'prompt'
'post/completion'
)
for s in "${sources[@]}"; do
source $ZDOTDIR/configs/${s}.zsh
done
# Local config
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local

View file

@ -1,3 +0,0 @@
#compdef g
compdef g=git

View file

@ -1,2 +0,0 @@
#compdef m
compdef m=make

View file

@ -1,11 +0,0 @@
alias hosts='sudo vim /etc/hosts'
alias rebase='git fetch --all --prune --prune-tags && git rebase'
alias sshconfig='vim ~/.ssh/config'
alias vim='nvim'
# Allow for pasting lines of code that start with a dollar sign.
alias \$=''
# Re-implement pbcopy and pbpaste from macOS.
alias pbcopy="xclip -selection clipboard"
alias pbpaste="xclip -selection clipboard -o"

View file

@ -1,4 +0,0 @@
autoload -U colors
colors
export CLICOLOR=1

View file

@ -1,38 +0,0 @@
function m() {
if [[ -f .notes/Makefile ]];
then
make -f .notes/Makefile "$@"
else
make "$@"
fi
}
function mkd() {
mkdir -p "$@" && cd "$@"
}
function composer() {
docker run -u $UID -it --rm \
-v $(pwd):/app \
-v ~/.composer:/root/.composer \
-v ~/.ssh:/root/.ssh \
composer \
composer $*
}
# Run 'phpunit' or 'pest' depending on the project.
function p () {
vendor/bin/$(phpunit-or-pest) $*;
}
function pf () {
vendor/bin/$(phpunit-or-pest) --filter $*
}
nv() {
if [[ $# > 0 ]];
then
nvim $@
else
nvim .
fi
}

View file

@ -1,2 +0,0 @@
# Include keybindings for fzf.
. /usr/share/doc/fzf/examples/key-bindings.zsh

View file

@ -1,5 +0,0 @@
precmd() {
# Add a blank line before each command.
print ''
}

View file

@ -1,7 +0,0 @@
setopt histignoredups
setopt inc_append_history
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.cache/zsh/history

View file

@ -1,9 +0,0 @@
bindkey -s "^f" "tmux-sessioniser\n"
# Search through history with the up and down arrows.
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search # Up
bindkey "${terminfo[kcud1]}" up-line-or-beginning-search # Down

View file

@ -1,2 +0,0 @@
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

View file

@ -1,3 +0,0 @@
# Fix "zsh: no matches found: HEAD^" error.
# See https://github.com/opdavies/dotfiles/issues/14.
setopt NO_NOMATCH

View file

@ -1,25 +0,0 @@
setopt auto_cd
export PATH=\
$PATH:\
/usr/bin:\
$HOME/.cargo/bin:\
$HOME/.composer/vendor/bin:\
$HOME/.dotfiles/bin:\
$HOME/.dotfiles/bin/bin:\
$HOME/.local/bin:\
$HOME/.platformsh/bin:\
$HOME/.pulumi/bin:\
$HOME/bin:\
$HOME/snap/bin:\
bin:\
node_modules/.bin:\
tools/php-cs-fixer/vendor/bin:\
vendor/bin
export CDPATH=\
./:\
$HOME/Code:\
$HOME/Code/clients:\
$HOME/Code/open_source:\
$HOME

View file

@ -1,6 +0,0 @@
# Platform.sh CLI configuration.
export PATH="$HOME/"'.platformsh/bin':"$PATH"
if [ -f "$HOME/"'.platformsh/shell-config.rc' ]; then
. "$HOME/"'.platformsh/shell-config.rc';
fi

View file

@ -1,10 +0,0 @@
# antigen.zsh has been downloaded manually for now,
# see https://github.com/zsh-users/antigen/issues/659.
source $HOME/.antigen.zsh
antigen bundle mollifier/cd-gitroot
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-completions
antigen bundle zsh-users/zsh-syntax-highlighting
antigen apply

View file

@ -1,8 +0,0 @@
# load our own completion functions
fpath=(~/.config/zsh/completion-scripts $fpath)
autoload -Uz compinit && compinit
## case-insensitive (all), partial-word and then substring completion
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' \
'r:|[._-]=* r:|=*' 'l:|=* r:|=*'

View file

@ -1,34 +0,0 @@
autoload -Uz colors && colors
prompt_color() {
[[ -n "$1" ]] && print "%{$fg_bold[$2]%}$1%{$reset_color%}"
}
prompt_blue() { print "$(prompt_color "$1" blue)" }
prompt_green() { print "$(prompt_color "$1" green)" }
prompt_red() { print "$(prompt_color "$1" red)" }
prompt_yellow() { print "$(prompt_color "$1" yellow)" }
prompt_full_path() {
print "$(prompt_blue %~)"
}
prompt_shortened_path() {
print "$(prompt_blue %2~)"
}
prompt_git_branch() {
local branch="$(git symbolic-ref HEAD 2> /dev/null | cut -d'/' -f3)"
[ -n "${branch}" ] && print "$(prompt_green $branch)"
}
prompt_git_commit() {
local commit_sha="$(git rev-parse --short HEAD 2> /dev/null)"
[ -n "${commit_sha}" ] && echo [$(prompt_yellow $commit_sha)]
}
setopt prompt_subst
PROMPT='$(prompt_shortened_path) $(prompt_git_branch) $(prompt_git_commit) $ '

View file

@ -1,9 +0,0 @@
# No arguments: `git status`
# With arguments: acts like `git`
g() {
if [[ $# -gt 0 ]]; then
git "$@"
else
git status
fi
}

View file

@ -1,8 +0,0 @@
# Execute a "run" file either within ".notes" or the current directory.
function run {
if [[ -f .notes/run ]]; then
.notes/run "${@}"
elif [[ -f run ]]; then
./run "${@}"
fi
}

View file

@ -1,281 +0,0 @@
# The git prompt's git commands are read-only and should not interfere with
# other processes. This environment variable is equivalent to running with `git
# --no-optional-locks`, but falls back gracefully for older versions of git.
# See git(1) for and git-status(1) for a description of that flag.
#
# We wrap in a local function instead of exporting the variable directly in
# order to avoid interfering with manually-run git commands by the user.
function __git_prompt_git() {
GIT_OPTIONAL_LOCKS=0 command git "$@"
}
function git_prompt_info() {
# If we are on a folder not tracked by git, get out.
# Otherwise, check for hide-info at global and local repository level
if ! __git_prompt_git rev-parse --git-dir &> /dev/null \
|| [[ "$(__git_prompt_git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
return 0
fi
local ref
ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \
|| ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \
|| return 0
# Use global ZSH_THEME_GIT_SHOW_UPSTREAM=1 for including upstream remote info
local upstream
if (( ${+ZSH_THEME_GIT_SHOW_UPSTREAM} )); then
upstream=$(__git_prompt_git rev-parse --abbrev-ref --symbolic-full-name "@{upstream}" 2>/dev/null) \
&& upstream=" -> ${upstream}"
fi
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
}
# Checks if working tree is dirty
function parse_git_dirty() {
local STATUS
local -a FLAGS
FLAGS=('--porcelain')
if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then
FLAGS+='--untracked-files=no'
fi
case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in
git)
# let git decide (this respects per-repo config in .gitmodules)
;;
*)
# if unset: ignore dirty submodules
# other values are passed to --ignore-submodules
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
;;
esac
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1)
fi
if [[ -n $STATUS ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
else
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
fi
}
# Gets the difference between the local and remote branches
function git_remote_status() {
local remote ahead behind git_remote_status git_remote_status_detailed
remote=${$(__git_prompt_git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
if [[ -n ${remote} ]]; then
ahead=$(__git_prompt_git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
behind=$(__git_prompt_git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
if [[ $ahead -eq 0 ]] && [[ $behind -eq 0 ]]; then
git_remote_status="$ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE"
elif [[ $ahead -gt 0 ]] && [[ $behind -eq 0 ]]; then
git_remote_status="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE"
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}"
elif [[ $behind -gt 0 ]] && [[ $ahead -eq 0 ]]; then
git_remote_status="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE"
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
elif [[ $ahead -gt 0 ]] && [[ $behind -gt 0 ]]; then
git_remote_status="$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE"
git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
fi
if [[ -n $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]]; then
git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX${remote:gs/%/%%}$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX"
fi
echo $git_remote_status
fi
}
# Outputs the name of the current branch
# Usage example: git pull origin $(git_current_branch)
# Using '--quiet' with 'symbolic-ref' will not cause a fatal error (128) if
# it's not a symbolic ref, but in a Git repo.
function git_current_branch() {
local ref
ref=$(__git_prompt_git symbolic-ref --quiet HEAD 2> /dev/null)
local ret=$?
if [[ $ret != 0 ]]; then
[[ $ret == 128 ]] && return # no git repo.
ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) || return
fi
echo ${ref#refs/heads/}
}
# Gets the number of commits ahead from remote
function git_commits_ahead() {
if __git_prompt_git rev-parse --git-dir &>/dev/null; then
local commits="$(__git_prompt_git rev-list --count @{upstream}..HEAD 2>/dev/null)"
if [[ -n "$commits" && "$commits" != 0 ]]; then
echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
fi
fi
}
# Gets the number of commits behind remote
function git_commits_behind() {
if __git_prompt_git rev-parse --git-dir &>/dev/null; then
local commits="$(__git_prompt_git rev-list --count HEAD..@{upstream} 2>/dev/null)"
if [[ -n "$commits" && "$commits" != 0 ]]; then
echo "$ZSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$ZSH_THEME_GIT_COMMITS_BEHIND_SUFFIX"
fi
fi
}
# Outputs if current branch is ahead of remote
function git_prompt_ahead() {
if [[ -n "$(__git_prompt_git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
}
# Outputs if current branch is behind remote
function git_prompt_behind() {
if [[ -n "$(__git_prompt_git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then
echo "$ZSH_THEME_GIT_PROMPT_BEHIND"
fi
}
# Outputs if current branch exists on remote or not
function git_prompt_remote() {
if [[ -n "$(__git_prompt_git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then
echo "$ZSH_THEME_GIT_PROMPT_REMOTE_EXISTS"
else
echo "$ZSH_THEME_GIT_PROMPT_REMOTE_MISSING"
fi
}
# Formats prompt string for current git commit short SHA
function git_prompt_short_sha() {
local SHA
SHA=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
}
# Formats prompt string for current git commit long SHA
function git_prompt_long_sha() {
local SHA
SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
}
function git_prompt_status() {
[[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
# Maps a git status prefix to an internal constant
# This cannot use the prompt constants, as they may be empty
local -A prefix_constant_map
prefix_constant_map=(
'\?\? ' 'UNTRACKED'
'A ' 'ADDED'
'M ' 'ADDED'
'MM ' 'MODIFIED'
' M ' 'MODIFIED'
'AM ' 'MODIFIED'
' T ' 'MODIFIED'
'R ' 'RENAMED'
' D ' 'DELETED'
'D ' 'DELETED'
'UU ' 'UNMERGED'
'ahead' 'AHEAD'
'behind' 'BEHIND'
'diverged' 'DIVERGED'
'stashed' 'STASHED'
)
# Maps the internal constant to the prompt theme
local -A constant_prompt_map
constant_prompt_map=(
'UNTRACKED' "$ZSH_THEME_GIT_PROMPT_UNTRACKED"
'ADDED' "$ZSH_THEME_GIT_PROMPT_ADDED"
'MODIFIED' "$ZSH_THEME_GIT_PROMPT_MODIFIED"
'RENAMED' "$ZSH_THEME_GIT_PROMPT_RENAMED"
'DELETED' "$ZSH_THEME_GIT_PROMPT_DELETED"
'UNMERGED' "$ZSH_THEME_GIT_PROMPT_UNMERGED"
'AHEAD' "$ZSH_THEME_GIT_PROMPT_AHEAD"
'BEHIND' "$ZSH_THEME_GIT_PROMPT_BEHIND"
'DIVERGED' "$ZSH_THEME_GIT_PROMPT_DIVERGED"
'STASHED' "$ZSH_THEME_GIT_PROMPT_STASHED"
)
# The order that the prompt displays should be added to the prompt
local status_constants
status_constants=(
UNTRACKED ADDED MODIFIED RENAMED DELETED
STASHED UNMERGED AHEAD BEHIND DIVERGED
)
local status_text
status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)"
# Don't continue on a catastrophic failure
if [[ $? -eq 128 ]]; then
return 1
fi
# A lookup table of each git status encountered
local -A statuses_seen
if __git_prompt_git rev-parse --verify refs/stash &>/dev/null; then
statuses_seen[STASHED]=1
fi
local status_lines
status_lines=("${(@f)${status_text}}")
# If the tracking line exists, get and parse it
if [[ "$status_lines[1]" =~ "^## [^ ]+ \[(.*)\]" ]]; then
local branch_statuses
branch_statuses=("${(@s/,/)match}")
for branch_status in $branch_statuses; do
if [[ ! $branch_status =~ "(behind|diverged|ahead) ([0-9]+)?" ]]; then
continue
fi
local last_parsed_status=$prefix_constant_map[$match[1]]
statuses_seen[$last_parsed_status]=$match[2]
done
fi
# For each status prefix, do a regex comparison
for status_prefix in ${(k)prefix_constant_map}; do
local status_constant="${prefix_constant_map[$status_prefix]}"
local status_regex=$'(^|\n)'"$status_prefix"
if [[ "$status_text" =~ $status_regex ]]; then
statuses_seen[$status_constant]=1
fi
done
# Display the seen statuses in the order specified
local status_prompt
for status_constant in $status_constants; do
if (( ${+statuses_seen[$status_constant]} )); then
local next_display=$constant_prompt_map[$status_constant]
status_prompt="$next_display$status_prompt"
fi
done
echo $status_prompt
}
# Outputs the name of the current user
# Usage example: $(git_current_user_name)
function git_current_user_name() {
__git_prompt_git config user.name 2>/dev/null
}
# Outputs the email of the current user
# Usage example: $(git_current_user_email)
function git_current_user_email() {
__git_prompt_git config user.email 2>/dev/null
}
# Output the name of the root directory of the git repository
# Usage example: $(git_repo_name)
function git_repo_name() {
local repo_path
if repo_path="$(__git_prompt_git rev-parse --show-toplevel 2>/dev/null)" && [[ -n "$repo_path" ]]; then
echo ${repo_path:t}
fi
}

View file

@ -1,34 +0,0 @@
---
- name: Install
ansible.builtin.package:
name:
- zsh
state: latest
become: true
- name: Set default
user:
name: "{{ ansible_env['USER'] }}"
shell: /usr/bin/zsh
become: yes
- name: Configuration
ansible.builtin.file:
src: "{{ role_path }}/files/{{ zsh_config_item.src }}"
path: "{{ zsh_config_item.path }}"
state: link
loop_control:
loop_var: zsh_config_item
with_items:
- { src: config, path: "{{ ansible_user_dir }}/.config/zsh" }
- { src: .zshenv, path: "{{ ansible_user_dir }}/.zshenv" }
- name: Delete old files
ansible.builtin.file:
path: "{{ old_files_item }}"
state: absent
loop_control:
loop_var: old_files_item
with_items:
- "{{ ansible_user_dir }}/.zsh"
- "{{ ansible_user_dir }}/.zshrc"