From 06a1116840e2a01f1b8f91ed547bf8dda6d012a7 Mon Sep 17 00:00:00 2001 From: Yi-Ting Shih Date: Thu, 10 Apr 2025 03:54:27 +0800 Subject: [PATCH] Initial commit --- config.fish | 4 ++++ fish_variables | 33 +++++++++++++++++++++++++++++++++ functions/fish_prompt.fish | 26 ++++++++++++++++++++++++++ functions/k.fish | 4 ++++ functions/kctx.fish | 4 ++++ functions/kns.fish | 4 ++++ functions/mctl.fish | 4 ++++ functions/pctl.fish | 4 ++++ functions/rgrep.fish | 4 ++++ functions/tree.fish | 4 ++++ 10 files changed, 91 insertions(+) create mode 100644 config.fish create mode 100644 fish_variables create mode 100644 functions/fish_prompt.fish create mode 100644 functions/k.fish create mode 100644 functions/kctx.fish create mode 100644 functions/kns.fish create mode 100644 functions/mctl.fish create mode 100644 functions/pctl.fish create mode 100644 functions/rgrep.fish create mode 100644 functions/tree.fish diff --git a/config.fish b/config.fish new file mode 100644 index 0000000..fb85e4d --- /dev/null +++ b/config.fish @@ -0,0 +1,4 @@ +if status is-interactive + # Commands to run in interactive sessions can go here + fish_add_path "$HOME/.local/bin" +end diff --git a/fish_variables b/fish_variables new file mode 100644 index 0000000..83cea8f --- /dev/null +++ b/fish_variables @@ -0,0 +1,33 @@ +# This file contains fish universal variable definitions. +# VERSION: 3.0 +SETUVAR __fish_initialized:3800 +SETUVAR fish_color_autosuggestion:brblack +SETUVAR fish_color_cancel:\x2dr +SETUVAR fish_color_command:blue +SETUVAR fish_color_comment:red +SETUVAR fish_color_cwd:green +SETUVAR fish_color_cwd_root:red +SETUVAR fish_color_end:green +SETUVAR fish_color_error:brred +SETUVAR fish_color_escape:brcyan +SETUVAR fish_color_history_current:\x2d\x2dbold +SETUVAR fish_color_host:normal +SETUVAR fish_color_host_remote:yellow +SETUVAR fish_color_normal:normal +SETUVAR fish_color_operator:brcyan +SETUVAR fish_color_param:cyan +SETUVAR fish_color_quote:yellow +SETUVAR fish_color_redirection:cyan\x1e\x2d\x2dbold +SETUVAR fish_color_search_match:white\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack +SETUVAR fish_color_status:red +SETUVAR fish_color_user:brgreen +SETUVAR fish_color_valid_path:\x2d\x2dunderline +SETUVAR fish_greeting:\x1d +SETUVAR fish_key_bindings:fish_default_key_bindings +SETUVAR fish_pager_color_completion:normal +SETUVAR fish_pager_color_description:yellow\x1e\x2di +SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline +SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan +SETUVAR fish_pager_color_selected_background:\x2dr +SETUVAR fish_user_paths:/home/ytshih/\x2elocal/bin diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish new file mode 100644 index 0000000..9f2d072 --- /dev/null +++ b/functions/fish_prompt.fish @@ -0,0 +1,26 @@ +function fish_prompt --description 'Informative prompt' + #Save the return status of the previous command + set -l last_pipestatus $pipestatus + set -lx __fish_last_status $status # Export for __fish_print_pipestatus. + + if functions -q fish_is_root_user; and fish_is_root_user + printf '%s@%s %s%s%s# ' $USER (prompt_hostname) (set -q fish_color_cwd_root + and set_color $fish_color_cwd_root + or set_color $fish_color_cwd) \ + (prompt_pwd) (set_color normal) + else + set -l status_color (set_color $fish_color_status) + set -l statusb_color (set_color --bold $fish_color_status) + set -l pipestatus_string (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus) + + set -l cwd (pwd) + if git rev-parse --is-inside-work-tree >/dev/null 2>&1 + set -l git_root (git rev-parse --show-toplevel) + set -l git_root_basename (basename "$git_root") + set cwd (string replace --regex "^$git_root" "($git_root_basename)" "$cwd") + end + printf '[%s] %s%s@%s %s%s %s%s%s%s%s \n> ' (date "+%H:%M:%S") (set_color brblue) \ + $USER (prompt_hostname) (set_color $fish_color_cwd) $cwd $pipestatus_string \ + (set_color yellow) (string trim -l (fish_git_prompt)) (set_color normal) + end +end diff --git a/functions/k.fish b/functions/k.fish new file mode 100644 index 0000000..d90b6b4 --- /dev/null +++ b/functions/k.fish @@ -0,0 +1,4 @@ +function k --wraps=kubectl --description 'alias k kubectl' + kubectl $argv + +end diff --git a/functions/kctx.fish b/functions/kctx.fish new file mode 100644 index 0000000..31d6e4e --- /dev/null +++ b/functions/kctx.fish @@ -0,0 +1,4 @@ +function kctx --wraps='kubectl config use-context' --description 'alias kctx kubectl config use-context' + kubectl config use-context $argv + +end diff --git a/functions/kns.fish b/functions/kns.fish new file mode 100644 index 0000000..db0562b --- /dev/null +++ b/functions/kns.fish @@ -0,0 +1,4 @@ +function kns --wraps='kubectl config set-context --current --namespace' --description 'alias kns kubectl config set-context --current --namespace' + kubectl config set-context --current --namespace $argv + +end diff --git a/functions/mctl.fish b/functions/mctl.fish new file mode 100644 index 0000000..8ed5a86 --- /dev/null +++ b/functions/mctl.fish @@ -0,0 +1,4 @@ +function mctl --wraps='sudo machinectl' --description 'alias mctl sudo machinectl' + sudo machinectl $argv + +end diff --git a/functions/pctl.fish b/functions/pctl.fish new file mode 100644 index 0000000..67818c8 --- /dev/null +++ b/functions/pctl.fish @@ -0,0 +1,4 @@ +function pctl --wraps='sudo portablectl' --description 'alias pctl sudo portablectl' + sudo portablectl $argv + +end diff --git a/functions/rgrep.fish b/functions/rgrep.fish new file mode 100644 index 0000000..45c64cd --- /dev/null +++ b/functions/rgrep.fish @@ -0,0 +1,4 @@ +function rgrep --wraps='grep -rE' --wraps=grep --wraps='grep -rnE' --description 'alias rgrep grep -rnE' + grep -rnE $argv + +end diff --git a/functions/tree.fish b/functions/tree.fish new file mode 100644 index 0000000..316da4b --- /dev/null +++ b/functions/tree.fish @@ -0,0 +1,4 @@ +function tree --description 'alias tree tree -C' + command tree -C $argv + +end