Skip to content

Commit 6f63073

Browse files
committed
feat(shell): migrate from bash to fish shell
1 parent 99f5f37 commit 6f63073

23 files changed

+350
-39
lines changed

chezmoi/.chezmoiignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ ansible
1111

1212
dconf.ini
1313
installed-extensions.txt
14+
15+
# Fish
16+
.config/fish/plugins
17+
.config/fish/completion
18+
.config/fish/fishprof.txt
19+
.config/fish/fish_variables

chezmoi/dot_bash_functions

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,6 @@ function g_commit_and_push() {
66
git push
77
}
88

9-
function g_setup_mr_branch() {
10-
local branch_name="$1"
11-
12-
# Determine default branch on remote
13-
local default_branch="$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')"
14-
15-
# Make sure the default branch is up to date locally
16-
echo "default branch: '${default_branch}'. Updating default branch..."
17-
git switch "${default_branch}"
18-
git pull
19-
20-
echo "creating branch '${branch_name}'..."
21-
git switch -c "${branch_name}" "${default_branch}"
22-
23-
git push -u origin "${branch_name}"
24-
25-
echo "Done!"
26-
}
27-
289
function tfinit() {
2910
export TF_HTTP_USERNAME="tmeijn"
3011

@@ -53,7 +34,7 @@ function tfinit() {
5334

5435
}
5536

56-
# Function to check if a directory has pending changes
37+
# Function to check if a git repository has pending changes
5738
check_git_status() {
5839
find . -type d -name ".git" ! -path "*/.terraform/modules*" -exec dirname {} \; | while read -r dir; do
5940
if [ -d "$dir/.git" ]; then

chezmoi/dot_bash_profile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ if [ -d "$HOME/.local/bin" ] ; then
88
PATH="$HOME/.local/bin:$PATH"
99
fi
1010

11-
eval "$(mise activate bash --shims)"
12-
13-
export AQUA_ROOT_DIR="${XDG_DATA_HOME:-$HOME/.local/share/aquaproj-aqua}"
14-
export PATH="${AQUA_ROOT_DIR}/bin:$PATH"
15-
export AQUA_GLOBAL_CONFIG=${AQUA_GLOBAL_CONFIG:-${XDG_CONFIG_HOME:-$HOME/.config}/aquaproj-aqua/aqua.yaml}
16-
export AQUA_GENERATE_WITH_DETAIL=true
17-
1811
if [ -f "$HOME/.bashrc" ]; then
1912
. "$HOME/.bashrc"
2013
fi

chezmoi/dot_bashrc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ fi
2626
HISTCONTROL=ignoreboth
2727

2828
# append to the history file, don't overwrite it
29-
shopt -s histappend
3029
export PROMPT_COMMAND="history -a"
3130

3231
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
@@ -148,8 +147,6 @@ if command -v rbw &> /dev/null; then
148147
export LAB_CORE_TOKEN="$gitlab_token" && echo "✍🏾 LAB_CORE_TOKEN"
149148
github_token="$(rbw get GITHUB_TOKEN)"
150149
export GITHUB_TOKEN="$github_token" && echo "✍🏾 GITHUB_TOKEN"
151-
jira_token="$(rbw get JIRA_API_TOKEN)"
152-
export JIRA_API_TOKEN="$jira_token" && echo "✍🏾 JIRA_API_TOKEN"
153150
else
154151
echo "🔒 Bitwarden vault locked, not loading tokens. 🔒"
155152
echo "💡 To load tokens run the \`reco\` alias. 💡"

chezmoi/dot_config/aquaproj-aqua/aqua.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,6 @@ packages:
325325
- name: atc0005/[email protected]
326326
description: Small CLI tool used to submit messages to Microsoft Teams
327327
link: https://github.com/atc0005/send2teams
328+
- name: sharkdp/[email protected]
329+
description: A simple, fast and user-friendly alternative to 'find'
330+
link: https://github.com/sharkdp/fd

chezmoi/dot_config/fish/conf.d/.keep

Whitespace-only changes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env fish
2+
3+
abbr --add fish-reload-config 'source ~/.config/fish/**/*.fish'
4+
abbr --add g_commit_and_push --set-cursor 'git commit -am "%" && git push'
5+
abbr --add starwars 'telnet towel.blinkenlights.nl'
6+
abbr --add agi 'aqua g -g -i'
7+
8+
9+
abbr --position anywhere --add p0 "&> /dev/null" # Pipe everything to /dev/null
10+
11+
# Function to set abbreviation if command exists
12+
function set_abbr_if_cmd_exists
13+
set -l cmd $argv[1]
14+
set -l abbr_name $argv[2]
15+
set -l abbr_value $argv[3]
16+
if command -v $cmd >/dev/null
17+
abbr -a $abbr_name $abbr_value
18+
end
19+
end
20+
21+
# Function to set environment variable if command exists
22+
function set_env_if_cmd_exists
23+
set -l cmd $argv[1]
24+
set -l var_name $argv[2]
25+
set -l var_value $argv[3]
26+
if command -v $cmd >/dev/null
27+
set -gx $var_name $var_value
28+
end
29+
end
30+
31+
# Aqua installed tools
32+
set_abbr_if_cmd_exists eza ls eza
33+
set_abbr_if_cmd_exists eza ll "eza -al"
34+
set_abbr_if_cmd_exists bat cat bat
35+
set_abbr_if_cmd_exists gping ping gping
36+
set_abbr_if_cmd_exists hwatch watch hwatch
37+
set_abbr_if_cmd_exists lazydocker lzd lazydocker
38+
set_abbr_if_cmd_exists lazygit lzg lazygit
39+
40+
# Mise installed tools
41+
set_env_if_cmd_exists moar PAGER "moar -no-clear-on-exit"
42+
set_abbr_if_cmd_exists pgcli psql pgcli
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Repeats the last command with `sudo` prefix
2+
alias pls='sudo $history[1]'
3+
4+
# Needed for granted to work, see: https://docs.commonfate.io/granted/internals/shell-alias#grantedinternalsshell-alias
5+
alias assume="source "$(dirname $(aqua which assume))"/assume.fish"
6+
7+
# Terraform aliases
8+
alias tfapply='terraform apply plan.tfplan'
9+
alias tfcopyplan='terraform show -no-color plan.tfplan | pbcopy'
10+
alias tfplan='terraform plan -out=plan.tfplan'
11+
12+
# Helpers for working with Clipboard
13+
alias pbcopy='xclip -selection clipboard'
14+
alias pbpaste='xclip -selection clipboard -o'
15+
alias cb='flatpak run app.getclipboard.Clipboard'
16+
17+
# Provision Hetzner GitLab Runners using scheduled pipelines trigger
18+
alias gl_runner_up='glab -R el-capitano/operations/hetzner-cloud-runners schedule run 2691862'
19+
alias gl_runner_down='glab -R el-capitano/operations/hetzner-cloud-runners schedule run 383558'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Set Aqua variables and paths
2+
if set -q XDG_DATA_HOME
3+
set -gx AQUA_ROOT_DIR "$XDG_DATA_HOME/aquaproj-aqua"
4+
else
5+
set -gx AQUA_ROOT_DIR "$HOME/.local/share/aquaproj-aqua"
6+
end
7+
8+
set -gx PATH "$AQUA_ROOT_DIR/bin" $PATH
9+
10+
if set -q XDG_CONFIG_HOME
11+
set -gx AQUA_GLOBAL_CONFIG "$XDG_CONFIG_HOME/aquaproj-aqua/aqua.yaml"
12+
else
13+
set -gx AQUA_GLOBAL_CONFIG "$HOME/.config/aquaproj-aqua/aqua.yaml"
14+
end
15+
16+
set -gx AQUA_GENERATE_WITH_DETAIL true
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
##############################################
2+
# BITWARDEN: auto load tokens if DB unlocked #
3+
##############################################
4+
5+
function __load_tokens_if_rbw_unlocks --on-event rbw-unlocked
6+
if command -v rbw >/dev/null 2>&1
7+
if rbw unlocked >/dev/null 2>&1
8+
echo "🔓🗝️ Session unlocked, loading tokens from Bitwarden... 🔓🗝️"
9+
10+
load_token OPENAI_API_KEY
11+
load_token GITLAB_TOKEN TF_HTTP_PASSWORD TF_VAR_gitlab_token GL_TOKEN LAB_CORE_TOKEN
12+
load_token GITHUB_TOKEN
13+
else
14+
echo "🔒 Bitwarden vault locked, not loading tokens. 🔒"
15+
echo "💡 To load tokens run the `reco` alias. 💡"
16+
end
17+
end
18+
end
19+
20+
function load_token
21+
set -l token_name $argv[1]
22+
set -l token_value (rbw get $token_name)
23+
set -gx $token_name $token_value
24+
echo "🔓 $token_name"
25+
for alias in $argv[2..-1]
26+
set -gx $alias $token_value
27+
echo "🔓 $alias (alias of $token_name)"
28+
end
29+
end
30+
31+
function reco
32+
rbw unlock
33+
emit rbw-unlocked
34+
end
35+
36+
# Call one time to see if already unlocked.
37+
__load_tokens_if_rbw_unlocks

0 commit comments

Comments
 (0)