Madiwka4 4 anni fa
parent
commit
807b0dc9ec
2 ha cambiato i file con 56 aggiunte e 16 eliminazioni
  1. +22
    -5
      README.md
  2. +34
    -11
      setup.sh

+ 22
- 5
README.md Vedi File

@@ -1,3 +1,9 @@
# Overview

This is a fork of RinRi's <a href="https://github.com/RinRi-D/cpsrc">cpsrc</a>, but made to be compatible with Debian based Operating Systems, and use Visual Studio Code instead of neovim.

It also has a couple tweaks, such as custom directories, better dpendency compatibility, and custom program names.

# Installation

Clone the repository and make setup.sh executable and run it:
@@ -9,9 +15,20 @@ chmod +x setup.sh
./setup.sh
```

First, you have to write template which will be used to create new files. Remember the number of the line with which you usually start coding. Enter it. That is it!
First, you are given the choise to enter your custom directory, for example,

```
Enter custom directory for code? [y/N] y
Enter directory for files:
/home/user/Code
Set directory as /home/user/Code

```
and your files will be unpacked in /home/user/Code!

Next, you can create your own template. This doesnt support pre-selected lines, since it doesn't work on VIM!

# Using
# Usage

In order to create a new .cpp file, you have to run create.sh with filename argument without an extension:

@@ -19,10 +36,10 @@ In order to create a new .cpp file, you have to run create.sh with filename argu
./create.sh 1234a
```

You will be automatically redirected to neovim.
You will be automatically redirected to VSCode.

To compile&run file, you can just use run.sh with filename(this time with extension):
To compile&run file, you can just use run.sh with filename, (also without extension)

```shell
./run.sh 1234a.cpp
./run.sh 1234a
```

+ 34
- 11
setup.sh Vedi File

@@ -1,18 +1,41 @@
echo "Your distro? ( 1)Arch, 2)Debian): "
read distro
if [ $distro -eq 1 ]
then
sudo pacman -Syu g++ code
elif [ $distro -eq 2 ]
then
sudo apt update
sudo apt upgrade
sudo apt install g++ code
else
echo "Please install these packages manually: Code, G++"
read -p "Press enter to continue" A
fi

read -r -p "${1:-Set custom directory for code? [y/N]} " response
case "$response" in
[yY][eE][sS]|[yY])
echo "Enter directory for files:"
read DIR
echo "set dir as $DIR"
;;
*)
echo "Setting this directory"
;;
esac

# create.sh
echo $'cp template.cpp $1.cpp\nnvim -s .gg $1.cpp' > create.sh
echo 'cp template.cpp $1.cpp \n code $1.cpp' > $DIR/create.sh

# template
read -n 1 -r -s -p $'Press any key to create template file...\n'
nvim template.cpp

# start line
read -p $'Enter starting line of cursor:\n' line
((line=line-1))
echo "$line"gg > .gg
read -p "Press enter to create template" A
code $DIR/template.cpp

# run.sh
echo $'g++ -g $1\n./a.out' > run.sh
echo 'g++ -o $1.out -g $1.cpp\n./$1.out' > $DIR/run.sh

# make all executable
chmod +x create.sh
chmod +x run.sh
chmod +x $DIR/create.sh
chmod +x $DIR/run.sh

Caricamento…
Annulla
Salva