Coder Social home page Coder Social logo

openterm's Introduction

Terminal for iOS

OpenTerm

Download on the App Store
(Previously called Terminal for iOS)

Swift Platform: iOS Build Status
Twitter Donate via PayPal

About

OpenTerm is a sandboxed command line interface for iOS.

Commands included:

awk cat cd chflags
chksum clear compress cp
credits cub curl date
dig du echo egrep
env fgrep grep gunzip
gzip help host link
ln ls mkdir mv
nc nslookup open-url pbcopy
pbpaste ping printenv pwd
readlink rlogin rm rmdir
say scp sed setenv
sftp share sleep ssh
ssh-keygen stat sum tar
tee telnet touch tr
uname uncompress unlink unsetenv
uptime wc whoami

Dependencies

To set up dependencies, run bootstrap.sh.

Running

Open OpenTerm.xcworkspace, change the bundle identifier to an identifier linked to your Apple developer account in order to run. Build using the OpenTerm scheme.

Running on device

To run on a device, you will have to run resign-frameworks.sh, but first change iPhone Developer: Louis D'hauwe (5U7B95VS8G) with the name of your own certificate.

License

OpenTerm is available under the GPLv2 (or later) and the MPLv2 license.

See COPYING for more license info.

openterm's People

Contributors

alessaba avatar basthomas avatar hevey avatar holzschu avatar ian-mcdowell avatar louisdh avatar maxkatzmann avatar mecid avatar n-holzschuch avatar palmin avatar reden87 avatar simpaa 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  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

openterm's Issues

Auto completion for history

We store a list of previously executed commands. It'd be quite simple to expose this to the auto completion code, so they are displayed as options to run again, most recently run first.

Would probably want to set a limit on how many commands from history can be displayed in auto complete.

x-callback-url client support

It would be very cool to be able to invoke automation capabilities in other apps through x-callback-url commands.

Imagine something like

 grep < myfile | x-callback-url workflow://run-workflow?name=Send%20Email&input=[stdin]

I am not sure about the syntax yet as it requires piping to be in place.

The important thing is to find a nice way to bridge command-line pipes to x-callback-url such that it is easy to pass stdin as input parameters and easy to get result from x-success or x-error and put this on stdout or stderr.

I opened this issue to gauge interest. Once piping is in place I would be happy to submit a PR with the work.

Terminal crash with special character ~

Weird bug. When I type ~ on my French logitech keyboard (⌥ + n), iOS waits for another key in case I want to type a special character (e.g. ñ).

When I type ~ in Terminal and press enter, I get this message
weird message 1

Then, if I press backspace twice, the first one delete the space after the :
weird message 2

And the second one makes the app crash.

Auto completion for directory contents

Currently, auto suggestions appear for the files/folders in the current directory. It'd be great if these could be smart about directory paths as they are entered.

For example:
Say my directory layout relative to the current directory is as follows:

  • hello
    • world
      • file.txt
      • test

If I type: cd, the auto completion will correctly list hello, since cd deals with folders, and hello is a folder in the current directory.

However, if I type cd hello/, it breaks. It should instead show world.
If I type cd hello/world/, it should display test and not file.txt, since cd only deals with folders.

Force touch cursor difficult to use due to colour

The force touch cursor is black which makes it invisible on the black background of the terminal. The only reason you can see where it is is from the intersection with the green characters on the screen.
Not sure if it's possible to control or if iOS handles this.

Handle files with spaces better

Currently you can't redirect an output to a file with spaces in its name.
E.g. the following doesn't work:

echo hello > "Hello world.txt"

Auto complete also doesn't account for spaces in files, so it will suggest adding file names with spaces in it, which then leads to unexpected actions for the user.

Ideally we would also support a backslash for escaping spaces.
Such that the following 2 are equivalent:

echo hello > "Hello world.txt"
echo hello > Hello\ world.txt

Standardize Indentation rules

Currently, both tabs & spaces are littered across the code. It'd be nice to set a standard and set project-wide Xcode settings for indentation, and add SwiftLint rules.

Document and/or file provider compatibility

I'm wondering if this app could be made compatible with document or file providers.

It could allow you to use Terminal to search for things using grep or reorganise files using the file system commands, that are stored in other apps. That would be awesome to interact with your iCloud Drive, Dropbox or the local checkout of a git repository from Working Copy.

Similarly other apps could get access to the data stored in Terminal's sandbox. That would especially be useful for text editors like Textastic or Pythonista.

Not sure if this is possible or feasible, but something to consider.

Scripting support

Since this app is taking the route of writing its own shell (instead of trying to recompile bash/zsh/fish/etc), it'd be great if that shell would support scripting. I have a few proposals:

File-based scripting

For example. I would like to write a script to create a new directory and cd to it:

echo "mkdir $1 && cd $1" > mkcd
chmod +x mkcd
./mkcd foo

In order for the above to work, a few features are required:

  • Execute script files (in $PATH and relative paths)
  • Pass and interpret arguments to scripts when executing

GUI-based scripting

While file-based scripting is closest to what other shells do, since this app is geared towards touch screen users on iOS, it might be a better experience to create a GUI, similar to the existing History panel, that contains user-defined scripts.

  • Runnable commands, like those from ios_system.
  • Defined using a visual editor
  • Sync with iCloud
  • If stored in files, stored outside of the root directory (i.e. not editable text files).

Lone quotation mark causes crash

Entering a quotation mark (“) on its own into the terminal causes it to crash on execution. It does not appear to be just an issue with it being unpaired as 123”, “123, and 12”3 work as expected. Single quotation marks (‘) do not exhibit this issue.

I think it might be that the terminal is trying to parse the following characters into a command to run, and getting no following characters. Things like “rm

Unpaired quotation marks handled strangely

It appears that when a quotation mark is seen by the terminal, it strips itself and the closing quotation mark and the result is taken literally. When the quotation mark is unpaired, instead of simply causing an error or assuming to close the quotation mark, the last character is stripped. This means that “rm shows r: command not found, but “rmz to show the usage for the rm command.

Related to this issue is the other issue I submitted, where entering only a “ crashes the app. The terminal is probably trying to strip the final character, but not finding one, and crashing.

Sample crash report: https://pastebin.com/NTthrH2F

Network commands

It'd be great to have network commands such as ping, telnet and dig for native command-line network diagnostics from iOS.

grep redirection from < file not working

While working on #26 I am having problems getting input redirection to work.

It can be replicated by entering

: echo test > test
: grep e test
test

: grep e < test
: 

where the problem is that the last grep does not output anything, since it should be working on stdin.

@holzschu I was able to fix the problem for x-callback-url by using fileno(stdin) instead of STDIN_FILENO as you suggest in the docs, but it seems grep does not do this. Let me know if you would like a PR for this.

iCloud Documents folder should be home (if iCloud enabled).

Currently home is set to the app's local folder (which has its local Documents folder as a subfolder). When iCloud is enabled, executing cd ~ should bring the user to the iCloud documents folder.

This can probably be fixed with a setenv, though my first attempts have been futile.
Not sure why this doesn't work:

setenv("HOME", DocumentManager.shared.activeDocumentsFolderURL.path.utf8CString, 0)

@holzschu Any clue what I'm doing wrong?

Man page support

Would love to see man pages available for each of the included utilities. There are a few options for where information from them could surface in-app:

  • man <command name> - View the man page for the command.
  • Auto completions - parse available arguments and surface above keyboard while typing
  • In-app help GUI. Render man page better than spitting it out into text view, put it into a UIViewController with some highlighting, etc.

Support for multiple tabs

I am preparing a change to support a tabbed interface, similar to macOS Terminal or iOS Safari. I'm using my own library, TabView, to accomplish this.

There are a few architectural issues that will need fixing to support this.

  • Currently, we rely on FileManager.currentDirectoryPath for the terminal, which is a process-wide variable. To support multiple tabs, it's required that each tab have its own "terminal" with its own working directory. On second thought, I don't believe it will be possible to have multiple concurrent working directories. It should work to switch between them when commands are run, however. This just means we can't support concurrent running commands.
  • CommandExecutor supports multiple instances, but the changes being made by @holzschu to the way it calls ios_system (in PR #63), will be in conflict with that, as it changes the process-wide stdout variable._

Here's a screenshot if my current tab UI for OpenTerm:

debbe4aa-0505-404b-97e8-046068963b65

Compile issue

Hi Louis!

I have some problems with compiling the app.
I had some time to investigate what's the problem and here's what I found:

The error message for me is the following (unmodified master branch):

ld: warning: directory not found for option '-L/Users/gergo.nemeth/Developer/terminal/Dependencies/ios_system/Frameworks'
ld: warning: directory not found for option '-F/Users/gergo.nemeth/Developer/terminal/Dependencies/ios_system/Frameworks'
ld: library not found for -lcrypto
clang: error: linker command failed with exit code 1 (use -v to see invocation)

In Xcode I see the following:

screen shot 2018-01-10 at 20 42 27

If I click the first libcrypto.a file in the File Inspector I see the following full file path:
/Users/gergo.nemeth/Developer/terminal/Dependencies/libssh2-for-iOS/lib/libcrypto.a

For the second libcrypto.a:
/Users/gergo.nemeth/Developer/terminal/Dependencies/ios_system/Frameworks/libcrypto.a

For the libssl.a:
/Users/gergo.nemeth/Developer/terminal/Dependencies/libssh2-for-iOS/lib/libssl.a

And for the libssh2.a:
/Users/gergo.nemeth/Developer/terminal/Dependencies/libssh2-for-iOS/lib/libssh2.a

The problem is that neither the libssh2-for-iOS/lib nor the ios_system/Frameworks folder can be found in the file system:

screen shot 2018-01-10 at 20 47 00

Is it possible that you did not add every file to version control?
Thanks for the answer in advance.

Missing iCloud Drive folder

cd ~ and then cd Documents take me to local OpenTerm folder, not iCloud Drive folder. Can't find a way to save files on iCloud Drive. Already check settings and I'm ok with "Save on iCloud Drive".

Git support

Would it be possible to add support for Git? It would be very useful

Support for iOS <11.0

Hello, there are many of us out there who still use iOS 10 or earlier, would it be possible to add legacy support to this app? (The App Store warns that this app is only compatible with iOS 11.0+)

app icon foreground color

I think a quick improvement to the app icon would be to change the text color of "~|" to the default foreground color 00DC00 of the terminal.

invoke OpenTerm through x-callback-url

I think it would be useful to be able to run commands in OpenTerm from other apps through x-callback-url, which is sort of the reverse of issue #26.

Imagine something along the lines of:

openterm://x-callback-url/run?command=grep%20find&input=stuff%20%on%20stdin%20to%find
                             &x-success=...&x-error=...

The command parameter is the command that is executed, while input is passed to stdin. Depending on the status code of the command either x-success or x-error callbacks are done with the text result from either stdout or stderr.

Since commands can do all sorts of things, it would probably be best to have a key parameter with a random password like Drafts and Working Copy have, such that users are not tricked into running malicious commands.

How would you feel about such a feature?

Anything you would like me to consider?

Additional commands

How would one go about adding additional commands themselves (e.g. nano, ssh, etc.)

CA certificate issue when using curl

Hi there. When trying to use the curl command, I’m getting the following output and no result. I’ve been unable to find any reference to this issue elsewhere, so thought it best to post here.

Wesley: curl "https://REDACTED"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (77) SSL: can't load CA certificate file /var/mobile/Containers/Data/Application/FF8326DA-0265-40D5-A8C5-F0EA506EE623/Documents/cacert.pem

Coding Shell builtins with Swift

It could be fine to implement a class for coding shell builtins, or maybe with JavaScript to made scripts downloadable,
for example:

class Command {
    /// Shared textView where print
    static var terminal: UITextView!

    func printtv(_ text: String) {
        terminal.text += text
    }

    var helpText: String? { return nil }

    /// Subclass and put code here
    func execute(arguments: [String]) {}
}

class Example {
   
    override var helpText: String? {
         return "Prints Hello World!"
    }

    override func execute(arguments: [String]) {
        printtv("Hello World!")
    }
}

I'll try to open a pull request for this feature.

Libssh missing symbols

Currently I am unable to compile master due to missing libssh symbols. I am not sure where these come from or how to compile the project.

Some complication instructions will be useful.

Add instructions for side loading, Python, etc.

I've still not successfully built Python after trying for a few hours...It'd be nice to have some instructions on how to enable Python, Lua, etc, locally.

Additionally, what specific reasons/guidelines are we using for whether to include a command by default or not? In my opinion, Python and Lua should be included by default.

@holzschu is probably the expert in this area.

first tab behaving weird on iPhone X

I am working to adapt Drag and Drop to the new tabbed interface (commit 255da5f) and the first tab disappears above the navbar on iPhone X.

This happens when the first tab is the only one, but also when adding a new tab. Second tab does not seem to have this problem.

img_c1270fb2f3b3-2

It was hard to get this on the screenshot but as the cursor blinks you can see a small green dot on the left side of the screen below the tab bar.

Directory selection with Dropbox

I can successfully select a directory inside iCloud drive or working copy and everything works as expected.

But if I try to use a dropbox folder nothing happens. I'm going to guess this is an issue with the dropbox files provider and not OpenTerm but wanted to report it incase something can be done.

Limit commands to Documents folder

Currently it's possible to "escape" the documents folder and peek at the system hierarchy (e.g. cd / will bring you to the root of iOS). Apple may find this reason to remove the app from the App Store. Therefore, I was wondering if there's any way to easily limit all commands to a certain folder scope.

Suggestion: Better xterm compatibility

Would it be possible to have the terminal window emulate a xterm? With control caracters to change font color, bold, etc?

Try "curl -s wttr.in/london" in a MacOS Terminal window and in Terminal so see the effects.

Pipe is not working.

Hi,

First of all thank you for great app :)
I have problem. When type in in prompt:

`
iPad (1710): ls | wc

ls: wc: No such file or directory

ls: |: No such file or directory
`

Is ‚pipe’ supported by Terminal app?

Best regards
Arek

Keyboard input should bring the cursor back to the input line

When selecting text the cursor stays in the position the user puts it, after this any keyboard input is ignored unless the cursor is manually returned to the input line. I believe expected behaviour is that the view would scroll to the input line and text input would immediately begin.

Crash when scrolling InputAssistant and pressing 'U'.

Seems that there's a crash happening only when you scroll the InputAssistant and then press 'U' on the US keyboard. I can't seem to see it crash for other letters (didn't try them all), but 'U' is 100% reproducible.

Video link of issue.

It looks like the crash is occurring (I think) in the InputAssistantCollectionView.swift:82

guard let inputAssistantView = inputAssistantView, let name = inputAssistantView.dataSource?.inputAssistantView(inputAssistantView, nameForSuggestionAtIndex: indexPath.row) else {
    fatalError("No suggestion name found at index.")
}

For some reason index 0,0 is initially skipped over, yet once we try to access it, it results in a crash.

(lldb) po indexPath
▿ 2 elements
  - 0 : 0
  - 1 : 1

(lldb) po indexPath
▿ 2 elements
  - 0 : 0
  - 1 : 2

(lldb) po indexPath
▿ 2 elements
  - 0 : 0
  - 1 : 3

(lldb) po indexPath
▿ 2 elements
  - 0 : 0
  - 1 : 4

(lldb) po indexPath
▿ 2 elements
  - 0 : 0
  - 1 : 0

(lldb) po inputAssistantView.dataSource?.inputAssistantView(inputAssistantView, nameForSuggestionAtIndex: indexPath.row)
error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x0).
The process has been returned to the state before expression evaluation.

Crash log can be seen below.

2018-02-08 00:22:15.859558-0800 OpenTerm[4870:174896] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndexedSubscript:]: index 9223372036854775806 beyond bounds [0 .. 4]'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010999c12b __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x0000000109030f41 objc_exception_throw + 48
	2   CoreFoundation                      0x00000001099dc0cc _CFThrowFormattedException + 194
	3   CoreFoundation                      0x00000001099cd9cf -[__NSArrayM objectAtIndexedSubscript:] + 175
	4   UIKit                               0x000000010b595c52 -[_UIFlowLayoutSection setSize:forItemAtIndexPath:invalidationContext:] + 1486
	5   UIKit                               0x000000010b598f37 -[_UIFlowLayoutInfo setSize:forItemAtIndexPath:] + 417
	6   UIKit                               0x000000010b50cf86 -[UICollectionViewFlowLayout invalidationContextForPreferredLayoutAttributes:withOriginalAttributes:] + 304
	7   UIKit                               0x000000010b4c205a -[UICollectionView _checkForPreferredAttributesInView:originalAttributes:] + 591
	8   UIKit                               0x000000010b4c2b62 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 974
	9   UIKit                               0x000000010b4c278e -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 35
	10  UIKit                               0x000000010b4c7d00 -[UICollectionView _updateVisibleCellsNow:] + 4860
	11  UIKit                               0x000000010b4c9ad8 -[UICollectionView _updateVisibleCellsNow:] + 12500
	12  UIKit                               0x000000010b4c9ad8 -[UICollectionView _updateVisibleCellsNow:] + 12500
	13  UIKit                               0x000000010b4c9ad8 -[UICollectionView _updateVisibleCellsNow:] + 12500
	14  UIKit                               0x000000010b4cdc21 -[UICollectionView layoutSubviews] + 364
	15  UIKit                               0x000000010aac1a6d -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1439
	16  QuartzCore                          0x00000001110c461c -[CALayer layoutSublayers] + 159
	17  QuartzCore                          0x00000001110c87ad _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 401
	18  QuartzCore                          0x000000011104f86c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 364
	19  QuartzCore                          0x000000011107c946 _ZN2CA11Transaction6commitEv + 500
	20  QuartzCore                          0x000000011107d694 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 76
	21  CoreFoundation                      0x000000010993ec07 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
	22  CoreFoundation                      0x000000010993eb5e __CFRunLoopDoObservers + 430
	23  CoreFoundation                      0x0000000109923124 __CFRunLoopRun + 1572
	24  CoreFoundation                      0x0000000109922889 CFRunLoopRunSpecific + 409
	25  GraphicsServices                    0x000000011097f9c6 GSEventRunModal + 62
	26  UIKit                               0x000000010a9f05d6 UIApplicationMain + 159
	27  OpenTerm                            0x00000001086a2fe7 main + 55
	28  libdyld.dylib                       0x000000010f391d81 start + 1
	29  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

I can open a ticket on InputAssistant, but since I see @IMcD23 on here, I figure I'd place it here first.

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.