chore: rework directory structure
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
1fbdeb0d21
commit
01225fd44d
169 changed files with 1410 additions and 1690 deletions
roles/user/shell/zsh
65
roles/user/shell/zsh/files/starship.toml
Normal file
65
roles/user/shell/zsh/files/starship.toml
Normal file
|
@ -0,0 +1,65 @@
|
|||
add_newline = false
|
||||
format = """$username\
|
||||
$hostname\
|
||||
$directory\
|
||||
$git_branch\
|
||||
$git_commit\
|
||||
$git_state\
|
||||
$git_status\
|
||||
${custom.toolbox}\
|
||||
$nix_shell\
|
||||
$jobs\
|
||||
$time\
|
||||
$cmd_duration\
|
||||
$line_break\
|
||||
$character"""
|
||||
|
||||
[username]
|
||||
format = "[$user@]($style)"
|
||||
show_always = true
|
||||
style_user = "blue"
|
||||
|
||||
[hostname]
|
||||
format = "[$hostname]($style) "
|
||||
ssh_only = false
|
||||
style = "blue"
|
||||
|
||||
[directory]
|
||||
style = "yellow"
|
||||
|
||||
[git_branch]
|
||||
format = "[$branch]($style)"
|
||||
style = "cyan"
|
||||
|
||||
[git_state]
|
||||
format = '\([$state( $progress_current/$progress_total)]($style)\) '
|
||||
style = "cyan"
|
||||
|
||||
[git_status]
|
||||
format = "[[(*$conflicted$untracked$modified$staged$renamed$deleted)](218) ($ahead_behind$stashed)]($style)"
|
||||
style = "cyan"
|
||||
conflicted = ""
|
||||
untracked = ""
|
||||
modified = ""
|
||||
staged = ""
|
||||
renamed = ""
|
||||
deleted = ""
|
||||
stashed = "≡"
|
||||
|
||||
[custom.toolbox]
|
||||
when = "ls /run/.containerenv"
|
||||
symbol = " "
|
||||
command = "~/.local/bin/toolbox_name.sh"
|
||||
format = "in [$symbol($output )]($style)"
|
||||
style = "bold purple"
|
||||
|
||||
[time]
|
||||
disabled = true
|
||||
|
||||
[cmd_duration]
|
||||
format = "[$duration]($style) "
|
||||
|
||||
[character]
|
||||
success_symbol = "[λ](green)"
|
||||
error_symbol = "[λ](red)"
|
||||
vimcmd_symbol = "[❮](green)"
|
173
roles/user/shell/zsh/files/zshrc
Normal file
173
roles/user/shell/zsh/files/zshrc
Normal file
|
@ -0,0 +1,173 @@
|
|||
export ZSH="/home/mfocko/.oh-my-zsh"
|
||||
|
||||
ENABLE_CORRECTION=true
|
||||
plugins=(git common-aliases history systemd sudo zsh-autosuggestions zsh-syntax-highlighting zsh-aliases-exa fzf direnv taskwarrior autojump)
|
||||
source $ZSH/oh-my-zsh.sh
|
||||
|
||||
### add .local/bin to PATH ###
|
||||
export GOPATH=$HOME/.go
|
||||
export PATH=$HOME/.go/bin:$HOME/.npm/bin:$HOME/.emacs.d/bin:$HOME/.local/bin:$PATH
|
||||
|
||||
### zsh autosuggestions color ###
|
||||
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=8,bold,underline"
|
||||
|
||||
### Ruby gems ###
|
||||
if which ruby >/dev/null && which gem >/dev/null; then
|
||||
PATH="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin:$PATH"
|
||||
fi
|
||||
|
||||
### NeoVim ###
|
||||
export EDITOR=nvim
|
||||
alias vim=nvim
|
||||
|
||||
alias alacrittyconf="$EDITOR ~/.config/alacritty/alacritty.yml"
|
||||
alias kittyconf="$EDITOR ~/.config/kitty/kitty.conf"
|
||||
|
||||
### git aliases ###
|
||||
export GIT_EDITOR=$EDITOR
|
||||
alias gcs="git commit -v -s"
|
||||
|
||||
### tokens ###
|
||||
source ~/.tokens
|
||||
|
||||
### gpg as ssh key ###
|
||||
function gpg_for_ssh() {
|
||||
export GPG_TTY=$(tty)
|
||||
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
|
||||
gpgconf --launch gpg-agent
|
||||
}
|
||||
gpg_for_ssh
|
||||
|
||||
### direnv & nixpkg ###
|
||||
if [[ $(command -v direnv 2> /dev/null) ]]; then
|
||||
eval "$(direnv hook zsh)";
|
||||
fi
|
||||
if [ -e /home/mfocko/.nix-profile/etc/profile.d/nix.sh ]; then
|
||||
. /home/mfocko/.nix-profile/etc/profile.d/nix.sh;
|
||||
fi # added by Nix installer
|
||||
|
||||
### Rust ###
|
||||
# export RUSTUP_HOME=/opt/rustup
|
||||
# export CARGO_HOME=/opt/cargo
|
||||
# export PATH=/opt/cargo/bin:$PATH
|
||||
export PATH=~/.cargo/bin:$PATH
|
||||
# [[ -s "/opt/cargo/env" ]] && source /opt/cargo/env
|
||||
|
||||
### Go ###
|
||||
export PATH="$HOME/.go/bin:$PATH"
|
||||
|
||||
### SDKMan ###
|
||||
export SDKMAN_DIR="/opt/sdkman"
|
||||
[[ -s "/opt/sdkman/bin/sdkman-init.sh" ]] && source "/opt/sdkman/bin/sdkman-init.sh"
|
||||
|
||||
### Bitwarden ###
|
||||
eval "$(bw completion --shell zsh); compdef _bw bw;"
|
||||
|
||||
function bwu() {
|
||||
local VAULT=$(readlink ~/.config/Bitwarden\ CLI/data.json | cut -d'/' -f6 | cut -d'.' -f-3)
|
||||
local PASS=$(yad --text "Master password for Bitwarden Vault @ $VAULT:" --center --button "yad-ok" --entry --hide-text)
|
||||
export BW_SESSION=$(bw unlock --raw "$PASS")
|
||||
}
|
||||
|
||||
# alias bwu='export BW_SESSION="$(bw unlock --raw)"'
|
||||
alias bwl='export BW_SESSION='
|
||||
|
||||
alias bwrh='ln -sf $HOME/.config/Bitwarden\ CLI/{vault.bitwarden.com,data}.json'
|
||||
alias bwvps='ln -sf $HOME/.config/Bitwarden\ CLI/{vault.mfocko.xyz,data}.json'
|
||||
|
||||
function gen_pass() {
|
||||
LENGTH=12
|
||||
if [[ -n $1 ]]; then
|
||||
LENGTH=$1
|
||||
fi
|
||||
|
||||
bw generate -uln --length $LENGTH
|
||||
}
|
||||
|
||||
function gen_passphrase() {
|
||||
LENGTH=2
|
||||
if [[ -n $1 ]]; then
|
||||
LENGTH=$1
|
||||
fi
|
||||
|
||||
bw generate -p --words $LENGTH
|
||||
}
|
||||
|
||||
# HashiCorp Vault
|
||||
export VAULT_ADDR="https://hvault.mfocko.xyz"
|
||||
function hcvu() {
|
||||
local PASS=$(yad --text "Password for HashiCorp Vault @ mfocko.xyz:" --center --button "yad-ok" --entry --hide-text)
|
||||
vault login -method=userpass -no-print username=$(whoami) password=$PASS
|
||||
}
|
||||
|
||||
### public_html ###
|
||||
function from_phrase() {
|
||||
bw list items --search $2 | jq --raw-output ".[] | select(.folderId == \"$1\") | .fields[] | select(.value == \"$3\") | .name"
|
||||
}
|
||||
|
||||
function to_phrase() {
|
||||
bw list items --search $2 | jq --raw-output ".[] | select(.folderId == \"$1\") | .fields[] | select(.name == \"$3\") | .value"
|
||||
}
|
||||
|
||||
function get_link() {
|
||||
FOLDER=$(bw list folders --search public_html | jq --raw-output ".[0].id")
|
||||
if [[ "$1" == "aisa" ]]; then
|
||||
PREFIX="https://fi.muni.cz/~xfocko";
|
||||
elif [[ "$1" == "poincare" ]]; then
|
||||
PREFIX="https://me.mfocko.xyz";
|
||||
fi;
|
||||
|
||||
echo $PREFIX/$(to_phrase $FOLDER $1 $2)
|
||||
}
|
||||
|
||||
function ls_links() {
|
||||
FOLDER=$(bw list folders --search public_html | jq --raw-output ".[0].id")
|
||||
bw list items --search $1 | jq ".[] | select(.folderId == \"$FOLDER\") | .fields[].name"
|
||||
}
|
||||
|
||||
### Red Hat ###
|
||||
alias rh_vpn='echo "$(bw get password Red\ Hat\ -\ SSO)$(bw get totp Red\ Hat\ -\ SSO)" | nmcli --ask connection up Brno\ \(BRQ\)'
|
||||
alias rh_vpn_rdu2='echo "$(bw get password Red\ Hat\ -\ SSO)$(bw get totp Red\ Hat\ -\ SSO)" | nmcli --ask connection up Raleigh\ \(RDU2\)'
|
||||
alias rh_wifi='echo -e "\n$(bw get password Red\ Hat\ -\ SSO)$(bw get totp Red\ Hat\ -\ SSO)" | nmcli --ask connection up Red\ Hat'
|
||||
alias rh_ticket='echo "$(bw get password Red\ Hat\ -\ Kerberos)" | kinit mfocko@REDHAT.COM'
|
||||
|
||||
### Fedora ###
|
||||
alias fk='echo "$(bw get password Fedora\ Accounts)$(bw get totp Fedora\ Accounts)" | fkinit'
|
||||
|
||||
### FI ###
|
||||
alias fi_vpn='echo "$(bw get password Faculty\ Pass)" | nmcli --ask connection up VPN\ FI\ MU'
|
||||
|
||||
### C(XX)FLAGS ###
|
||||
# export CC=gcc
|
||||
# export CFLAGS="-std=c11 -Wall -Werror"
|
||||
# export CXXFLAGS="-std=c++14 -Wall -Werror"
|
||||
# export LDLIBS="-lm -lkarel -lcurses"
|
||||
# export LDLIBS="-lm"
|
||||
|
||||
export LANG=en_US.UTF-8
|
||||
|
||||
### Lazy aliases ###
|
||||
alias q="exit"
|
||||
alias k="exit"
|
||||
alias ts="tmux new -As default"
|
||||
alias Reset="reset && tmux clear-history"
|
||||
|
||||
### Java ###
|
||||
export PATH="/opt/jdk-18/bin:$PATH"
|
||||
|
||||
### fzf ###
|
||||
# source $HOME/.oh-my-zsh/custom/plugins/fzf-tab-completion/zsh/fzf-zsh-completion.sh
|
||||
# bindkey '^I' fzf_completion
|
||||
|
||||
# if [[ "$TMUX" == "" && "$VSCODE_SHELL_INTEGRATION" == "" ]]; then
|
||||
# tmux new -s
|
||||
# fi;
|
||||
|
||||
### sprunge ###
|
||||
function sprunge_paste() {
|
||||
echo "Paste your code: "
|
||||
cat - | curl -F 'sprunge=<-' http://sprunge.us
|
||||
}
|
||||
|
||||
### Starship ###
|
||||
eval "$(starship init zsh)"
|
23
roles/user/shell/zsh/tasks/install.yml
Normal file
23
roles/user/shell/zsh/tasks/install.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
---
|
||||
- name: Install zsh
|
||||
ansible.builtin.package:
|
||||
name:
|
||||
- zsh
|
||||
- autojump
|
||||
state: present
|
||||
become: true
|
||||
|
||||
- name: Install fzf for fuzzy finding
|
||||
ansible.builtin.package:
|
||||
name: fzf
|
||||
state: present
|
||||
become: true
|
||||
when: ansible_distribution not in [ "AlmaLinux" ]
|
||||
|
||||
# “yet another dialog” for the functions in zshrc
|
||||
- name: Install yad for prompts from shell
|
||||
ansible.builtin.package:
|
||||
name: yad
|
||||
state: present
|
||||
become: true
|
||||
when: ansible_distribution not in [ "AlmaLinux" ]
|
18
roles/user/shell/zsh/tasks/main.yml
Normal file
18
roles/user/shell/zsh/tasks/main.yml
Normal file
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
- name: Packages
|
||||
ansible.builtin.include_tasks: install.yml
|
||||
tags: install
|
||||
|
||||
- name: Plugin oh-my-zsh
|
||||
ansible.builtin.include_tasks: oh-my-zsh.yml
|
||||
tags: zsh-oh-my-zsh
|
||||
|
||||
- name: Plugin starship
|
||||
ansible.builtin.include_tasks: starship.yml
|
||||
|
||||
- name: Set default shell
|
||||
become: true
|
||||
ansible.builtin.user:
|
||||
name: "{{ target_user }}"
|
||||
shell: /bin/zsh
|
||||
tags: zsh/set-default-shell
|
35
roles/user/shell/zsh/tasks/oh-my-zsh.yml
Normal file
35
roles/user/shell/zsh/tasks/oh-my-zsh.yml
Normal file
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
- name: Fetch the oh-my-zsh installer
|
||||
ansible.builtin.get_url:
|
||||
url: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
|
||||
dest: /tmp/oh-my-zsh.sh
|
||||
mode: 0700
|
||||
|
||||
- name: Install oh-my-zsh
|
||||
ansible.builtin.command:
|
||||
cmd: sh /tmp/oh-my-zsh.sh --unattended
|
||||
creates: ~/.oh-my-zsh
|
||||
|
||||
- name: Clone zsh-autosuggestions
|
||||
ansible.builtin.git:
|
||||
repo: https://github.com/zsh-users/zsh-autosuggestions
|
||||
dest: ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
|
||||
update: no
|
||||
|
||||
- name: Clone zsh-syntax-highlighting
|
||||
ansible.builtin.git:
|
||||
repo: https://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||
dest: ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
|
||||
update: no
|
||||
|
||||
- name: Clone zsh-aliases-exa
|
||||
ansible.builtin.git:
|
||||
repo: https://github.com/DarrinTisdale/zsh-aliases-exa.git
|
||||
dest: ~/.oh-my-zsh/custom/plugins/zsh-aliases-exa
|
||||
update: no
|
||||
|
||||
- name: Install the config
|
||||
ansible.builtin.copy:
|
||||
src: files/zshrc
|
||||
dest: ~/.zshrc
|
||||
mode: 0600
|
17
roles/user/shell/zsh/tasks/starship.yml
Normal file
17
roles/user/shell/zsh/tasks/starship.yml
Normal file
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
- name: Fetch the starship installer
|
||||
ansible.builtin.get_url:
|
||||
url: https://starship.rs/install.sh
|
||||
dest: /tmp/starship.sh
|
||||
mode: 0700
|
||||
|
||||
- name: Install starship
|
||||
ansible.builtin.command:
|
||||
cmd: sh /tmp/starship.sh -f -b $HOME/.local/bin
|
||||
creates: ~/.local/bin/starship
|
||||
|
||||
- name: Install starship configuration
|
||||
ansible.builtin.copy:
|
||||
src: files/starship.toml
|
||||
dest: ~/.config/starship.toml
|
||||
mode: 0600
|
Loading…
Add table
Add a link
Reference in a new issue