Lots of stuff. Working on refactoring
This commit is contained in:
6
fish/functions/bubu.fish
Executable file
6
fish/functions/bubu.fish
Executable file
@@ -0,0 +1,6 @@
|
||||
function bubu --description="Update, upgrade and clean up homebrew packages"
|
||||
brew update
|
||||
and brew outdated
|
||||
and brew upgrade
|
||||
and brew cleanup
|
||||
end
|
||||
4
fish/functions/fish_greeting.fish
Executable file
4
fish/functions/fish_greeting.fish
Executable file
@@ -0,0 +1,4 @@
|
||||
function fish_greeting
|
||||
|
||||
end
|
||||
|
||||
29
fish/functions/fish_prompt.fish
Executable file
29
fish/functions/fish_prompt.fish
Executable file
@@ -0,0 +1,29 @@
|
||||
function fish_prompt
|
||||
set -l status_copy $status
|
||||
|
||||
if set -q VIRTUAL_ENV
|
||||
echo -sn "(" (basename "$VIRTUAL_ENV") ")"
|
||||
end
|
||||
|
||||
# Hostname with unique color
|
||||
set_color (hostname -s | md5 | cut -c-6)
|
||||
echo -sn (hostname -s)
|
||||
|
||||
# A yellow separator
|
||||
# The color of this could be used to signify something
|
||||
set_color yellow
|
||||
echo -sn ':'
|
||||
|
||||
# Contracted path to PWD
|
||||
set_color normal
|
||||
echo -sn (prompt_pwd)
|
||||
|
||||
# A green or red >, depending on exit status of last command
|
||||
if test "$status_copy" -ne 0
|
||||
set_color red
|
||||
else
|
||||
set_color green
|
||||
end
|
||||
echo -sn ' > '
|
||||
end
|
||||
|
||||
34
fish/functions/fish_right_prompt.fish
Executable file
34
fish/functions/fish_right_prompt.fish
Executable file
@@ -0,0 +1,34 @@
|
||||
function fish_right_prompt
|
||||
# Check if we are inside a version controlled directory (git only)
|
||||
set -l ref (git symbolic-ref HEAD ^/dev/null)
|
||||
if test -z $ref
|
||||
return
|
||||
end
|
||||
|
||||
# Check if any files have changes
|
||||
git diff --no-ext-diff --quiet --exit-code ^/dev/null
|
||||
or set -l dirty 'yes'
|
||||
|
||||
# Check if any files are staged
|
||||
git diff-index --cached --quiet HEAD -- ^/dev/null
|
||||
or set -l staged 'yes'
|
||||
|
||||
set_color normal
|
||||
echo -sn '['
|
||||
|
||||
# Print branch name
|
||||
# red if dirty
|
||||
# yellow if staged
|
||||
# green otherwise
|
||||
if set -q staged
|
||||
set_color yellow
|
||||
else if set -q dirty
|
||||
set_color red
|
||||
else
|
||||
set_color green
|
||||
end
|
||||
echo -sn (string replace refs/heads/ '' -- $ref)
|
||||
|
||||
set_color normal
|
||||
echo -sn ']'
|
||||
end
|
||||
4
fish/functions/fish_user_key_bindings.fish
Executable file
4
fish/functions/fish_user_key_bindings.fish
Executable file
@@ -0,0 +1,4 @@
|
||||
function fish_user_key_bindings
|
||||
bind \t try_subst
|
||||
end
|
||||
|
||||
10
fish/functions/g.fish
Executable file
10
fish/functions/g.fish
Executable file
@@ -0,0 +1,10 @@
|
||||
function g
|
||||
# shortcut to git
|
||||
# If no arguments are given, run git status and git l
|
||||
if count $argv >/dev/null
|
||||
git $argv
|
||||
else
|
||||
git status
|
||||
git l -5
|
||||
end
|
||||
end
|
||||
3
fish/functions/greb.fish
Executable file
3
fish/functions/greb.fish
Executable file
@@ -0,0 +1,3 @@
|
||||
function greb --description "Git rebase entire history, interactively"
|
||||
git rebase --interactive (git rev-list --max-parents=0 HEAD)
|
||||
end
|
||||
40
fish/functions/man.fish
Executable file
40
fish/functions/man.fish
Executable file
@@ -0,0 +1,40 @@
|
||||
function man --description "Format and display the on-line manual pages"
|
||||
# Work around the "builtin" manpage that everything symlinks to,
|
||||
# by prepending our fish datadir to man. This also ensures that man gives fish's
|
||||
# man pages priority, without having to put fish's bin directories first in $PATH
|
||||
|
||||
# My changes (Thomas Lovén)
|
||||
# Add color to the man pager
|
||||
#
|
||||
# blink
|
||||
set -lx LESS_TERMCAP_mb (set_color -o red)
|
||||
# bold
|
||||
set -lx LESS_TERMCAP_md (set_color -o purple)
|
||||
set -lx LESS_TERMCAP_me (set_color normal)
|
||||
# standout
|
||||
set -lx LESS_TERMCAP_so (set_color -b blue) (set_color yellow)
|
||||
set -lx LESS_TERMCAP_se (set_color normal)
|
||||
# underline
|
||||
set -lx LESS_TERMCAP_us (set_color -u green)
|
||||
set -lx LESS_TERMCAP_ue (set_color normal)
|
||||
|
||||
set -l manpath
|
||||
if set -q MANPATH
|
||||
set manpath $MANPATH
|
||||
else if command -qs manpath
|
||||
set manpath (command manpath)
|
||||
end
|
||||
# Notice local exported copy of the variable.
|
||||
set -lx MANPATH $manpath
|
||||
|
||||
set -l fish_manpath (dirname $__fish_datadir)/fish/man
|
||||
if test -d "$fish_manpath" -a -n "$MANPATH"
|
||||
set MANPATH $fish_manpath:$MANPATH
|
||||
# Invoke man with this manpath, and we're done.
|
||||
command man $argv
|
||||
return
|
||||
end
|
||||
|
||||
# If fish's man pages could not be found, just invoke man normally
|
||||
command man $argv
|
||||
end
|
||||
4
fish/functions/mcd.fish
Executable file
4
fish/functions/mcd.fish
Executable file
@@ -0,0 +1,4 @@
|
||||
function mcd --description "Make directory and enter it"
|
||||
mkdir -p $argv
|
||||
and cd $argv
|
||||
end
|
||||
14
fish/functions/try_subst.fish
Executable file
14
fish/functions/try_subst.fish
Executable file
@@ -0,0 +1,14 @@
|
||||
function try_subst
|
||||
# Use s/word/replacement<tab> to replace word with replacement
|
||||
# in last command
|
||||
commandline | read -l saved_commandline
|
||||
|
||||
set -l pattern '^s/..*/.*$'
|
||||
|
||||
if commandline -t | grep -E -q "$pattern"
|
||||
commandline -tr (echo -n "$history[1]" | sed -e (commandline -t)/g)
|
||||
else
|
||||
commandline -f complete
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user