Files
dotfiles/dot_config/nushell/nu_scripts/sourced/run-c-cpp.nu
Cian Hughes 896af887ca Changed . token to _dot
This change allows the dotfiles to work with chezmoi (e.g: on windows)
and improves grepability with neovim/telescope
2024-11-07 13:52:17 +00:00

28 lines
761 B
Nu

# Runs C code via GCC without leaving a file behind
def rcc [
file: path # The file to run
] {
# Remove exe if still exists
rm $"($file).exe" --permanent --force
# Compile code to exe
^gcc ("." | path join $file | path expand) -o ("." | path join $"($file).exe" | path expand)
# Execute exe
^$"($file).exe"
# Remove exe
rm $"($file).exe" --permanent --force
}
# Runs C++ code via g++ without leaving a file behind
def r++ [
file: path # The file to run
] {
# Remove exe if still exists
rm $"($file).exe" --permanent --force
# Compile code to exe
^g++ ("." | path join $file | path expand) -o ("." | path join $"($file).exe" | path expand)
# Execute exe
^$"($file).exe"
# Remove exe
rm $"($file).exe" --permanent --force
}