Look for special files in all parent directories

This commit is contained in:
Ilan Cosman 2022-08-06 18:19:13 -04:00
parent e3b79b7358
commit 7aababe7de
9 changed files with 21 additions and 7 deletions

View File

@ -1,3 +1,4 @@
function _tide_item_crystal
test -e shard.yml && _tide_print_item crystal $tide_crystal_icon' ' (crystal --version | string match -r "[\d.]+")[1]
path is $_tide_parent_dirs/shard.yml &&
_tide_print_item crystal $tide_crystal_icon' ' (crystal --version | string match -r "[\d.]+")[1]
end

View File

@ -1,3 +1,4 @@
function _tide_item_go
test -e go.mod && _tide_print_item go $tide_go_icon' ' (go version | string match -r "[\d.]+")
path is $_tide_parent_dirs/go.mod &&
_tide_print_item go $tide_go_icon' ' (go version | string match -r "[\d.]+")
end

View File

@ -1,3 +1,4 @@
function _tide_item_java
test -e pom.xml && _tide_print_item java $tide_java_icon' ' (java -version &| string match -r "[\d.]+")[1]
path is $_tide_parent_dirs/pom.xml &&
_tide_print_item java $tide_java_icon' ' (java -version &| string match -r "[\d.]+")[1]
end

View File

@ -1,3 +1,4 @@
function _tide_item_node
test -e package.json && _tide_print_item node $tide_node_icon' ' (node --version | string trim --chars=v)
path is $_tide_parent_dirs/package.json &&
_tide_print_item node $tide_node_icon' ' (node --version | string trim --chars=v)
end

View File

@ -1,3 +1,4 @@
function _tide_item_php
test -e composer.json && _tide_print_item php $tide_php_icon' ' (php --version | string match -r 'PHP ([\d.]+)')[2]
path is $_tide_parent_dirs/composer.json &&
_tide_print_item php $tide_php_icon' ' (php --version | string match -r 'PHP ([\d.]+)')[2]
end

View File

@ -1,3 +1,4 @@
function _tide_item_rustc
test -e Cargo.toml && _tide_print_item rustc $tide_rustc_icon' ' (rustc --version | string split ' ')[2]
path is $_tide_parent_dirs/Cargo.toml &&
_tide_print_item rustc $tide_rustc_icon' ' (rustc --version | string split ' ')[2]
end

View File

@ -1,5 +1,5 @@
function _tide_item_terraform
if test -d .terraform
if path is $_tide_parent_dirs/.terraform
terraform workspace show | read -l workspace
test $workspace != default && _tide_print_item terraform $tide_terraform_icon' ' $workspace
end

View File

@ -0,0 +1,6 @@
function _tide_parent_dirs --on-variable PWD
set -g _tide_parent_dirs (for dir in (string split / $PWD)
set -la parts $dir
string join / $parts
end)
end

View File

@ -4,6 +4,7 @@ status is-interactive || exit
_tide_remove_unusable_items
_tide_cache_variables
_tide_parent_dirs
source (functions --details _tide_pwd)
set -l prompt_var _tide_prompt_$fish_pid
@ -38,6 +39,7 @@ function fish_prompt
_tide_status=\$status _tide_pipestatus=\$pipestatus if not set -e _tide_repaint
jobs -q && set -lx _tide_jobs
$fish_path -c \"set _tide_pipestatus \$_tide_pipestatus
set _tide_parent_dirs \$_tide_parent_dirs
CMD_DURATION=\$CMD_DURATION fish_bind_mode=\$fish_bind_mode set $prompt_var (_tide_2_line_prompt)\" &
builtin disown