Giter VIP home page Giter VIP logo

shell-turtlestein's Introduction

Shell Turtlestein

A quick and simple way to run arbitrary shell commands in Sublime Text.

Mr. Turtlestein acts as a more flexible alternative to Sublime's build systems. Commands run in your project's directory:

input a shell command

And display their output just like Sublime's build systems:

command output

Input and output

Unix's familiar | and > operators can be used to pipe/redirect a command's input and output:

  • To pipe the active view's selections to a command, add a leading pipe character (e.g. | sort). If there are no non-empty selections the entire file will be piped to the command.
  • To pipe a command's output back into the view, add a trailing pipe character (e.g. | sort |).
  • To redirect the command's output to a new file, add a trailing greater than symbol to the command (e.g ls > or | sort >).

Using snippets

Snippets are available for frequently used commands. All snippets with the scope name source.shell (source.dosbatch for Windows users) can be used in the prompt shown above. I have some examples you can take a look at to get an idea for this.

Default keybindings

  • Ctrl + Shift + C (Cmd + Shift + C): prompt for a shell command
  • Ctrl + Alt + Shift + C (Cmd + Alt + Shift + C): launch a terminal in the window's directory
  • Ctrl + Shift + X (Cmd + Shift + X): re-run the previous command

Optional Configuration

In your own Packages/User/Shell Turtlestein.sublime-settings file you can override the following settings:

  • surround_cmd: A two-element array that specifies text to append before and after the command (e.g. ["source ~/.profile && ", ""]).
  • exec_args: The arguments that will be passed to ExecCommand. The same options that are available to build systems are available here, but file_regex, line_regex, encoding, env, and path are the only options that make sense to use with this plugin. Arguments specified in the cmd_settings (see below) will override these defaults.
  • cmd_settings: An array of configurations to use for commands that are executed. The first configuration to match the command being run will be used. The keys that each configuration should have are:
    • cmd_regex: A regex that must match the command for this configuration for this configuration to be used.
    • exec_args and surround_cmd override the settings described above for any matching command.
  • prefer_active_view_dir: If set to true, prefer using the directory of active file over using a folder open in the current project.

PAQ

Q: Who the balls is Shell Turtlestein?

A: He was a pet turtle that died in some episode of Modern Family. That's about as high-brow as my references get. R.I.P. Shell :(

Q: What does "PAQ" stand for?

A: Possibly asked questions

Thanks!

Thanks to all the contributors. I'd give you all high fives if my arm would fit through the internet.

shell-turtlestein's People

Contributors

cj avatar du-song avatar gsingh93 avatar inkytonik avatar laggingreflex avatar misfo avatar oker1 avatar rundef avatar stoopbrain avatar tresni avatar vinh0604 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shell-turtlestein's Issues

Strip out '\r' in Windows

On Windows, when piping the output of a command to a new view, the output ends up with carriage return markers ([CR]). I think this is expected in Sublime Text, because Sublime does not automatically strip out these characters from the view. Mr. Turtlestein should do this on the output from the command.

Can't use environment variables in shell snippet

The following snippet:

<snippet>
    <content><![CDATA[cvs up $TM_FILENAME]]></content>
    <tabTrigger>up</tabTrigger>
    <scope>source.shell,source.dosbatch</scope>
</snippet>

fills in an empty string for the $TM_FILENAME variable. Could it be carried through from the file that has focus when the shell is brought up, perhaps along with any other relevant environment variables?

PATH configuration

I think that it'd be nice to have a simple way to add paths for this package.

Setting path doesn't work.

Hi,

So I have:

{
    "cmd_config": [{
    "exec_args": {
      "path": "/usr/local/bin:$PATH"
    }
  }],
    "input_widget": {
        "syntax": "Packages/ShellScript/Shell-Unix-Generic.tmLanguage"
    }
}

but it will not run commands. If I make cmd_config an empty array it will run commands just fine.

I have this for my coffee-script build and it works just fine:

{
   "cmd": ["/usr/local/bin/coffee", "-p", "$file"],
   "selector": "source.coffee",
   "path": "/usr/local/bin:$PATH"
}

p.s. thank you for such a great plugin.

Add command to filter selection through shell command

A command I missed from a previous editor (Emacs, I think) was to be able to select some text and filter it through a shell command. E.g., you might select a paragraph and send it through wc to count the words in it.

By default, the selection would be replaced by the output of the command. E.g., I have a program that formats Scala import directives, so I can select the imports in a file then filter them through that command to tidy them up.

Anyway, I built an ST2 command to do this, but it occurs to me it would be a nice addition to your package. What do you think?

The code is easy and I'm happy to contribute it if you want it. I haven't put together a pull request because I'm not sure how you would prefer to integrate it.

Strange readline behavior

There's some strange behavior based on the readline stuff that I added. For instance, you can <Backspace> your way to the previous command (since it's just a multi-line view). So <Backspace> and probably other keybindings need to be overridden.

shell_cmd or cmd is required

Ctrl+Shift+C, type command and execute errors to this message:

shell_cmd or cmd is required

This change resolved it for me:

--- a/Default (Windows).sublime-keymap  
+++ b/Default (Windows).sublime-keymap  

@@ -1,5 +1,5 @@
 [
-   {"keys": ["ctrl+shift+c"], "command": "shell_prompt"},
+   {"keys": ["ctrl+shift+c"], "command": "shell_prompt", "args": { "cmd": ["cmd.exe"] } },
    {"keys": ["ctrl+shift+x"], "command": "shell_prompt", "args": { "run_previous": true } },
    {"keys": ["shift+ctrl+alt+c"], "command": "subprocess_in_cwd", "args": {
        "cmd": ["cmd.exe"]

Feature Request: Path Follows Open Files

Folks, any way we can have the current working directory be the same as the file that is open?

For example, if you have several files open from several projects, it would be nice to have the shell pickup the current working directory of each file as you hit Shift+Command+C

History

It would be nice to be able to hit the up arrow to get your previously run commands like when you do a find/replace.

Command not found

I tried using "grunt" but it says "/bin/sh: grunt: command not found". But when I "CD" to the project from a terminal and used "grunt" command, it worked fine. It goes the same for "bower". But built-in commands like "CD", "LS" are working fine in your plugin. How do I fix it?

ST3 support

Is there any chances we'll see ST3 support in nearby future?

Thanks

Default keyboard shortcuts

Could it be possible to not have any defaulted keyboard shortcuts… They class with another packages I have installed and it makes change everything…

Thanks

No module named 'sublime_readline

I'm getting this exception in the console. I'm using ST3.

reloading plugin Shell Turtlestein.shell_turtlestein
Traceback (most recent call last):
  File "/opt/sublime_text_3/sublime_plugin.py", line 73, in reload_plugin
    m = importlib.import_module(modulename)
  File "X/importlib/__init__.py", line 88, in import_module
  File "<frozen importlib._bootstrap>", line 1577, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1558, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1525, in _find_and_load_unlocked
  File "/opt/sublime_text_3/sublime_plugin.py", line 671, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "shell_turtlestein in /home/gulshan/.config/sublime-text-3/Installed Packages/Shell Turtlestein.sublime-package", line 4, in <module>
ImportError: No module named 'sublime_readline'
reloading plugin Shell Turtlestein.sublime_readline

Aliases

Is there a way of having aliases defined in ~/.bash_profile be available in the prompt? Alternatively, is there a way of defining aliases for use with Shell Turtlestein?

Thanks for the great work.

missing output after running any command

Hello,

after running any command like "ls", for example, the output window pops up at the bottom but stays empty.

I had a short skip warning in the status bar saying "couldn't determine language', but after reinstalling the package I can't reproduce the warning, but still, the output does not show up.

Thanks for any help.

Stop an existing task such as Grunt watch?

I was loving the turtle until I hit this.

If I have a watch task that I initiate from 'The Turtle', is there any way I can then stop it?

Opening the turtle and hitting CTRL+C / CTRL+Z has no effect. Tried sending killall -9 grunt and the like to no avail.

Should it be possible to stop it with a command or key press?

Not UTF-8 output

I get an "[Decode error - output not utf-8]". I'm using Windows 7 x64 Russian, so the output in cmd.exe is in CP866. The output was generated by a php script (PHP v5.4.4 , so UTF8 is the default encoding). None of the cyrillic chars are used in path to project or username (using Administrator account), so I think the problem is in cmd's default encoding. Can this be fixed ?

Should file name be Shell Turtlestein.sublime-settings ?

Readme says that the file to create for custom config is
Packages/User/Shell Turtlestein.sublime-commands

That didn't work for me. Googling a bit pointed me to Packages/User/Shell Turtlestein.sublime-settings and that worked for me. Is this something that needs to be fixed in readme? I'm running Sublime Text 2 Build 2217 on OSX.

Add a shortcut to rerun the previous command

I am often running the same commands over and over (ex rspec spec) so I press cmd-shift-c up enter. it would be nice if I could press cmd-shift-(dot) and have it do the same. I think thats a pretty common use case.

Crashes plugin_container on Windows 8

I use this to execute a batch script to checkout an svn branch and sometimes it will crash the plugin_container in mid stream.

Sublime Text 3 - Stable Channel, Build 3059

batch script (in case of relevance):

@echo off

    IF EXIST C:\Users\Andrew\Documents\Branches\aleslie-FIVE-%1 GOTO NO
    IF EXIST C:\Users\Andrew\Documents\[old]\aleslie-FIVE-%1 GOTO NO

    echo Creating Branch
    svn cp svn://SVNSERVER/trunk svn://SVNSERVER/dev/aleslie-FIVE-%1 -m "Creating branch aleslie-FIVE-%1" 

    echo Checking Out.
    svn co svn://SVNSERVER/dev/aleslie-FIVE-%1 C:\Users\Andrew\Documents\Branches\aleslie-FIVE-%1

    echo Done.

    copy "C:\Users\Andrew\Documents\Aptana Studio 3 Workspace\trunk\config.inc.php" C:\Users\Andrew\Documents\Branches\aleslie-FIVE-%1\config.inc.php

    GOTO FINISH


:NO
    echo Branch already exists.
    pause

:FINSIH

Let me know if you need anymore information and I'll post it on next crash.

Issue with running PHP Code Sniffer against currently opened (focussed) file

Having difficult finding the correct syntax for opening up a Windows command prompt and running phpcs against the current file. All I get is an empty command prompt opening without the command I hoped to run. The following is what I thought it might be but unsure of where I am going wrong.

Can anyone help?

{ "keys": ["ctrl+shift+c"], "command": "subprocess_in_cwd",
    "args": { "cmd": ["cmd.exe"] },
    "exec_args": { "cmd": ["phpcs", "--standard=\"%USERPROFILE%/phpcs-ruleset.xml\"", "$file"] }
}

Shell Interactive mode, Other usability

I am using sublime on ubuntu linux platform.

This plug-in works to send shell commands, line by line.

Following are the issues which I came across:

  1. While editing shell script, no way of highlight select multiple lines of text
    and to be sent to terminal.

  2. Shell stdout screen is nice within workspace but it doesn't support to work with
    an interactive shell app like gdb, R, etc requires the user input.

  3. Could possibly the console screen output in second tab? when I use two column format, it is not nice.

cmd settings

there should be settings to change default command prompt on ctrl+shift+alt+c.
For example git bash for windows users instead windows cmd.

Is possible to open the shell in a new tab?

If I do like you said "ctrl+shift+c" it will open a small console at the bottom. If I run my command and then hit "esc" it will close the console, but the process will still be running.

I don't know how to open it again therefore I think it will be a better way to open in a new tab.

Default terminal instead of gnome-terminal (Linux)

Referring to ctrl + alt + shift + C's Linux keybinding

It shouldn't load gnome-terminal by default (not every linux distribution has gnome-terminal, nor some of us want it as the default).

I'm pretty sure there are quite a few ways to get the name of the terminal and then execute it (though i lack the knowledge). You can get the name of the default terminal by executing this command gsettings get org.gnome.desktop.default-applications.terminal exec but it still requires Gnome.

Feature Request: Command History

It would be nice to have a command history, where pressing up would go to the previous command and pushing down would go to later commands.

Command Console Not Opening in ST3

I am using ST3 build 3059 on Windows.

I find that the command prompt will not open in response to Ctrl-Shift-C, contrary to expectations. I am confident the key mapping is OK. I can open a built in command prompt with Ctrl+`.

I have seen exactly the same behaviour with the similar 'Shell Command' package. I wonder if there is a bug with ST3 and Windows here?

Shell_cmd or cmd is required error

Im getting the following:

shell_cmd or cmd is required
[cmd: ]
[dir: /Users/luismartins/Sites/webipack018/themes/front]
[path: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/share/npm/bin]
[Finished]

am I missing something on my configuration?

FR: Colors!

Colors FTW

Shell Turtlestein on the left, Terminal on the right.

Support for terminal colors

Currently color escape characters are displayed as:

img

It would be nice to have support for coloring the output inside sublime

Running commands on bash

Hi there,

I love turtlestein concept, however I'm not managing to get the most of out it. I've set my user settings like this:

{
    "surround_cmd": ["source ~/.bashrc &&", ""]
}

However, when I run a command what I get is:

/bin/sh: 1: source: not found

does this mean commands are run in /bin/sh ? any way I can get bash for my commands? I want to load my .bashrc for loading Python virtualenvs.

Thanks, cheers
Miguel

End session [feature-request]

If you run a command and hit Esc the shell keeps running in the background to let the command finish. Sometimes it's good that it does that, but other times it's a nuisance. There should be an option to let the user choose which behavior they want. Better yet, a user could configure Esc for current default behavior (let run in background) and Shift+Esc to force exit the shell.

Project setting for workingdir

For some projects, you'll be in a directory that doesn't have the makefile and it makes no sense for turtlestein to execute commands there. A setting like shellturtlestein_workingdir in the project settings would solve that.

s = window.active_view().settings() if s.has("shellturtlestein_workingdir"): return s.get("shellturtlestein_workingdir")

in cwd_for_window will add that feature.

Alternatively, you could interpret the "cd" command for the shell-turtlestein's working directory. E.g., if I'm in C:\Test\src in turtlestein, I could type cd .. in turtlestein and move to the parent directory and execute commands there.

Interpret % as current filepath

Just wondering if you could implement interpreting % as the path and name of the current views file like vim (eg. /home/foo/bar/projects/baz.ext )?

Use git sh.exe shell instead of windows default command prompt?

On windows I mainly use git's sh.exe ("C:\Program Files (x86)\Git\bin\sh.exe" --login -i) , with my customized .bashrc. Is there a way to use that to execute commands in instead of in windows default command prompt?

I tried running

"C:\Program Files (x86)\Git\bin\sh.exe" git status

but it gives error

"C:/Program Files (x86)/Git/bin/sh.exe": /usr/cmd/git: No such file or directory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.