better stow (vielleicht :/

This commit is contained in:
2025-11-10 19:49:56 +01:00
parent 89a95d9bd7
commit 94118d682b
61 changed files with 139 additions and 19 deletions

2
config/shell/.config/fish/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
fish_variables
fish_plugins

View File

@@ -0,0 +1,15 @@
#!/bin/bash
path=$(dirname "$(readlink -f "$0")")
[ -f "$HOME/.local/snippets/apply-color-helper" ] || {
echo "Missing helper script: $HOME/.local/snippets/apply-color-helper"
exit 1
}
. "$HOME/.local/snippets/apply-color-helper"
kvantummanager --set catppuccin-mocha-"$colorName" || {
log_error "Failed to set kvantum theme to catppuccin-mocha-${colorName}"
exit 1
}
log_success "kvantum"

View File

@@ -0,0 +1,19 @@
#!/bin/bash
path=$(dirname "$(readlink -f "$0")")
[ -f "$HOME/.local/snippets/apply-color-helper" ] || {
echo "Missing helper script: $HOME/.local/snippets/apply-color-helper"
exit 1
}
. "$HOME/.local/snippets/apply-color-helper"
file="$HOME/.local/share/nwg-look/gsettings"
sed -i -E "s/^(gtk-theme=catppuccin-mocha-)[^-]+(-standard\+default)$/\1${colorName}\2/" "$file" || {
log_error "Failed to edit ${file}"
exit 1
}
nwg-look -a -x
log_success "nwg-look"

View File

@@ -0,0 +1,64 @@
#!/bin/bash
path=$(dirname "$(readlink -f "$0")")
[ -f "$HOME/.local/snippets/apply-color-helper" ] || {
echo "Missing helper script: $HOME/.local/snippets/apply-color-helper"
exit 1
}
. "$HOME/.local/snippets/apply-color-helper"
file="$path"/../posh_theme.omp.json
targetTypes=("os" "session" "status")
if ! python3 - "$file" "$colorHex" "${targetTypes[@]}"; then {
log_error "Failed to edit ${file}"
exit 1
} fi <<EOF
import json
import sys
data = None
file = sys.argv[1]
colorHex = sys.argv[2]
targetTypes = sys.argv[3:]
with open(file, "r") as f:
data = json.load(f)
def processSegments(segments):
for segment in segments:
if "type" in segment and segment["type"] in targetTypes:
if "foreground" in segment:
segment["foreground"] = f"#{colorHex}"
def processTransientPrompt(transientPrompt):
if "foreground" in transientPrompt:
transientPrompt["foreground"] = f"#{colorHex}"
def process(obj):
if isinstance(obj, dict):
for k, v in obj.items():
if k == "segments" and isinstance(v, list):
processSegments(v)
elif k == "transient_prompt" and isinstance(v, dict):
processTransientPrompt(v)
else:
process(v)
elif isinstance(obj, list):
for item in obj:
process(item)
process(data)
if data is not None:
with open(file, "w") as f:
json.dump(data, f, indent=4)
EOF
if [ $? -ne 0 ]; then
log_error "Failed to edit ${file}"
exit 1
fi
log_success "oh-my-posh"

View File

@@ -0,0 +1,22 @@
if not status is-interactive
return
end
# no greeting
set fish_greeting
if test -d $HOME/.config/fish/prev.d
for file in $HOME/.config/fish/prev.d/*.fish
if test -f $file
source $file
end
end
end
if test -d $HOME/.config/fish/post.d
for file in $HOME/.config/fish/post.d/*.fish
if test -f $file
source $file
end
end
end

View File

@@ -0,0 +1,137 @@
from __future__ import print_function
import json
import os
import signal
import subprocess
import sys
import traceback
BASH = 'bash'
FISH_READONLY = [
'PWD', 'SHLVL', 'history', 'pipestatus', 'status', 'version',
'FISH_VERSION', 'fish_pid', 'hostname', '_', 'fish_private_mode'
]
IGNORED = [
'PS1', 'XPC_SERVICE_NAME'
]
def ignored(name):
if name == 'PWD': # this is read only, but has special handling
return False
# ignore other read only variables
if name in FISH_READONLY:
return True
if name in IGNORED or name.startswith("BASH_FUNC"):
return True
if name.startswith('%'):
return True
return False
def escape(string):
# use json.dumps to reliably escape quotes and backslashes
return json.dumps(string).replace(r'$', r'\$')
def escape_identifier(word):
return escape(word.replace('?', '\\?'))
def comment(string):
return '\n'.join(['# ' + line for line in string.split('\n')])
def gen_script():
# Use the following instead of /usr/bin/env to read environment so we can
# deal with multi-line environment variables (and other odd cases).
env_reader = "%s -c 'import os,json; print(json.dumps({k:v for k,v in os.environ.items()}))'" % (sys.executable)
args = [BASH, '-c', env_reader]
output = subprocess.check_output(args, universal_newlines=True)
old_env = output.strip()
pipe_r, pipe_w = os.pipe()
if sys.version_info >= (3, 4):
os.set_inheritable(pipe_w, True)
command = 'eval $1 && ({}; alias) >&{}'.format(
env_reader,
pipe_w
)
args = [BASH, '-c', command, 'bass', ' '.join(sys.argv[1:])]
p = subprocess.Popen(args, universal_newlines=True, close_fds=False)
os.close(pipe_w)
with os.fdopen(pipe_r) as f:
new_env = f.readline()
alias_str = f.read()
if p.wait() != 0:
raise subprocess.CalledProcessError(
returncode=p.returncode,
cmd=' '.join(sys.argv[1:]),
output=new_env + alias_str
)
new_env = new_env.strip()
old_env = json.loads(old_env)
new_env = json.loads(new_env)
script_lines = []
for k, v in new_env.items():
if ignored(k):
continue
v1 = old_env.get(k)
if not v1:
script_lines.append(comment('adding %s=%s' % (k, v)))
elif v1 != v:
script_lines.append(comment('updating %s=%s -> %s' % (k, v1, v)))
# process special variables
if k == 'PWD':
script_lines.append('cd %s' % escape(v))
continue
else:
continue
if k == 'PATH':
value = ' '.join([escape(directory)
for directory in v.split(':')])
else:
value = escape(v)
script_lines.append('set -g -x %s %s' % (k, value))
for var in set(old_env.keys()) - set(new_env.keys()):
script_lines.append(comment('removing %s' % var))
script_lines.append('set -e %s' % var)
script = '\n'.join(script_lines)
alias_lines = []
for line in alias_str.splitlines():
_, rest = line.split(None, 1)
k, v = rest.split("=", 1)
alias_lines.append("alias " + escape_identifier(k) + "=" + v)
alias = '\n'.join(alias_lines)
return script + '\n' + alias
script_file = os.fdopen(3, 'w')
if not sys.argv[1:]:
print('__bass_usage', file=script_file, end='')
sys.exit(0)
try:
script = gen_script()
except subprocess.CalledProcessError as e:
sys.exit(e.returncode)
except Exception:
print('Bass internal error!', file=sys.stderr)
raise # traceback will output to stderr
except KeyboardInterrupt:
signal.signal(signal.SIGINT, signal.SIG_DFL)
os.kill(os.getpid(), signal.SIGINT)
else:
script_file.write(script)

View File

@@ -0,0 +1,29 @@
function bass
set -l bash_args $argv
set -l bass_debug
if test "$bash_args[1]_" = '-d_'
set bass_debug true
set -e bash_args[1]
end
set -l script_file (mktemp)
if command -v python3 >/dev/null 2>&1
command python3 -sS (dirname (status -f))/__bass.py $bash_args 3>$script_file
else
command python -sS (dirname (status -f))/__bass.py $bash_args 3>$script_file
end
set -l bass_status $status
if test $bass_status -ne 0
return $bass_status
end
if test -n "$bass_debug"
cat $script_file
end
source $script_file
command rm $script_file
end
function __bass_usage
echo "Usage: bass [-d] <bash-command>"
end

View File

@@ -0,0 +1,5 @@
*
!.gitignore
!fetch.fish
!fetch.fish.template
!sshs.fish

View File

@@ -0,0 +1,38 @@
if not set -q fetch_logo_type
set -g fetch_logo_type "auto"
end
if not set -q fetch_color
set -g fetch_color "#89b4fa"
end
if test "$fetch_logo_type" = "symbols"
set -g fetch_args "--logo-type raw --logo-width 42 --logo \"$HOME/.config/fastfetch/logo_ros/42x.symbols\" --color \"$fetch_color\""
set -g fetch_args_brief "--logo-type raw --logo-width 28 --logo \"$HOME/.config/fastfetch/logo_ros/28x.symbols\" --color \"$fetch_color\""
else if test "$fetch_logo_type" = "logo"
set -g fetch_args "--logo-type builtin"
set -g fetch_args_brief "--logo-type small"
else if test "$fetch_logo_type" = "sixel"
set -g fetch_args "--logo-type raw --logo-width 42 --logo \"$HOME/.config/fastfetch/logo_ros/42x.sixel\" --color \"$fetch_color\""
set -g fetch_args_brief "--logo-type raw --logo-width 28 --logo \"$HOME/.config/fastfetch/logo_ros/28x.sixel\" --color \"$fetch_color\""
else # "kitty" or "auto" and others
set -g fetch_args "--logo-type $fetch_logo_type --logo-width 42 --logo \"$HOME/.config/fastfetch/logo_ros/ros.png\" --color \"$fetch_color\""
set -g fetch_args_brief "--logo-type $fetch_logo_type --logo-width 28 --logo \"$HOME/.config/fastfetch/logo_ros/ros.png\" --color \"$fetch_color\""
end
if type -q fastfetch
alias ff="fastfetch -c $HOME/.config/fastfetch/config.jsonc $fetch_args"
if test -f "$HOME/.config/fastfetch/brief.jsonc"
alias ff-brief="fastfetch -c $HOME/.config/fastfetch/brief.jsonc $fetch_args_brief"
else
alias ff-brief=ff
end
end
# add 'set -g no_fetch' somewhere other than post.d to disable fetching
if not set -q no_fetch
if type -q ff-brief
ff-brief
end
end

View File

@@ -0,0 +1,14 @@
# ssh with encrypted private keys
# $ssh_keys should be set in advance or left empty to use the default keys
if type -q ssh
bass $(ssh-init) > /dev/null 2>&1
# avoiding entering passphrase every time
function sshs
# test if keys are added to ssh-agent
if not ssh-add -l > /dev/null 2>&1
ssh-add $ssh_keys
end
ssh $argv
end
end

View File

@@ -0,0 +1,6 @@
*
!.gitignore
!prompt.fish
!theme.fish
!alias.fish
!env.fish

View File

@@ -0,0 +1,54 @@
# fzf
if type -q fzf
fzf --fish | source
if type -q wl-copy
function fzc
fzf $argv | string collect | wl-copy
end
end
if type -q bat
alias fz="fzf --preview 'bat --style=numbers --color=always {}'"
end
end
# cd
if type -q zoxide
zoxide init fish | source
alias cd=z
end
# rm
if type -q trash
alias rm="echo \"use 'trash' instead :)\" && sh -c \"exit 42\""
end
# ls
if type -q eza
alias ll="eza -lh --group-directories-first --icons=auto"
alias la="eza -lh --group-directories-first --icons=auto --all"
alias lt="eza --tree --level=2 --long --icons --git"
else
alias ll="ls -lh --group-directories-first --color=auto"
alias la="ls -lah --group-directories-first --color=auto"
end
# directories
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
# grep
alias grep="grep --color=auto"
# nvim
if type -q nvim
set -x -g EDITOR nvim
set -x -g VISUAL nvim
end
# others
if type -q tty-clock
alias clock="tty-clock -c -C 4"
end

View File

@@ -0,0 +1,13 @@
# PATH
fish_add_path $HOME/.local/scripts
fish_add_path $HOME/.local/bin
fish_add_path $HOME/.cargo/bin
fish_add_path $HOME/go/bin
# man
if type -q bat
set -x -g MANPAGER "sh -c 'col -bx | bat -l man -p'"
set -x -g MANROFFOPT -c
end
set -x -g GPG_TTY $(tty)

View File

@@ -0,0 +1,12 @@
function fish_prompt -d "Write out the prompt"
# This shows up as USER@HOST /home/user/ >, with the directory colored
# $USER and $hostname are set by fish, so you can just use them
# instead of using `whoami` and `hostname`
printf '%s@%s %s%s%s > ' $USER $hostname \
(set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
end
# oh-my-posh
if test -f $HOME/.config/posh_theme.omp.json; and type -q oh-my-posh
oh-my-posh init fish --config $HOME/.config/posh_theme.omp.json | source
end

View File

@@ -0,0 +1,6 @@
set -l theme 'Catppuccin Mocha'
if not set -q fish_current_theme; or not string match -q "$theme" "$fish_current_theme"
set -U fish_current_theme "$theme"
fish_config theme save "$theme"
end

View File

@@ -0,0 +1,30 @@
# name: 'Catppuccin Frappé'
# url: 'https://github.com/catppuccin/fish'
# preferred_background: 303446
fish_color_normal c6d0f5
fish_color_command 8caaee
fish_color_param eebebe
fish_color_keyword e78284
fish_color_quote a6d189
fish_color_redirection f4b8e4
fish_color_end ef9f76
fish_color_comment 838ba7
fish_color_error e78284
fish_color_gray 737994
fish_color_selection --background=414559
fish_color_search_match --background=414559
fish_color_option a6d189
fish_color_operator f4b8e4
fish_color_escape ea999c
fish_color_autosuggestion 737994
fish_color_cancel e78284
fish_color_cwd e5c890
fish_color_user 81c8be
fish_color_host 8caaee
fish_color_host_remote a6d189
fish_color_status e78284
fish_pager_color_progress 737994
fish_pager_color_prefix f4b8e4
fish_pager_color_completion c6d0f5
fish_pager_color_description 737994

View File

@@ -0,0 +1,30 @@
# name: 'Catppuccin Latte'
# url: 'https://github.com/catppuccin/fish'
# preferred_background: eff1f5
fish_color_normal 4c4f69
fish_color_command 1e66f5
fish_color_param dd7878
fish_color_keyword d20f39
fish_color_quote 40a02b
fish_color_redirection ea76cb
fish_color_end fe640b
fish_color_comment 8c8fa1
fish_color_error d20f39
fish_color_gray 9ca0b0
fish_color_selection --background=ccd0da
fish_color_search_match --background=ccd0da
fish_color_option 40a02b
fish_color_operator ea76cb
fish_color_escape e64553
fish_color_autosuggestion 9ca0b0
fish_color_cancel d20f39
fish_color_cwd df8e1d
fish_color_user 179299
fish_color_host 1e66f5
fish_color_host_remote 40a02b
fish_color_status d20f39
fish_pager_color_progress 9ca0b0
fish_pager_color_prefix ea76cb
fish_pager_color_completion 4c4f69
fish_pager_color_description 9ca0b0

View File

@@ -0,0 +1,30 @@
# name: 'Catppuccin Macchiato'
# url: 'https://github.com/catppuccin/fish'
# preferred_background: 24273a
fish_color_normal cad3f5
fish_color_command 8aadf4
fish_color_param f0c6c6
fish_color_keyword ed8796
fish_color_quote a6da95
fish_color_redirection f5bde6
fish_color_end f5a97f
fish_color_comment 8087a2
fish_color_error ed8796
fish_color_gray 6e738d
fish_color_selection --background=363a4f
fish_color_search_match --background=363a4f
fish_color_option a6da95
fish_color_operator f5bde6
fish_color_escape ee99a0
fish_color_autosuggestion 6e738d
fish_color_cancel ed8796
fish_color_cwd eed49f
fish_color_user 8bd5ca
fish_color_host 8aadf4
fish_color_host_remote a6da95
fish_color_status ed8796
fish_pager_color_progress 6e738d
fish_pager_color_prefix f5bde6
fish_pager_color_completion cad3f5
fish_pager_color_description 6e738d

View File

@@ -0,0 +1,30 @@
# name: 'Catppuccin Mocha'
# url: 'https://github.com/catppuccin/fish'
# preferred_background: 1e1e2e
fish_color_normal cdd6f4
fish_color_command 89b4fa
fish_color_param f2cdcd
fish_color_keyword f38ba8
fish_color_quote a6e3a1
fish_color_redirection f5c2e7
fish_color_end fab387
fish_color_comment 7f849c
fish_color_error f38ba8
fish_color_gray 6c7086
fish_color_selection --background=313244
fish_color_search_match --background=313244
fish_color_option a6e3a1
fish_color_operator f5c2e7
fish_color_escape eba0ac
fish_color_autosuggestion 6c7086
fish_color_cancel f38ba8
fish_color_cwd f9e2af
fish_color_user 94e2d5
fish_color_host 89b4fa
fish_color_host_remote a6e3a1
fish_color_status f38ba8
fish_pager_color_progress 6c7086
fish_pager_color_prefix f5c2e7
fish_pager_color_completion cdd6f4
fish_pager_color_description 6c7086

View File

@@ -0,0 +1,97 @@
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"foreground": "#89b4fa",
"properties": {
"windows": "\ue62a"
},
"style": "plain",
"template": "{{.Icon}}",
"type": "os"
},
{
"foreground": "#89b4fa",
"style": "plain",
"template": " {{.UserName}}",
"type": "session"
},
{
"foreground": "#89b4fa",
"style": "plain",
"template": "@{{.HostName}}",
"type": "session"
},
{
"foreground": "#94e2d5",
"properties": {
"folder_separator_icon": "/",
"style": "letter"
},
"style": "powerline",
"template": " \uf07b {{ .Path }} ",
"type": "path"
},
{
"foreground": "#a6e3a1",
"powerline_symbol": "\ue0b1",
"properties": {
"branch_icon": " ",
"fetch_stash_count": true,
"fetch_status": true,
"fetch_upstream_icon": true,
"fetch_worktree_count": true
},
"style": "powerline",
"template": " {{ .UpstreamIcon }} {{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} \ueb4b {{ .StashCount }}{{ end }} ",
"type": "git"
},
{
"foreground": "#f9e2af",
"powerline_symbol": "\ue0b1",
"template": " \ue235 {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }} ",
"style": "powerline",
"type": "python"
}
],
"type": "prompt"
},
{
"alignment": "left",
"newline": true,
"segments": [
{
"foreground": "#fab387",
"style": "plain",
"template": "\ue3bf ",
"type": "root"
},
{
"foreground": "#89b4fa",
"foreground_templates": [
"{{ if gt .Code 0 }}#f38ba8{{ end }}"
],
"properties": {
"always_enabled": true
},
"style": "plain",
"template": "{{ if gt .Code 0 }}{{ .Code }} {{ end }}# ",
"type": "status"
}
],
"type": "prompt"
}
],
"transient_prompt": {
"background": "transparent",
"foreground_templates": [
"{{ if gt .Code 0 }}#f38ba8{{ end }}"
],
"foreground": "#89b4fa",
"template": "# "
},
"version": 3
}