fish: some functions and aliases
This commit is contained in:
parent
077a885d2a
commit
331c9b0e69
24 changed files with 115 additions and 40 deletions
|
@ -1,49 +1,20 @@
|
||||||
if status is-interactive
|
if status is-interactive
|
||||||
set prompt_sep_a \ue0b0
|
set prompt_sep_a \ue0b0
|
||||||
set prompt_bang \n\U1f41f\
|
set prompt_bang \n\ (set_color brblue)\u266a\
|
||||||
set git_sign \ue0a0
|
set git_sign \ue0a0
|
||||||
set color_fg brwhite
|
set color_fg brwhite
|
||||||
set color_git_branch 3c3c3c
|
set color_git_branch 3c3c3c
|
||||||
set color_git yellow blue red purple
|
set color_git yellow blue red purple
|
||||||
function prompt.add
|
|
||||||
set color $argv[1]
|
|
||||||
set text $argv[2]
|
|
||||||
if test -z "$prompt_string"
|
|
||||||
set prompt_string (set_color -b $color)(set_color $color_fg) $text
|
|
||||||
else
|
|
||||||
set -a prompt_string (set_color -b $color)(set_color $prev_color)$prompt_sep_a(set_color $color_fg) $text
|
|
||||||
end
|
|
||||||
set prev_color $color
|
|
||||||
end
|
|
||||||
function prompt.git
|
|
||||||
git rev-parse 2>/dev/null || return
|
|
||||||
git status --porcelain -bu | while read line
|
|
||||||
if string match -qr "^##" "$line"
|
|
||||||
set git_branch (string match -r "\ (.+)\.\.\." "$line")[2]
|
|
||||||
string match -qr "\[behind" $line && set git_branch "$git_branch?"
|
|
||||||
string match -qr "\[ahead" $line && set git_branch "$git_branch!"
|
|
||||||
prompt.add "$color_git_branch" "$git_sign $git_branch"
|
|
||||||
else
|
|
||||||
string match -qr "^.[MD]" "$line" && set git_count[1] (math $git_count[1] + 1)
|
|
||||||
string match -qr "^[MDARC]." "$line" && set git_count[2] (math $git_count[2] + 1)
|
|
||||||
string match -qr "^\?\?" "$line" && set git_count[3] (math $git_count[3] + 1)
|
|
||||||
string match -qr "^[ADU]{2}" "$line" && set git_count[4] (math $git_count[4] + 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
test -n "$git_count[1]" && prompt.add "$color_git[1]" "~$git_count[1]"
|
|
||||||
test -n "$git_count[2]" && prompt.add "$color_git[2]" "+$git_count[2]"
|
|
||||||
test -n "$git_count[3]" && prompt.add "$color_git[3]" "!$git_count[3]"
|
|
||||||
test -n "$git_count[4]" && prompt.add "$color_git[4]" "*$git_count[4]"
|
|
||||||
end
|
|
||||||
function fish_prompt
|
|
||||||
set -g prompt_string
|
|
||||||
set -g prev_color
|
|
||||||
prompt.add blue (pwd)
|
|
||||||
prompt.git
|
|
||||||
prompt.add normal $prompt_bang
|
|
||||||
|
|
||||||
echo $prompt_string
|
set -l grc_cmds \
|
||||||
set -e prompt_string
|
iptables ipneighbor ipaddr iproute ip nmap netstat \
|
||||||
|
traceroute tcpdump ss ping \
|
||||||
|
dockerversion dockersearch dockerpull dockerps dockernetwork \
|
||||||
|
docker-machinels dockerinfo dockerimages \
|
||||||
|
lspci lsof lsmod lsblk lsattr getfacl id whois vmstat ulimit \
|
||||||
|
systemctl sysctl stat pv ps ping last gcc free findmnt fdisk env du \
|
||||||
|
dig diff df blkid
|
||||||
|
for cmd in $grc_cmds
|
||||||
|
command -q $cmd && alias $cmd="command grc -es --colour=auto $cmd"
|
||||||
end
|
end
|
||||||
# Commands to run in interactive sessions can go here
|
|
||||||
end
|
end
|
||||||
|
|
3
cli/.config/fish/functions/atmux.fish
Normal file
3
cli/.config/fish/functions/atmux.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function atmux
|
||||||
|
tmux attach || tmux
|
||||||
|
end
|
3
cli/.config/fish/functions/diff.fish
Normal file
3
cli/.config/fish/functions/diff.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function diff
|
||||||
|
command diff --color $argv
|
||||||
|
end
|
10
cli/.config/fish/functions/fish_prompt.fish
Normal file
10
cli/.config/fish/functions/fish_prompt.fish
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
function fish_prompt
|
||||||
|
set -g prompt_string
|
||||||
|
set -g prev_color
|
||||||
|
prompt.add blue (pwd)
|
||||||
|
prompt.git
|
||||||
|
prompt.add normal $prompt_bang
|
||||||
|
|
||||||
|
echo $prompt_string
|
||||||
|
set -e prompt_string
|
||||||
|
end
|
3
cli/.config/fish/functions/g.fish
Normal file
3
cli/.config/fish/functions/g.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function g
|
||||||
|
command lazygit $argv
|
||||||
|
end
|
3
cli/.config/fish/functions/gci.fish
Normal file
3
cli/.config/fish/functions/gci.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function gci
|
||||||
|
command git commit $argv
|
||||||
|
end
|
3
cli/.config/fish/functions/grep.fish
Normal file
3
cli/.config/fish/functions/grep.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function grep
|
||||||
|
command grep --color=auto $argv
|
||||||
|
end
|
6
cli/.config/fish/functions/greset.fish
Normal file
6
cli/.config/fish/functions/greset.fish
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
function greset
|
||||||
|
read -P "OK to reset and clean teh repo?"\n -ln1 resp
|
||||||
|
test "$resp" != y && return 0
|
||||||
|
command git clean -fd
|
||||||
|
command git reset --hard
|
||||||
|
end
|
4
cli/.config/fish/functions/groot.fish
Normal file
4
cli/.config/fish/functions/groot.fish
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
function groot
|
||||||
|
set -l root (command git rev-parse --show-toplevel)
|
||||||
|
test $status -eq 0 && cd $root
|
||||||
|
end
|
3
cli/.config/fish/functions/gsi.fish
Normal file
3
cli/.config/fish/functions/gsi.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function gsi
|
||||||
|
tig status
|
||||||
|
end
|
3
cli/.config/fish/functions/gsl.fish
Normal file
3
cli/.config/fish/functions/gsl.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function gsl
|
||||||
|
command git stash list $argv
|
||||||
|
end
|
3
cli/.config/fish/functions/gss.fish
Normal file
3
cli/.config/fish/functions/gss.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function gss
|
||||||
|
command git status -sbu $argv
|
||||||
|
end
|
3
cli/.config/fish/functions/gsw.fish
Normal file
3
cli/.config/fish/functions/gsw.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function gsw
|
||||||
|
command git switch $argv
|
||||||
|
end
|
3
cli/.config/fish/functions/gup.fish
Normal file
3
cli/.config/fish/functions/gup.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function gup
|
||||||
|
command git pull $argv
|
||||||
|
end
|
3
cli/.config/fish/functions/gwta.fish
Normal file
3
cli/.config/fish/functions/gwta.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function gwta
|
||||||
|
command git worktree add $argv
|
||||||
|
end
|
3
cli/.config/fish/functions/gwtp.fish
Normal file
3
cli/.config/fish/functions/gwtp.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function gwtp
|
||||||
|
command git worktree purge $argv
|
||||||
|
end
|
3
cli/.config/fish/functions/ll.fish
Normal file
3
cli/.config/fish/functions/ll.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function ll
|
||||||
|
ls -alg $argv
|
||||||
|
end
|
3
cli/.config/fish/functions/ls.fish
Normal file
3
cli/.config/fish/functions/ls.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function ls
|
||||||
|
command exa --group-directories-first $argv
|
||||||
|
end
|
10
cli/.config/fish/functions/prompt.add.fish
Normal file
10
cli/.config/fish/functions/prompt.add.fish
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
function prompt.add
|
||||||
|
set color $argv[1]
|
||||||
|
set text $argv[2]
|
||||||
|
if test -z "$prompt_string"
|
||||||
|
set prompt_string (set_color -b $color)(set_color $color_fg) $text
|
||||||
|
else
|
||||||
|
set -a prompt_string (set_color -b $color)(set_color $prev_color)$prompt_sep_a(set_color $color_fg) $text
|
||||||
|
end
|
||||||
|
set prev_color $color
|
||||||
|
end
|
20
cli/.config/fish/functions/prompt.git.fish
Normal file
20
cli/.config/fish/functions/prompt.git.fish
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
function prompt.git
|
||||||
|
git rev-parse 2>/dev/null || return
|
||||||
|
git status --porcelain -bu | while read line
|
||||||
|
if string match -qr "^##" "$line"
|
||||||
|
set git_branch (string match -r "\ (.+)\.\.\." "$line")[2]
|
||||||
|
string match -qr '\[behind' $line && set git_branch "$git_branch?"
|
||||||
|
string match -qr '\[ahead' $line && set git_branch "$git_branch!"
|
||||||
|
prompt.add "$color_git_branch" "$git_sign $git_branch"
|
||||||
|
else
|
||||||
|
string match -qr "^.[MD]" "$line" && set git_count[1] (math $git_count[1] + 1)
|
||||||
|
string match -qr "^[MDARC]." "$line" && set git_count[2] (math $git_count[2] + 1)
|
||||||
|
string match -qr "^\?\?" "$line" && set git_count[3] (math $git_count[3] + 1)
|
||||||
|
string match -qr "^[ADU]{2}" "$line" && set git_count[4] (math $git_count[4] + 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
test -n "$git_count[1]" && prompt.add "$color_git[1]" "~$git_count[1]"
|
||||||
|
test -n "$git_count[2]" && prompt.add "$color_git[2]" "+$git_count[2]"
|
||||||
|
test -n "$git_count[3]" && prompt.add "$color_git[3]" "!$git_count[3]"
|
||||||
|
test -n "$git_count[4]" && prompt.add "$color_git[4]" "*$git_count[4]"
|
||||||
|
end
|
3
cli/.config/fish/functions/rgrep.fish
Normal file
3
cli/.config/fish/functions/rgrep.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function rgrep
|
||||||
|
grep --exclude-dir=.git -R $argv
|
||||||
|
end
|
3
cli/.config/fish/functions/tailf.fish
Normal file
3
cli/.config/fish/functions/tailf.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function tailf
|
||||||
|
command less +F $argv
|
||||||
|
end
|
3
cli/.config/fish/functions/tmux.fish
Normal file
3
cli/.config/fish/functions/tmux.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function tmux
|
||||||
|
command tmux -2 $argv
|
||||||
|
end
|
3
cli/.config/fish/functions/vim.fish
Normal file
3
cli/.config/fish/functions/vim.fish
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
function vim
|
||||||
|
command nvim $argv
|
||||||
|
end
|
Loading…
Reference in a new issue