refactor: use __fish_palette in small utility functions (1/2)
37 duplicated declarations replaced by 8 calls. Output strings untouched; byte-identical across 29 harness cases.
This commit is contained in:
+1
-4
@@ -25,10 +25,7 @@
|
||||
function bkg --description 'Execute bkg'
|
||||
# Check if a command was provided as an argument.
|
||||
if test -z "$argv[1]"
|
||||
set -l c_head (set_color --bold cyan)
|
||||
set -l c_cmd (set_color --bold)
|
||||
set -l c_arg (set_color cyan)
|
||||
set -l c_reset (set_color normal)
|
||||
__fish_palette
|
||||
echo "$c_head""Usage:$c_reset $c_cmd""bkg$c_reset $c_arg""<command> [arguments...]$c_reset"
|
||||
return 1
|
||||
end
|
||||
|
||||
@@ -25,11 +25,7 @@
|
||||
# EXAMPLE
|
||||
# detach rsync -a ./data remote:/backup/
|
||||
function detach --description 'Execute detach'
|
||||
set -l c_head (set_color --bold cyan)
|
||||
set -l c_cmd (set_color --bold)
|
||||
set -l c_flag (set_color yellow)
|
||||
set -l c_arg (set_color cyan)
|
||||
set -l c_reset (set_color normal)
|
||||
__fish_palette
|
||||
|
||||
set -l show_help 0
|
||||
set -l args
|
||||
|
||||
@@ -38,11 +38,7 @@ function dng2avif --description 'Convert DNG raw to 10-bit HDR AVIF'
|
||||
|
||||
# Help Screen
|
||||
if set -q _flag_help; or test (count $argv) -eq 0 -a -z "$_flag_input"
|
||||
set -l c_head (set_color --bold cyan)
|
||||
set -l c_cmd (set_color --bold)
|
||||
set -l c_flag (set_color yellow)
|
||||
set -l c_dim (set_color brblack)
|
||||
set -l c_reset (set_color normal)
|
||||
__fish_palette
|
||||
echo "$c_head""Usage:$c_reset $c_cmd""dng2avif$c_reset $c_flag""[options]$c_reset $c_dim""[input.dng]$c_reset"
|
||||
echo ""
|
||||
echo "$c_head""Options:$c_reset"
|
||||
|
||||
+1
-6
@@ -45,12 +45,7 @@
|
||||
# edit --editor=code --clipboard
|
||||
# edit --text="hello world"
|
||||
function edit --description 'Open files in a terminal or GUI editor with fallbacks'
|
||||
set -l c_head (set_color --bold cyan)
|
||||
set -l c_cmd (set_color --bold)
|
||||
set -l c_flag (set_color yellow)
|
||||
set -l c_err (set_color red)
|
||||
set -l c_dim (set_color brblack)
|
||||
set -l c_reset (set_color normal)
|
||||
__fish_palette
|
||||
|
||||
# Opinionated guard (C1): fall back to the legacy bare-editor behavior.
|
||||
if not __fish_config_op_enabled (status current-function)
|
||||
|
||||
+1
-2
@@ -19,8 +19,7 @@
|
||||
function hist --description 'Search fish history and put it in the prompt'
|
||||
# Opinionated guard (C4): integrations disabled
|
||||
if not __fish_config_op_enabled (status current-function)
|
||||
set -l c_err (set_color red)
|
||||
set -l c_reset (set_color normal)
|
||||
__fish_palette
|
||||
echo "$c_err"'hist: disabled by __fish_config_op_integrations'"$c_reset" >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
@@ -41,11 +41,7 @@
|
||||
# NOTES
|
||||
# Typo abbreviation: url-open (expands to open-url on space/enter).
|
||||
function open-url --description 'Open a URL in the best available web browser'
|
||||
set -l c_head (set_color --bold cyan)
|
||||
set -l c_cmd (set_color --bold)
|
||||
set -l c_flag (set_color yellow)
|
||||
set -l c_arg (set_color cyan)
|
||||
set -l c_reset (set_color normal)
|
||||
__fish_palette
|
||||
|
||||
argparse h/help s/silent v/verbose -- $argv
|
||||
or return 1
|
||||
|
||||
+1
-5
@@ -28,11 +28,7 @@
|
||||
function p --description 'Put from clipboard'
|
||||
# Check for help flag
|
||||
if contains -- -h $argv; or contains -- --help $argv
|
||||
set -l c_head (set_color --bold cyan)
|
||||
set -l c_cmd (set_color --bold)
|
||||
set -l c_flag (set_color yellow)
|
||||
set -l c_dim (set_color brblack)
|
||||
set -l c_reset (set_color normal)
|
||||
__fish_palette
|
||||
echo "$c_head""Usage:$c_reset $c_cmd""p$c_reset $c_flag""[OPTIONS]$c_reset"
|
||||
echo ""
|
||||
echo " Pastes content from the system clipboard to stdout."
|
||||
|
||||
@@ -36,11 +36,7 @@
|
||||
# play-media
|
||||
# play-media --player mpv
|
||||
function play-media --description 'Pick audio/video files with fzf and play them'
|
||||
set -l c_head (set_color --bold cyan)
|
||||
set -l c_cmd (set_color --bold)
|
||||
set -l c_flag (set_color yellow)
|
||||
set -l c_dim (set_color brblack)
|
||||
set -l c_reset (set_color normal)
|
||||
__fish_palette
|
||||
|
||||
argparse h/help p/player= -- $argv
|
||||
or return 1
|
||||
|
||||
Reference in New Issue
Block a user