Shortcuts für PlatformIO
This commit is contained in:
parent
ab2f2580a8
commit
370f5109b5
6 changed files with 77 additions and 0 deletions
54
oh-my-zsh/custom/platformio.zsh
Normal file
54
oh-my-zsh/custom/platformio.zsh
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# PlatformIO Helper-Funktionen
|
||||
# Findet das PlatformIO-Projektverzeichnis (wo platformio.ini liegt)
|
||||
_pio_find_root() {
|
||||
local dir="$PWD"
|
||||
while [[ "$dir" != "/" ]]; do
|
||||
if [[ -f "$dir/platformio.ini" ]]; then
|
||||
echo "$dir"
|
||||
return 0
|
||||
fi
|
||||
dir="$(dirname "$dir")"
|
||||
done
|
||||
echo "Fehler: Kein PlatformIO-Projekt gefunden (platformio.ini fehlt)" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
# Build
|
||||
alias piob='_pio_build'
|
||||
_pio_build() {
|
||||
local root=$(_pio_find_root) || return 1
|
||||
echo "Building in: $root"
|
||||
(cd "$root" && pio run)
|
||||
}
|
||||
|
||||
# Upload
|
||||
alias piou='_pio_upload'
|
||||
_pio_upload() {
|
||||
local root=$(_pio_find_root) || return 1
|
||||
echo "Uploading from: $root"
|
||||
(cd "$root" && pio run --target upload)
|
||||
}
|
||||
|
||||
# Monitor
|
||||
alias piom='_pio_monitor'
|
||||
_pio_monitor() {
|
||||
local root=$(_pio_find_root) || return 1
|
||||
echo "Starting monitor from: $root"
|
||||
(cd "$root" && pio device monitor)
|
||||
}
|
||||
|
||||
# Upload + Monitor (praktische Kombi)
|
||||
alias pioum='_pio_upload_monitor'
|
||||
_pio_upload_monitor() {
|
||||
local root=$(_pio_find_root) || return 1
|
||||
echo "Upload & Monitor from: $root"
|
||||
(cd "$root" && pio run --target upload && pio device monitor)
|
||||
}
|
||||
|
||||
# Clean
|
||||
alias pioc='_pio_clean'
|
||||
_pio_clean() {
|
||||
local root=$(_pio_find_root) || return 1
|
||||
echo "Cleaning: $root"
|
||||
(cd "$root" && pio run --target clean)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue