mirror of https://github.com/mitchell/dotfiles.git
Modify fish config and prompt to check for commands before running;
cache programming language versions to improve prompt speed
This commit is contained in:
parent
75adf1cb0a
commit
101014980d
|
@ -10,11 +10,8 @@ set -gx PATH $PATH $GOBIN \
|
||||||
$HOME/.cargo/bin \
|
$HOME/.cargo/bin \
|
||||||
$HOME/.dotnet/tools
|
$HOME/.dotnet/tools
|
||||||
|
|
||||||
set -g fish_escape_delay_ms 10
|
command -sq kitty; and kitty + complete setup fish | source
|
||||||
|
command -sq asdf; and source (brew --prefix asdf)/asdf.fish
|
||||||
kitty + complete setup fish | source
|
|
||||||
|
|
||||||
source (brew --prefix asdf)/asdf.fish
|
|
||||||
|
|
||||||
# The next line updates PATH for the Google Cloud SDK.
|
# The next line updates PATH for the Google Cloud SDK.
|
||||||
# if test -f '/Users/m/Documents/google-cloud-sdk/path.fish.inc'; source '/Users/m/Documents/google-cloud-sdk/path.fish.inc'; end
|
# if test -f '/Users/m/Documents/google-cloud-sdk/path.fish.inc'; source '/Users/m/Documents/google-cloud-sdk/path.fish.inc'; end
|
||||||
|
|
|
@ -4,11 +4,6 @@ function fish_prompt --description 'Write out the prompt'
|
||||||
set -l suffix
|
set -l suffix
|
||||||
set -l user_prefix
|
set -l user_prefix
|
||||||
set -l git_branch
|
set -l git_branch
|
||||||
set -l go_version
|
|
||||||
set -l docker_version
|
|
||||||
set -l node_version
|
|
||||||
set -l ex_version
|
|
||||||
set -l dart_version
|
|
||||||
set -l jobs_num
|
set -l jobs_num
|
||||||
set -l exit_code
|
set -l exit_code
|
||||||
|
|
||||||
|
@ -66,7 +61,7 @@ function fish_prompt --description 'Write out the prompt'
|
||||||
if test -n "$SSH_CLIENT"; set user_prefix $USER @ (prompt_hostname) ' '; end
|
if test -n "$SSH_CLIENT"; set user_prefix $USER @ (prompt_hostname) ' '; end
|
||||||
|
|
||||||
# Show current git branch, based on git commands only.
|
# Show current git branch, based on git commands only.
|
||||||
if git branch --show-current > /dev/null 2> /dev/null
|
if test -e ./.git; and command -sq git
|
||||||
set -l branch_color green
|
set -l branch_color green
|
||||||
set -l git_status (git status)
|
set -l git_status (git status)
|
||||||
|
|
||||||
|
@ -96,15 +91,23 @@ function fish_prompt --description 'Write out the prompt'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set go version, by existence of go mod or dep files
|
# Set go version, by existence of go mod or dep files
|
||||||
if test -e ./go.mod; or test -e ./Gopkg.toml; and which go > /dev/null
|
if test -e ./go.mod; or test -e ./Gopkg.toml; and command -sq go
|
||||||
set -l version_str (string match -r 'go\d+\.\d+\.?\d*' (go version))
|
if test -z "$go_version"
|
||||||
set go_version ' with ' (set_color 8eadaf) $version_str (set_color normal)
|
set -l version_str (string match -r 'go\d+\.\d+\.?\d*' (go version))
|
||||||
|
set go_version ' with ' (set_color 8eadaf) $version_str (set_color normal)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
set -g go_version
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set docker version, by existence of Dockerfile
|
# Set docker version, by existence of Dockerfile
|
||||||
if test -e ./Dockerfile; and which docker > /dev/null
|
if test -e ./Dockerfile; and command -sq docker
|
||||||
set -l version_str (string match -r '\d+\.\d+\.?\d*' (docker --version))
|
if test -z "$docker_version"
|
||||||
set docker_version ' on ' (set_color blue) 'docker' $version_str (set_color normal)
|
set -l version_str (string match -r '\d+\.\d+\.?\d*' (docker --version))
|
||||||
|
set docker_version ' on ' (set_color blue) 'docker' $version_str (set_color normal)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
set -g docker_version
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set user prefix, based on docker machine name
|
# Set user prefix, based on docker machine name
|
||||||
|
@ -113,26 +116,38 @@ function fish_prompt --description 'Write out the prompt'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set node (and ts) version, based on existance of package.json (and tsconfig.json)
|
# Set node (and ts) version, based on existance of package.json (and tsconfig.json)
|
||||||
if test -e ./package.json; and which node > /dev/null
|
if test -e ./package.json; and command -sq node
|
||||||
set -l version_str (string sub -s 2 (node -v))
|
if test -z "$node_version"
|
||||||
set node_version ' with ' (set_color brgreen) 'node' $version_str (set_color normal)
|
set -l version_str (string sub -s 2 (node -v))
|
||||||
|
set node_version ' with ' (set_color brgreen) 'node' $version_str (set_color normal)
|
||||||
|
|
||||||
if test -e ./tsconfig.json; and which tsc > /dev/null
|
if test -e ./tsconfig.json; and command -sq tsc
|
||||||
set -l version_str (string match -r '\d+\.\d+\.?\d*' (tsc -v))
|
set -l version_str (string match -r '\d+\.\d+\.?\d*' (tsc -v))
|
||||||
set node_version $node_version ' and ' (set_color cyan) 'ts' $version_str (set_color normal)
|
set node_version $node_version ' and ' (set_color cyan) 'ts' $version_str (set_color normal)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
set -g node_version
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set elixir version, based on existance of mix.exs
|
# Set elixir version, based on existance of mix.exs
|
||||||
if test -e ./mix.exs; and which elixir > /dev/null
|
if test -e ./mix.exs; and command -sq elixir
|
||||||
set -l version_str (string sub -s 8 (string match -r 'Elixir \d+\.\d+\.?\d*' (elixir -v)))
|
if test -z "$ex_version"
|
||||||
set ex_version ' with ' (set_color magenta) 'ex' $version_str (set_color normal)
|
set -l version_str (string sub -s 8 (string match -r 'Elixir \d+\.\d+\.?\d*' (elixir -v)))
|
||||||
|
set ex_version ' with ' (set_color magenta) 'ex' $version_str (set_color normal)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
set -g ex_version
|
||||||
end
|
end
|
||||||
|
|
||||||
# Set dart version, based on existances of pubspec.yaml
|
# Set dart version, based on existances of pubspec.yaml
|
||||||
if test -e ./pubspec.yaml; and which dart > /dev/null
|
if test -e ./pubspec.yaml; and command -sq dart
|
||||||
set -l version_str (string match -r '\d+\.\d+\.?\d*' (dart --version 2>| cat))
|
if test -z "$dart_version"
|
||||||
set dart_version ' with ' (set_color brblue) 'dart' $version_str (set_color normal)
|
set -l version_str (string match -r '\d+\.\d+\.?\d*' (dart --version 2>| cat))
|
||||||
|
set dart_version ' with ' (set_color brblue) 'dart' $version_str (set_color normal)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
set -g dart_version
|
||||||
end
|
end
|
||||||
|
|
||||||
# Combine all prompt variables
|
# Combine all prompt variables
|
||||||
|
|
Loading…
Reference in New Issue