Muh dotfiles
This commit is contained in:
3
.config/fish/functions/chat.fish
Normal file
3
.config/fish/functions/chat.fish
Normal file
@ -0,0 +1,3 @@
|
||||
function chat --wraps='ollama run --nowordwrap' --description 'Run an llm without history'
|
||||
OLLAMA_NOHISTORY=y ollama run --nowordwrap $argv
|
||||
end
|
3
.config/fish/functions/dots.fish
Normal file
3
.config/fish/functions/dots.fish
Normal file
@ -0,0 +1,3 @@
|
||||
function dots --wraps 'git --git-dir ~/.dotfiles/ --work-tree ~' --description 'Track dotfiles with git'
|
||||
command git --git-dir ~/.dotfiles/ --work-tree ~ $argv
|
||||
end
|
3
.config/fish/functions/fish_greeting.fish
Normal file
3
.config/fish/functions/fish_greeting.fish
Normal file
@ -0,0 +1,3 @@
|
||||
function fish_greeting
|
||||
# command -q fortune; and fortune -as
|
||||
end
|
1
.config/fish/functions/fish_mode_prompt.fish
Normal file
1
.config/fish/functions/fish_mode_prompt.fish
Normal file
@ -0,0 +1 @@
|
||||
function fish_mode_prompt; end
|
65
.config/fish/functions/fish_prompt.fish
Normal file
65
.config/fish/functions/fish_prompt.fish
Normal file
@ -0,0 +1,65 @@
|
||||
function fish_prompt --description 'Write out the prompt'
|
||||
# Save those before running anything
|
||||
set -l last_pipestatus $pipestatus
|
||||
set -lx __fish_last_status $status # Export for __fish_print_pipestatus.
|
||||
|
||||
# Detect reflow from window size change
|
||||
if test "$__fish_prompt_term_dimensions" != "$COLUMNS$LINES"
|
||||
set -g __fish_prompt_term_dimensions "$COLUMNS$LINES"
|
||||
if set -q __fish_prompt
|
||||
echo -ns $__fish_prompt
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
# Write pipestatus if a command was issued
|
||||
# TODO: hardcode this mess
|
||||
if test "$__fish_prompt_status_generation" != $status_generation
|
||||
set -g __fish_prompt_status_generation $status_generation
|
||||
set -q fish_color_status; or set -g fish_color_status brred
|
||||
|
||||
set -f prompt_status (__fish_print_pipestatus '' '' '|' '' (set_color --bold $fish_color_status) $last_pipestatus)
|
||||
end
|
||||
|
||||
# Only show login if in SSH or container
|
||||
if not set -q prompt_host
|
||||
set -g prompt_host '' # global because it's slow and unchanging
|
||||
if set -q SSH_TTY; or begin
|
||||
command -sq systemd-detect-virt
|
||||
and systemd-detect-virt -q
|
||||
end
|
||||
set prompt_host "$(prompt_login) "
|
||||
end
|
||||
end
|
||||
|
||||
if not set -q __prompt_suffix
|
||||
set -g __prompt_suffix '>'
|
||||
set -g __prompt_color_cwd fish_color_cwd
|
||||
|
||||
if fish_is_root_user
|
||||
set __prompt_suffix '#'
|
||||
set -q fish_color_cwd_root; or set -g fish_color_cwd_root red
|
||||
set __prompt_color_cwd fish_color_cwd_root
|
||||
end
|
||||
end
|
||||
|
||||
set -l suffix $__prompt_suffix
|
||||
if test "$fish_key_bindings" = fish_vi_key_bindings
|
||||
or test "$fish_key_bindings" = fish_hybrid_key_bindings
|
||||
switch $fish_bind_mode
|
||||
# case insert
|
||||
case default
|
||||
set suffix (set_color --bold brmagenta)N
|
||||
case visual
|
||||
set suffix (set_color --bold brcyan)V
|
||||
case replace_one
|
||||
set suffix (set_color --bold bryellow)R
|
||||
case replace
|
||||
set suffix (set_color --bold brred)R
|
||||
end
|
||||
end
|
||||
|
||||
set -l n (set_color normal)
|
||||
set -g __fish_prompt $n $prompt_host (set_color $$__prompt_color_cwd) (prompt_pwd -D2) $n ' ' $prompt_status $suffix $n ' '
|
||||
echo -ns $__fish_prompt
|
||||
end
|
53
.config/fish/functions/fish_right_prompt.fish
Normal file
53
.config/fish/functions/fish_right_prompt.fish
Normal file
@ -0,0 +1,53 @@
|
||||
function fish_right_prompt
|
||||
# Detect reflow from window size change
|
||||
if test "$__fish_right_prompt_term_dimensions" != "$COLUMNS$LINES"
|
||||
set -g __fish_right_prompt_term_dimensions "$COLUMNS$LINES"
|
||||
if set -q __fish_right_prompt
|
||||
echo -ns $__fish_right_prompt
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
set -g __fish_git_prompt_showdirtystate 1
|
||||
set -g __fish_git_prompt_showuntrackedfiles 1
|
||||
set -g __fish_git_prompt_showupstream informative
|
||||
set -g __fish_git_prompt_showcolorhints 1
|
||||
set -g __fish_git_prompt_use_informative_chars 1
|
||||
|
||||
# Unfortunately this only works if we have a sensible locale
|
||||
string match -qi '*.utf-8' -- $LANG $LC_CTYPE $LC_ALL
|
||||
and set -g __fish_git_prompt_char_dirtystate \U1F4a9
|
||||
set -g __fish_git_prompt_char_untrackedfiles '?'
|
||||
|
||||
set -l vcs (fish_vcs_prompt '%s' 2>/dev/null)
|
||||
|
||||
set -q VIRTUAL_ENV_DISABLE_PROMPT
|
||||
or set -g VIRTUAL_ENV_DISABLE_PROMPT true
|
||||
set -q VIRTUAL_ENV
|
||||
and set -l venv (string replace -r '.*/' '' -- "$VIRTUAL_ENV")
|
||||
|
||||
# Count duration (optionally)
|
||||
if test $CMD_DURATION -gt 100 -a \
|
||||
"$__fish_right_prompt_status_generation" != $status_generation
|
||||
set -g __fish_right_prompt_status_generation $status_generation
|
||||
|
||||
set -l secs (math -s2 $CMD_DURATION / 1000 % 60)
|
||||
set -l mins (math -s0 $CMD_DURATION / 60000 % 60)
|
||||
set -l hrs (math -s0 $CMD_DURATION / 3600000)
|
||||
set -l parts
|
||||
|
||||
# Remove excess verbosity
|
||||
test $hrs -gt 0; and set -a parts $hrs'h'
|
||||
if test $mins -gt 0
|
||||
set -a parts $mins'm'
|
||||
set secs (math -s0 $secs) # drop millis when there are mins
|
||||
end
|
||||
test $secs -gt 0 -a $hrs -eq 0; and set -a parts $secs's'
|
||||
|
||||
set -f duration (set_color white)(string join ':' -- $parts)
|
||||
end
|
||||
|
||||
set -l n (set_color normal)
|
||||
set -g __fish_right_prompt $n $venv' ' $duration' ' $vcs' ' (set_color brblack) (date '+%R') $n
|
||||
echo -ns $__fish_right_prompt
|
||||
end
|
40
.config/fish/functions/fish_user_key_bindings.fish
Normal file
40
.config/fish/functions/fish_user_key_bindings.fish
Normal file
@ -0,0 +1,40 @@
|
||||
function fish_user_key_bindings
|
||||
if command -q fzf
|
||||
set -gx FZF_CTRL_R_OPTS '--reverse'
|
||||
|
||||
function bind; end # thanks fzf for not using `builtin`
|
||||
if functions -q fzf_key_bindings
|
||||
fzf_key_bindings
|
||||
else
|
||||
echo 'WARNING: using `fzf --fish | source`'
|
||||
command fzf --fish | source
|
||||
end
|
||||
functions -e bind
|
||||
|
||||
# FZF_ALT_C_COMMAND, FZF_ALT_C_OPTS
|
||||
bind alt-c fzf-cd-widget
|
||||
bind -M insert alt-c fzf-cd-widget
|
||||
# FZF_CTRL_T_COMMAND, FZF_CTRL_T_OPTS
|
||||
bind alt-f fzf-file-widget
|
||||
bind -M insert alt-f fzf-file-widget
|
||||
# FZF_CTRL_R_OPTS
|
||||
bind ctrl-f fzf-history-widget
|
||||
bind -M insert ctrl-f fzf-history-widget
|
||||
else
|
||||
echo 'INFO: fzf not found'
|
||||
end
|
||||
|
||||
# Unused: alt-z, insert ctrl-r
|
||||
|
||||
bind alt-t transpose-words
|
||||
bind -M insert alt-t transpose-words
|
||||
bind -M visual alt-t transpose-words
|
||||
bind ctrl-t transpose-chars
|
||||
bind -M insert ctrl-t transpose-chars
|
||||
bind -M visual ctrl-t transpose-chars
|
||||
bind ctrl-z 'fish_commandline_append " &; disown"'
|
||||
bind -M insert ctrl-z 'fish_commandline_append " &; disown"'
|
||||
bind -M visual ctrl-z 'fish_commandline_append " &; disown"'
|
||||
|
||||
# bind -M insert ctrl-d exit
|
||||
end
|
3
.config/fish/functions/la.fish
Normal file
3
.config/fish/functions/la.fish
Normal file
@ -0,0 +1,3 @@
|
||||
function la --wraps 'ls' --description 'List all files in directory using verbose format'
|
||||
ls -lAh --group-directories-first $argv
|
||||
end
|
3
.config/fish/functions/ll.fish
Normal file
3
.config/fish/functions/ll.fish
Normal file
@ -0,0 +1,3 @@
|
||||
function ll --wraps 'ls' --description 'List contents of directory using long format'
|
||||
ls -lh --group-directories-first $argv
|
||||
end
|
7
.config/fish/functions/music.fish
Normal file
7
.config/fish/functions/music.fish
Normal file
@ -0,0 +1,7 @@
|
||||
function music --wraps 'yt-dlp -x --embed-thumbnail --embed-chapters' --description 'Download music with yt-dlp'
|
||||
test -d $argv[-1]; or set -a argv "$XDG_MUSIC_DIR"
|
||||
echo "Downloading into $argv[-1]"
|
||||
|
||||
command yt-dlp --extract-audio --embed-thumbnail --embed-chapters \
|
||||
--output "$argv[-1]/%(title)s.%(ext)s" $argv[..-2]
|
||||
end
|
3
.config/fish/functions/tree.fish
Normal file
3
.config/fish/functions/tree.fish
Normal file
@ -0,0 +1,3 @@
|
||||
function tree
|
||||
command tree -C --dirsfirst $argv
|
||||
end
|
11
.config/fish/functions/y.fish
Normal file
11
.config/fish/functions/y.fish
Normal file
@ -0,0 +1,11 @@
|
||||
function y --wraps 'yazi' --description 'TUI file manager'
|
||||
set -l tmp (mktemp -t 'yazi_cwd.XXX')
|
||||
yazi --cwd-file="$tmp" $argv
|
||||
|
||||
set -l cwd (command cat -- "$tmp")
|
||||
and test -n "$cwd"
|
||||
and test "$cwd" != "$PWD"
|
||||
and builtin cd -- "$cwd"
|
||||
|
||||
rm -f -- "$tmp"
|
||||
end
|
Reference in New Issue
Block a user