mirror of
https://github.com/fscotto/infra.git
synced 2026-05-30 15:39:58 +00:00
Remove tmux-bitwarden plugin and bw install
This commit is contained in:
@@ -389,7 +389,6 @@
|
|||||||
else ''
|
else ''
|
||||||
}}
|
}}
|
||||||
gitmux_version: v0.11.5
|
gitmux_version: v0.11.5
|
||||||
bw_version: 1.22.1
|
|
||||||
opencode_asset_name: >-
|
opencode_asset_name: >-
|
||||||
{{
|
{{
|
||||||
'opencode-linux-x64-baseline.tar.gz' if ansible_facts['architecture'] == 'x86_64'
|
'opencode-linux-x64-baseline.tar.gz' if ansible_facts['architecture'] == 'x86_64'
|
||||||
@@ -407,9 +406,6 @@
|
|||||||
tags: [packages]
|
tags: [packages]
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
gitmux_asset: "gitmux_{{ gitmux_version }}_linux_{{ gitmux_arch }}.tar.gz"
|
gitmux_asset: "gitmux_{{ gitmux_version }}_linux_{{ gitmux_arch }}.tar.gz"
|
||||||
bw_asset: "bw-linux-{{ bw_version }}.zip"
|
|
||||||
bw_checksum: >-
|
|
||||||
sha256:https://github.com/bitwarden/cli/releases/download/v{{ bw_version }}/bw-linux-sha256-{{ bw_version }}.txt
|
|
||||||
|
|
||||||
- name: Ensure architecture is supported for Ollama binary
|
- name: Ensure architecture is supported for Ollama binary
|
||||||
tags: [packages]
|
tags: [packages]
|
||||||
@@ -429,12 +425,6 @@
|
|||||||
msg: "Unsupported architecture {{ ansible_facts['architecture'] }} for gitmux release binary"
|
msg: "Unsupported architecture {{ ansible_facts['architecture'] }} for gitmux release binary"
|
||||||
when: gitmux_arch == ''
|
when: gitmux_arch == ''
|
||||||
|
|
||||||
- name: Ensure architecture is supported for bw binary
|
|
||||||
tags: [packages]
|
|
||||||
ansible.builtin.fail:
|
|
||||||
msg: "Unsupported architecture {{ ansible_facts['architecture'] }} for bw release binary"
|
|
||||||
when: ansible_facts['architecture'] != 'x86_64'
|
|
||||||
|
|
||||||
- name: Ensure temporary directory exists for external tools
|
- name: Ensure temporary directory exists for external tools
|
||||||
tags: [packages]
|
tags: [packages]
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
@@ -485,12 +475,6 @@
|
|||||||
checksum: "sha256:https://github.com/arl/gitmux/releases/download/{{ gitmux_version }}/checksums.txt"
|
checksum: "sha256:https://github.com/arl/gitmux/releases/download/{{ gitmux_version }}/checksums.txt"
|
||||||
extracted_binary: gitmux
|
extracted_binary: gitmux
|
||||||
install_dest: /usr/local/bin/gitmux
|
install_dest: /usr/local/bin/gitmux
|
||||||
- name: bw
|
|
||||||
asset_name: "{{ bw_asset }}"
|
|
||||||
url: "https://github.com/bitwarden/cli/releases/download/v{{ bw_version }}/{{ bw_asset }}"
|
|
||||||
checksum: "{{ bw_checksum }}"
|
|
||||||
extracted_binary: bw
|
|
||||||
install_dest: /usr/local/bin/bw
|
|
||||||
|
|
||||||
- name: Download desktop online archive binary releases
|
- name: Download desktop online archive binary releases
|
||||||
tags: [packages]
|
tags: [packages]
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ set -ga update-environment TERM_PROGRAM
|
|||||||
set -g @plugin 'tmux-plugins/tpm'
|
set -g @plugin 'tmux-plugins/tpm'
|
||||||
set -g @plugin 'tmux-plugins/tmux-sensible'
|
set -g @plugin 'tmux-plugins/tmux-sensible'
|
||||||
set -g @plugin 'sei40kr/tmux-project'
|
set -g @plugin 'sei40kr/tmux-project'
|
||||||
set -g @plugin 'Alkindi42/tmux-bitwarden'
|
|
||||||
set-option -g @plugin 'b0o/tmux-autoreload'
|
set-option -g @plugin 'b0o/tmux-autoreload'
|
||||||
set -g @plugin 'tmux-plugins/tmux-resurrect'
|
set -g @plugin 'tmux-plugins/tmux-resurrect'
|
||||||
set -g @plugin 'tmux-plugins/tmux-continuum'
|
set -g @plugin 'tmux-plugins/tmux-continuum'
|
||||||
@@ -114,10 +113,5 @@ set -g @continuum-restore 'on'
|
|||||||
# Project options
|
# Project options
|
||||||
set -ag @project-base-dirs ,"${HOME}/.dotfiles","${HOME}/Projects:0:2"
|
set -ag @project-base-dirs ,"${HOME}/.dotfiles","${HOME}/Projects:0:2"
|
||||||
|
|
||||||
# Bitwarden plugin setup
|
|
||||||
set -g @bw-session 'BW_SESSION'
|
|
||||||
set -g @bw-copy-to-clipboard 'on'
|
|
||||||
set -g @bw-key 'T'
|
|
||||||
|
|
||||||
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
|
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
|
||||||
run '~/.tmux/plugins/tpm/tpm'
|
run '~/.tmux/plugins/tpm/tpm'
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
# tmux-bitwarden
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
You need to have:
|
|
||||||
* [Bitwarden CLI](https://bitwarden.com/)
|
|
||||||
* [jq](https://stedolan.github.io/jq/)
|
|
||||||
* [fzf](https://github.com/junegunn/fzf)
|
|
||||||
* bash > 4.0
|
|
||||||
|
|
||||||
## Install
|
|
||||||
|
|
||||||
### Tmux Plugin Manager (recommended)
|
|
||||||
1. In your `.tmux.conf` add the plugin to the list.
|
|
||||||
```
|
|
||||||
set -g @plugin 'Alkindi42/tmux-bitwarden'
|
|
||||||
```
|
|
||||||
2. Type `prefix + I` to install the plugin.
|
|
||||||
|
|
||||||
## Key bindings
|
|
||||||
* `prefix + b`: list login items in a bottom pane.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
First, log into your Bitwarden user account using the `login` command (you only need to do this once):
|
|
||||||
```bash
|
|
||||||
$ bw login your-email@domain.com
|
|
||||||
? Master password: [input is hidden]
|
|
||||||
To unlock your vault, set your session key to the `BW_SESSION` environment variable. ex:
|
|
||||||
$ export BW_SESSION="lpvf7Rt+pAMXW2YJ5O42jJp6ZY0Ny01vq9jaUdFYbroS1CXWgjVdy7j42owHVoLwZf+yDI+ro68Qngo9mdD/vA=="
|
|
||||||
> $env:BW_SESSION="lpvf7Rt+pAMXW2YJ5O42jJp6ZY0Ny01vq9jaUdFYbroS1CXWgjVdy7j42owHVoLwZf+yDI+ro68Qngo9mdD/vA=="
|
|
||||||
```
|
|
||||||
|
|
||||||
In a tmux session, you can run the plugin with the default key binding `prefix + b`. This opens a new pane at the bottom with login items. You can choose your login item with `<Enter>`, your password will be automatically filled.
|
|
||||||
|
|
||||||
If you have not configured your bitwarden session (`BW_SESSION`), you will be prompted to re-enter your master password before each selection (see configuration section for more information)
|
|
||||||
|
|
||||||
## Configuration
|
|
||||||
|
|
||||||
### Changing the default key-binding
|
|
||||||
```
|
|
||||||
set -g @bw-key 'T'
|
|
||||||
```
|
|
||||||
Default: `u`
|
|
||||||
|
|
||||||
### Define Bitwarden session
|
|
||||||
To avoid re-entering your master password before each selection, you can define your [session Bitwarden](https://bitwarden.com/help/article/cli/#session-management).
|
|
||||||
Your `BW_SESSION` comes from the result of the `login` command.
|
|
||||||
```
|
|
||||||
set -g @bw-session 'BW_SESSION'
|
|
||||||
```
|
|
||||||
If the `BW_SESSION` variable exists in your environment variable then it will be used.
|
|
||||||
|
|
||||||
### Copy the password to the clipboard
|
|
||||||
By default, after selection, the password is sent in the last pane. If you want to have it in your clipboard you have to activate the option:
|
|
||||||
```
|
|
||||||
set -g @bw-copy-to-clipboard 'on'
|
|
||||||
```
|
|
||||||
Default: `off`
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
declare -r CURRENT_DIR
|
|
||||||
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
source "$CURRENT_DIR/scripts/utils.sh"
|
|
||||||
|
|
||||||
declare -a REQUIRED_BINARIES=(
|
|
||||||
'jq'
|
|
||||||
'fzf'
|
|
||||||
'bw'
|
|
||||||
)
|
|
||||||
|
|
||||||
main() {
|
|
||||||
for binary in "${REQUIRED_BINARIES[@]}"
|
|
||||||
do
|
|
||||||
if ! is_binary_exist "$binary"
|
|
||||||
then
|
|
||||||
display_tmux_message "binary $binary does not exist"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
key_binding=$(get_tmux_option "@bw-key" "b")
|
|
||||||
tmux bind-key "$key_binding" split-window -l 10 "$CURRENT_DIR/scripts/main.sh"
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
declare -r CURRENT_DIR
|
|
||||||
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
source "$CURRENT_DIR/utils.sh"
|
|
||||||
|
|
||||||
is_authenticated() {
|
|
||||||
[[ $(bw status | jq '.status') != "\"unauthenticated\"" ]] && true
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get bitwarden items
|
|
||||||
get_bw_items() {
|
|
||||||
local session="$1"
|
|
||||||
filter='map({ (.name|tostring): .login.password })|add'
|
|
||||||
|
|
||||||
if [[ -z "$session" ]]; then
|
|
||||||
bw list items | jq -r "$filter"
|
|
||||||
else
|
|
||||||
bw list items --session "$session" | jq -r "$filter"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
get_password() {
|
|
||||||
local items=$1
|
|
||||||
local key=$2
|
|
||||||
|
|
||||||
password=$(echo "$items" | jq ".\"$key\"")
|
|
||||||
echo "${password:1:-1}"
|
|
||||||
}
|
|
||||||
|
|
||||||
main() {
|
|
||||||
declare -A TMUX_OPTS=(
|
|
||||||
["@bw-session"]=$(get_tmux_option "@bw-session" "$BW_SESSION")
|
|
||||||
["@bw-copy-to-clipboard"]=$(get_tmux_option "@bw-copy-to-clipboard" "off")
|
|
||||||
)
|
|
||||||
|
|
||||||
is_authenticated
|
|
||||||
if [[ $? -eq 1 ]]; then
|
|
||||||
display_tmux_message "You are not logged in."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
items=$(get_bw_items "${TMUX_OPTS[@bw-session]}")
|
|
||||||
|
|
||||||
# Choice element
|
|
||||||
key=$(echo "$items" | jq --raw-output '.|keys[]' | fzf --no-multi) || return
|
|
||||||
|
|
||||||
password=$(get_password "$items" "$key")
|
|
||||||
|
|
||||||
if [[ "${TMUX_OPTS[@bw-copy-to-clipboard]}" == "on" ]]; then
|
|
||||||
cp_to_clipboard "$password"
|
|
||||||
else
|
|
||||||
# Send the password in the last pane.
|
|
||||||
tmux send-keys -t ! "$password"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
main "$@"
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Copy text to the clipboard
|
|
||||||
cp_to_clipboard() {
|
|
||||||
if [[ "$(uname)" == "Darwin" ]] && is_binary_exist "pbcopy"; then
|
|
||||||
echo -n "$1" | pbcopy
|
|
||||||
elif [[ "$(uname)" == "Linux" ]] && is_binary_exist "wl-copy"; then
|
|
||||||
echo -n "$1" | wl-copy
|
|
||||||
elif [[ "$(uname)" == "Linux" ]] && is_binary_exist "xsel"; then
|
|
||||||
echo -n "$1" | xsel -b
|
|
||||||
elif [[ "$(uname)" == "Linux" ]] && is_binary_exist "xclip"; then
|
|
||||||
echo -n "$1" | xclip -i
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if binary exist
|
|
||||||
is_binary_exist() {
|
|
||||||
local binary=$1
|
|
||||||
|
|
||||||
command -v "$binary" &> /dev/null
|
|
||||||
return $?
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get tmux option
|
|
||||||
get_tmux_option() {
|
|
||||||
local option="$1"
|
|
||||||
local default_value="$2"
|
|
||||||
local option_value
|
|
||||||
option_value=$(tmux show-option -gqv "$option")
|
|
||||||
|
|
||||||
if [[ -z "$option_value" ]]; then
|
|
||||||
echo "$default_value"
|
|
||||||
else
|
|
||||||
echo "$option_value"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Display tmux message in status bar
|
|
||||||
display_tmux_message() {
|
|
||||||
local message=$1
|
|
||||||
tmux display-message "tmux-bitwarden: $message"
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user