mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 22:57:46 +00:00
Add helpers
folder and add script for running C/C++ quickly (#241)
This commit is contained in:
parent
4ab39c0d09
commit
0f9d10d78d
2 changed files with 40 additions and 0 deletions
13
helpers/README.md
Normal file
13
helpers/README.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Helpers
|
||||
|
||||
Commands to make your life easier.
|
||||
|
||||
## How to use
|
||||
|
||||
Execute following snippet at any time to be able to run the commands in the scripts:
|
||||
|
||||
```zsh
|
||||
source './path/to/script.nu'
|
||||
```
|
||||
|
||||
With `./path/to/...` being the path to the script you want to utilize.
|
27
helpers/run-c-cpp.nu
Normal file
27
helpers/run-c-cpp.nu
Normal file
|
@ -0,0 +1,27 @@
|
|||
# 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue