Showing posts with label Sublime Text 3. Show all posts
Showing posts with label Sublime Text 3. Show all posts

11/24/2015

Custom Build System for PHP Scripts: Sublime3



# Sublime3 : Custom Build System for PHP

## Helps to run and debug PHP Scripts directly using Sublime3
## Note: PHP Binary ( php.exe ) should be within SYSTEM PATH
Otherwise You should edit Build System and paste absolute Path for php.exe binary

# Code 


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
 "shell_cmd": "php.exe -f  \"${file}\"",
 "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
 "working_dir": "${file_path}",
 "selector": "source.php, source.php4, source.php5",

 "variants":
 [
  {
   "name": "Run with CMD",
   "shell_cmd": "start cmd.exe /k php.exe -f  \"${file}\""
  },
  {
   "name": "Run and Only Lint PHP Code",
   "shell_cmd": "start cmd.exe /k php.exe -l  \"${file}\""
  },
  {
   "name": "Start PHP Development Server",
   "shell_cmd": "start cmd.exe /k php.exe -S 127.0.0.10:8080 -t \"${file_path}\""
  },
  {
   "name": "Launch Home Page for Server (Google Chrome)",
   "shell_cmd": "start chrome http://127.0.0.10:8080"
  },
  {
   "name": "Launch Home Page for Server (Mozilla Firefox)",
   "shell_cmd": "start firefox http://127.0.0.10:8080"
  },
  {
   "name": "Launch Home Page for Server (Explorer)",
   "shell_cmd": "start http://127.0.0.10:8080"
  },
  {
   "name": "Launch Home Page for Server (MS Edge)",
   "shell_cmd": "start microsoft-edge:http://127.0.0.10:8080"
  },
  {
   "name": "Launch Home Page for Server (Internet Explorer)",
   "shell_cmd": "start iexplore http://127.0.0.10:8080"
  },
  {
   "name": "Generate Syntax Highlighted Code and Copy to Clipboard",
   "shell_cmd": "php.exe -s \"${file}\" | clip"
  }
 ]
}

# Video Tutorial




1/21/2015

Custom Build System for Python : Sublime-Text-3


# Result ( For Linux ):- 
    # Allow you to run Python Script Directly, Just hit CTRL+B
    # Debug your Python script easily using IPython Terminal/Console.
        # So, You have a Python Script and there is something that you want to check out after completion of Python Script. then you need to Hit SHIFT+CTRL+B keys.
        # So that Sublime runs build+run command, So far we have defined that first we want to execute our script using IPython interactive environment and then we want to take a look at Objects/Variables/results/output generated by our Python script.



# Sublime 3: Custom Build System Script for Python :-


{
    "shell_cmd": "xterm -hold -e python \"$file\"",
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python, source.py",

    "variants":
    [
        {
            "name": "Run",
            "shell_cmd": "xterm -fg green -hold -e ipython -i \"${file}\""
        }
    ]
}

1/11/2015

Custom Build System for C++11 : Sublime-Text-3






# Why sublime-text?
    # Because, it is lightweight, portable, and runs on Win/Linux/MacOS.
    # and it is really awesome.
    # it is more flexible and extensible.
    # You can turn your Sublime-text editor into a FULL featured IDE.
    # I really use it for C/C++/HTML/JS/CSS/Python/Java, and it is great.
    # Sublime-Text Editor is more real, because it allows you to customize almost everything.
    # For Compiled languages, you can use pre-built BUILD SYSTEM or create your own.
    # Snippet, that is a great idea and that would be great if you learn, how to write snippet and use them.

# Why we are here?
    # What is Build-system in Sublime-Text Editor?
        # Build-system allows you to write and build programs directly ( Just hit, CTRL+b ) and if you want to run build binary ( Just hit, SHIFT+CTRL+b )
        # Build System ( RUN, BUILD ) basically allows you to run Two COMMANS using their shortcut key, that really does not matter which command you want to invoke with CTRL+b and CTRL+SHIFT+b.



    # What about pre-built BUILD SYSTEM for C++
        # Hmm, that is great, but we want some more functionality ( I want to pass some command line parameters ) , this is why we want to write our own Custom BUILD SYSTEM for C++.

    # Sublime-Text Build System Script for C/C++
    ## When, You want to use Flags like, -std=c++11
    #### C++11.sublime-build ( FOR LINUX )

{
    "shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++, source.cpp",

    "variants":
    [
        {
            "name": "Run",
            "shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -std=c++11 && \"${file_path}/${file_base_name}\""
        }
    ]
}
    ####

    ## When, you want to run your program in Terminal ( xterm ) instead of sublime-Text console, Becaue you can pass input using Sublime-Text Console.
    ## NOTE, that you may not be able to see terminal because your program won't wait for your response.
    ## So, you need to stop your C/C++ program from being exiting automatically.
    #### C++11.sublime-build

{
    "shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++, source.cpp",

    "variants":
    [
        {
            "name": "Run",
            "shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -std=c++11 && \"${file_path}/${file_base_name}\""
        }
    ]
}
    ####

    # When, you want to run your program in a separate terminal process, that won't exit automatically even if program exists itself or you can tell xTerm, not to close itself.
    # FINAL Version : filename: C++11.sublime-build
    # PATH : $USER_HOME/.config/sublime-text-3/Packages/User/
    # FOR LINUX Operating System
    #### C++11.sublime-build

{
    "shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++, source.cpp",

    "variants":
    [
        {
            "name": "Run",
            "shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -std=c++11 && xterm -fg green -bg black -hold -e \"${file_path}/${file_base_name}\""
        }
    ]
}
    ####

    # FINAL Version : filename: C++11.sublime-build
    # PATH : %sublime-text-3%\Packages\User\
    # For Windows:-
        # NOTE, Ensure that GNU GCC Compiler is in your System PATH environment variable.
        # If you want to check whether g++/gcc BINARY is in your system PATH.
             # use  which   Command for LINUX (  which -a g++ )
             # use  where   Command for Windows  (  where gcc )

        # So if you are a Windows user and you might want to use some external Terminal Emulator Programs for Windows, just like, ( mintty, console2, cmder, conemu ) .
        # I recommend you to use mintty terminal emulator for windows that works just as  xterm   in Linux.

        # Command Example:-

mintty --hold always -e g++ sample.cpp -o sample.exe

        # One, more TIP for windows user( Optional for Linux Users)
            # Sometimes you might want to supply some input to your program.
            # There are actually two ways, first, You are going to type each and every required value, but for sublime, let me tell you one thing, Sublime-Text-3 console is not Interactive, means it will not ask you for any input, this just runs and show you the output.
            # BUT you have second option, When you want to automate your compiled program, OK, we are going to write every required query for proper functioning of our program in a separate text file and tell Sublime-Text-3 to take input data from this file Instead of STDIN FILE.

{
    "shell_cmd": "g++ -std=c++11 \"${file}\" -o \"${file_path}/${file_base_name}.exe\"",
    "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
    "working_dir": "${file_path}",
    "selector": "source.c, source.c++, source.cpp",

    "variants":
    [
        {
            "name": "Run",
            "shell_cmd": "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" -std=c++11 && mintty --hold always -e \"${file_path}/${file_base_name}.exe\""
        }
    ]
}





# Take a look :-


# Download Sublime Text Editor :-
    http://www.sublimetext.com/
    http://www.sublimetext.com/3


# References :-
    http://sublime-text-unofficial-documentation.readthedocs.org/en/latest/reference/build_systems.html