Last active
September 24, 2024 16:09
-
-
Save NikiforovAll/037bad7aeaf296b08dc4762c6c91dc50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Preview file content using bat (https://github.com/sharkdp/bat) | |
export FZF_CTRL_T_OPTS=" | |
--walker-skip .git,node_modules,target | |
--preview 'bat -n --color=always {}' | |
--bind 'ctrl-/:change-preview-window(down|hidden|)'" | |
export FZF_DEFAULT_OPTS=" | |
--preview 'bat -n --color=always {}' | |
" | |
function fzfp() { | |
local PROJECTS=$(dotnet sln list | sed '1,2d') | |
echo "$PROJECTS" | fzf --preview "bat --style=numbers --color=always --line-range :500 {} -l xml" | |
} | |
function fzft() { | |
if [ -n "$1" ]; then | |
local PROJECT=$1 | |
else | |
local PROJECT=$(fzfp) | |
fi | |
dotnet build $PROJECT --verbosity quiet > /dev/null 2>&1 | |
local TESTS=$(dotnet test $PROJECT --verbosity quiet --list-tests --no-build | sed '/^The following Tests/d; /^Test run for/d; /^VSTest version/d; /^No test is available/d;' | grep -v '^[[:space:]]*$') | |
echo "$TESTS" | fzf --no-preview | |
} | |
function dotnet_test() { | |
if [ -n "$1" ]; then | |
local PROJECT=$1 | |
else | |
local PROJECT=$(fzfp) | |
fi | |
if [ -z "$PROJECT" ]; then | |
echo -e "No project selected. Please select a project using \e[32mfzfp\e[0m." | |
return 1 | |
fi | |
local TEST=$(fzft $PROJECT | sed 's/[[:space:]]\+$//') | |
if [ -z "$TEST" ]; then | |
echo -e "No test selected. Please select a test using \e[32mfzft\e[0m." | |
return 1 | |
fi | |
dotnet test "$PROJECT" --no-build --filter "$TEST" | |
} | |
function dotnet_build() { | |
if [ -n "$1" ]; then | |
local PROJECT=$1 | |
else | |
local PROJECT=$(fzfp) | |
fi | |
if [ -z "$PROJECT" ]; then | |
echo -e "No project selected. Please select a project using \e[32mfzfp\e[0m." | |
return 1 | |
fi | |
echo "\e[32mBuilding\e[0m $PROJECT" | |
dotnet build $PROJECT -v q | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment