From ea82cbb1c0b778dd946c717cceace53fab391ba8 Mon Sep 17 00:00:00 2001 From: Tom Li Dobnik Date: Sat, 9 Aug 2025 17:12:43 +0200 Subject: init --- .config/fish/config.fish | 81 +++++++++++++++++++++++++++++ .config/fish/fish_variables | 43 ++++++++++++++++ .config/fish/functions/fish_prompt.fish | 91 +++++++++++++++++++++++++++++++++ 3 files changed, 215 insertions(+) create mode 100644 .config/fish/config.fish create mode 100644 .config/fish/fish_variables create mode 100644 .config/fish/functions/fish_prompt.fish (limited to '.config/fish') diff --git a/.config/fish/config.fish b/.config/fish/config.fish new file mode 100644 index 0000000..9c5de4a --- /dev/null +++ b/.config/fish/config.fish @@ -0,0 +1,81 @@ +if status is-interactive + clear +end + +function fish_greeting; end + +function f + set tmp (mktemp -t "yazi-cwd.XXXXXX") + yazi $argv --cwd-file="$tmp" + if set cwd (command cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ] + builtin cd -- "$cwd" + end + rm -f -- "$tmp" +end + +function lt; + eza --tree --color=always --icons=always --level=$argv +end + +function a + set max_depth 5 + set current_depth 0 + set dir (pwd) + + while test $current_depth -lt $max_depth + if test -d "$dir/venv" + source "$dir/venv/bin/activate.fish" + return 0 + end + set dir (dirname $dir) + set current_depth (math $current_depth + 1) + end + + echo "venv folder not found within $max_depth levels." + return 1 +end + +function gitzip + git ls-files | zip archive.zip -@ +end + +alias c=clear +alias g=fg +alias v=nvim +alias vv="nvim ." +alias ic="cd ~/Library/Mobile Documents/com~apple~CloudDocs" +alias cc="clear & cd" +alias l="eza --color=always --long --git --no-filesize --icons=always --no-time --no-user --no-permissions --group-directories-first" +alias ll="eza --color=always --long --git --icons=always --no-user --group-directories-first" +alias la="eza -a --color=always --long --git --no-filesize --icons=always --no-time --no-user --no-permissions --group-directories-first" +alias ff="fastfetch" +alias p=pgcli +alias t="tmux attach" +alias d="deactivate" +alias venv="python3 -m venv venv" +alias cd="z" +alias gi="git init && aig" +alias gs="git status" +alias aig="cp ~/.config/.gitignore-template ./.gitignore" +alias u="uv run" + + +function ga + git add -A + git commit -m "auto" +end + +# Created by `pipx` on 2024-11-25 11:43:56 +set PATH $PATH /Users/tom/.local/bin +# Cargo path +set PATH $HOME/.cargo/bin $PATH + +eval "$(/opt/homebrew/bin/brew shellenv)" +zoxide init fish | source +atuin init fish --disable-up-arrow | source +export EDITOR="nvim" + +# uv +fish_add_path "/Users/tomiko/.local/bin" + +starship init fish | source diff --git a/.config/fish/fish_variables b/.config/fish/fish_variables new file mode 100644 index 0000000..eb2b27e --- /dev/null +++ b/.config/fish/fish_variables @@ -0,0 +1,43 @@ +# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR __fish_initialized:3800 +SETUVAR fish_color_autosuggestion:4c566a +SETUVAR fish_color_cancel:\x2d\x2dreverse +SETUVAR fish_color_command:88c0d0 +SETUVAR fish_color_comment:4c566a\x1e\x2d\x2ditalics +SETUVAR fish_color_cwd:5e81ac +SETUVAR fish_color_cwd_root:bf616a +SETUVAR fish_color_end:81a1c1 +SETUVAR fish_color_error:bf616a +SETUVAR fish_color_escape:ebcb8b +SETUVAR fish_color_history_current:e5e9f0\x1e\x2d\x2dbold +SETUVAR fish_color_host:a3be8c +SETUVAR fish_color_host_remote:ebcb8b +SETUVAR fish_color_keyword:81a1c1 +SETUVAR fish_color_match:\x2d\x2dbackground\x3dbrblue +SETUVAR fish_color_normal:normal +SETUVAR fish_color_operator:81a1c1 +SETUVAR fish_color_option:8fbcbb +SETUVAR fish_color_param:d8dee9 +SETUVAR fish_color_quote:a3be8c +SETUVAR fish_color_redirection:b48ead\x1e\x2d\x2dbold +SETUVAR fish_color_search_match:\x2d\x2dbold\x1e\x2d\x2dbackground\x3d434c5e +SETUVAR fish_color_selection:d8dee9\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3d434c5e +SETUVAR fish_color_status:bf616a +SETUVAR fish_color_user:a3be8c +SETUVAR fish_color_valid_path:\x2d\x2dunderline +SETUVAR fish_key_bindings:fish_default_key_bindings +SETUVAR fish_pager_color_background:\x1d +SETUVAR fish_pager_color_completion:e5e9f0 +SETUVAR fish_pager_color_description:ebcb8b\x1e\x2d\x2ditalics +SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline +SETUVAR fish_pager_color_progress:3b4252\x1e\x2d\x2dbackground\x3dd08770 +SETUVAR fish_pager_color_secondary_background:\x1d +SETUVAR fish_pager_color_secondary_completion:\x1d +SETUVAR fish_pager_color_secondary_description:\x1d +SETUVAR fish_pager_color_secondary_prefix:\x1d +SETUVAR fish_pager_color_selected_background:\x2d\x2dbackground\x3d434c5e +SETUVAR fish_pager_color_selected_completion:\x1d +SETUVAR fish_pager_color_selected_description:\x1d +SETUVAR fish_pager_color_selected_prefix:\x1d +SETUVAR fish_user_paths:/Users/tomiko/\x2elocal/bin diff --git a/.config/fish/functions/fish_prompt.fish b/.config/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..1e5e722 --- /dev/null +++ b/.config/fish/functions/fish_prompt.fish @@ -0,0 +1,91 @@ +function fish_prompt + set -l __last_command_exit_status $status + + if not set -q -g __fish_arrow_functions_defined + set -g __fish_arrow_functions_defined + function _git_branch_name + set -l branch (git symbolic-ref --quiet HEAD 2>/dev/null) + if set -q branch[1] + echo (string replace -r '^refs/heads/' '' $branch) + else + echo (git rev-parse --short HEAD 2>/dev/null) + end + end + + function _is_git_dirty + not command git diff-index --cached --quiet HEAD -- &>/dev/null + or not command git diff --no-ext-diff --quiet --exit-code &>/dev/null + end + + function _is_git_repo + type -q git + or return 1 + git rev-parse --git-dir >/dev/null 2>&1 + end + + function _hg_branch_name + echo (hg branch 2>/dev/null) + end + + function _is_hg_dirty + set -l stat (hg status -mard 2>/dev/null) + test -n "$stat" + end + + function _is_hg_repo + fish_print_hg_root >/dev/null + end + + function _repo_branch_name + _$argv[1]_branch_name + end + + function _is_repo_dirty + _is_$argv[1]_dirty + end + + function _repo_type + if _is_hg_repo + echo hg + return 0 + else if _is_git_repo + echo git + return 0 + end + return 1 + end + end + + set -l cyan (set_color -o cyan) + set -l yellow (set_color -o yellow) + set -l red (set_color -o red) + set -l green (set_color -o green) + set -l blue (set_color -o blue) + set -l normal (set_color normal) + + set -l arrow_color "$green" + if test $__last_command_exit_status != 0 + set arrow_color "$red" + end + + set -l arrow "$arrow_color➜ " + if fish_is_root_user + set arrow "$arrow_color# " + end + + set -l cwd $yellow(prompt_pwd) + + set -l repo_info + if set -l repo_type (_repo_type) + set -l repo_branch $red(_repo_branch_name $repo_type) + set repo_info "$cyan $repo_type:($repo_branch$cyan)" + + if _is_repo_dirty $repo_type + set -l dirty "$yellow ✗" + set repo_info "$repo_info$dirty" + end + end + + echo $arrow $cwd $repo_info $normal + # echo $arrow +end -- cgit v1.2.3