Skip to content

Commit

Permalink
Merge branch 'autocompletion'
Browse files Browse the repository at this point in the history
  • Loading branch information
VladBrok committed Jun 5, 2023
2 parents 0041a88 + e63119e commit 0abc687
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion scripts/dev-build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

dotnet build src/navigatio --no-restore && scripts/setup.sh src/navigatio/bin/debug/net6.0/
dotnet build src/Navigatio --no-restore && scripts/setup.sh src/Navigatio/bin/debug/net6.0/
15 changes: 15 additions & 0 deletions scripts/navigatio-completions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

export ROOT=/usr/local/bin/navigatio

_navigatio_completions() {
COMPREPLY=($(compgen -W "$(_extract_keys_from_json $ROOT/aliases.json)" -- "${COMP_WORDS[-1]}"))
}

_extract_keys_from_json() {
local file=$1
cat $file | tr -d "[:space:]" | grep -o '"[^"]\+":' | tr -d '":'
}

complete -F _navigatio_completions nav
complete -F _navigatio_completions n
11 changes: 6 additions & 5 deletions scripts/release.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env bash

PROJECT_DIR=src/navigatio
PROJECT_DIR=src/Navigatio
BASE_DIR=${PROJECT_DIR}/bin/Release

function release_for_os() {
rm -rf ${BASE_DIR}/$1 && \
rm -rf ${BASE_DIR}/$1 &&
dotnet publish $PROJECT_DIR --configuration Release --output ${BASE_DIR}/$1 --runtime $1 --self-contained true &&
(cd "${BASE_DIR}/$1/" && zip "$1.zip" * && cd - && cp "${BASE_DIR}/$1/$1.zip" .)

dotnet publish $PROJECT_DIR --configuration Release --output ${BASE_DIR}/$1 --runtime $1 --self-contained true && \

powershell Compress-Archive -Path "'${BASE_DIR}/$1/*'" -DestinationPath "$1.zip" -Force
# This was used to create a zip archive on windows:
# powershell Compress-Archive -Path "'${BASE_DIR}/$1/*'" -DestinationPath "$1.zip" -Force
}

release_for_os win-x86
Expand Down
12 changes: 8 additions & 4 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ function create_dir() {
cp -r ${EXE_PATH}. $ROOT
}

function setup_autocompletion() {
sudo cp ${EXE_PATH}navigatio-completions.sh /etc/bash_completion.d/
}

function sudo_create_dir() {
sudo -E bash -c "$(declare -f create_dir); create_dir"
}
Expand All @@ -26,15 +30,15 @@ function set_permissions() {
}

function create_alias() {
echo "" >> ~/.bashrc
echo "alias nav='source ${ROOT}/nav.sh ${ROOT} ${ROOT}/output.sh'" >> ~/.bashrc
echo "" >>~/.bashrc
echo "alias nav='source ${ROOT}/nav.sh ${ROOT} ${ROOT}/output.sh'" >>~/.bashrc
}

unamestr=$(uname)
if [[ "$unamestr" == 'Linux' ]]
then
if [[ "$unamestr" == 'Linux' ]]; then
sudo_create_dir
set_permissions
setup_autocompletion
else
create_dir
fi
Expand Down
1 change: 1 addition & 0 deletions src/Navigatio/Navigatio.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<None Include="../../settings.json" CopyToOutputDirectory="PreserveNewest" />
<None Include="../../scripts/nav.sh" CopyToOutputDirectory="PreserveNewest" />
<None Include="../../scripts/setup.sh" CopyToOutputDirectory="PreserveNewest" />
<None Include="../../scripts/navigatio-completions.sh" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>

0 comments on commit 0abc687

Please sign in to comment.