nixos76: shellcheck quick-switch
This commit is contained in:
parent
a29572f876
commit
1ed635be48
|
@ -5,19 +5,23 @@ commitchanges="false"
|
||||||
|
|
||||||
while getopts 'c' OPTION; do
|
while getopts 'c' OPTION; do
|
||||||
case "$OPTION" in
|
case "$OPTION" in
|
||||||
c) commitchanges="true" ;;
|
c) commitchanges="true" ;;
|
||||||
|
*) exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Stolen from https://stackoverflow.com/a/29436423
|
# Stolen from https://stackoverflow.com/a/29436423
|
||||||
function yes_or_no {
|
function yes_or_no {
|
||||||
while true; do
|
while true; do
|
||||||
read -p "$* [y/n]: " yn
|
read -r -p "$* [y/n]: " yn
|
||||||
case $yn in
|
case $yn in
|
||||||
[Yy]*) return 0 ;;
|
[Yy]*) return 0 ;;
|
||||||
[Nn]*) echo "Aborted" ; return 1 ;;
|
[Nn]*)
|
||||||
esac
|
echo "Aborted"
|
||||||
done
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset_bspwm() {
|
function reset_bspwm() {
|
||||||
|
@ -38,25 +42,23 @@ function apply() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function commit_and_apply() {
|
function commit_and_apply() {
|
||||||
read -p "Git working directory is unclean. Commit message: " msg
|
read -r -p "Git working directory is unclean. Commit message: " msg
|
||||||
git add .
|
git add .
|
||||||
git commit -m "$(hostname): $msg"
|
git commit -m "$(hostname): $msg"
|
||||||
apply
|
apply
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z "$(git status --porcelain)" ]
|
if [ -z "$(git status --porcelain)" ]; then
|
||||||
then
|
|
||||||
apply
|
apply
|
||||||
else
|
else
|
||||||
if [ "$commitchanges" == "false" ]
|
if [ "$commitchanges" == "false" ]; then
|
||||||
then
|
echo "Using local flake..."
|
||||||
echo "Using local flake..."
|
sudo nixos-rebuild switch --show-trace --flake .
|
||||||
sudo nixos-rebuild switch --show-trace --flake .
|
reset_bspwm
|
||||||
reset_bspwm
|
else
|
||||||
else
|
echo "Committing flake and pushing..."
|
||||||
echo "Committing flake and pushing..."
|
commit_and_apply
|
||||||
commit_and_apply
|
|
||||||
fi
|
fi
|
||||||
|
# shellcheck disable=SC2028
|
||||||
echo "\nOperation completed."
|
echo "\nOperation completed."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue