summaryrefslogtreecommitdiff
path: root/Shell
AgeCommit message (Collapse)Author
2020-04-13Shell: Suggest local executables and directoriesStephan Unverwerth
...when no matching executable could be found in $PATH
2020-04-13Shell: Complete .hidden files if token starts with a dotAnotherTest
2020-04-13Shell: Avoid spamming debug output with suggestionsAnotherTest
2020-04-13Shell: Do not manually write to the editor buffer when completing pathsAnotherTest
2020-04-11LibLine: Display suggestions and cycle between themAnotherTest
With extra color (tm) This commit also patches the users of LibLine to properly use the new API
2020-03-31LibLine: Rename LineEditor.{cpp,h} => Editor.{cpp,h}Andreas Kling
2020-03-31LibLine: Rename LineEditor to Line::EditorAndreas Kling
2020-03-31LibLine: Rename from LibLineEditAndreas Kling
2020-03-31LibLineEdit + Shell: Handle Termios internally and give a copy if askedAnotherTest
This moves the Termios logic inside LibLineEdit and allows users to simply forget about the existence of termios if they so choose to :^)
2020-03-31LibLinEdit + Shell: handle signalsAnotherTest
This allows the LineEditor to get notified about signals, since we cannot set signal handlers in a clean way within the LineEditor instance.
2020-03-31Shell: Move LineEdit out and add it as a dependencyAnotherTest
This builds up on the 'new' LibLineEdit and overrides some of its hooks For instance, on_tab_complete_first_token
2020-03-30Shell: Shorten $HOME to '~' in shell promptsAndreas Kling
The "\w" substitution in shell prompts now uses '~' to represent the user's home directory (technically, whatever $HOME contains.)
2020-03-30Shell: Stop making shell history files world-readableAndreas Kling
\0 pointed out that it's pretty bad to have world-readable .history files, especially for root's shell!
2020-03-22Shell: More general tilde expansionShannon Booth
Now expanding a tilde isn't hardcoded to just work for `cd`. It is instead expanded while processing shell arguments. Autocompletion still doesn't work, but this is definitely an improvement over the last iteration.
2020-03-22Shell: Use starts_with() in expand_parametersShannon Booth
This reads a little nicer, and makes us care less about an empty String
2020-03-22Shell: Use size_t for SH_DEBUG vector iterationShannon Booth
We missed this when switching to size_t for vector sizing as this code is not normally compiled.
2020-03-09Shell: Validate only one directory is given to cdShannon Booth
2020-03-09Shell: Implement a "cd history" (cdh) builtinShannon Booth
`cdh` with no arguments dumps the last 8 cd calls in history, and `cdh [index]` can be used to cd to re-run a specific index from that history. `cdh` itself it a thin wrapper of the `cd` builtin. There's definitely some improvements that can be made for this command, but this seems like a good starting point for getting a feel for it and ideas for changing it in the future. It's not entirely clear whether we should be storing the resolved path - or simply just the last argument passed to cd. For now we just use the last path passed into cd as this seemed like the better option for now. This means: * invalid paths will still be stored in history (potentially useful) * cdh's can be repeated for duplicate directory names * the history looks a little nicer on the eyes It might make sense to use resolved paths. Closes #397
2020-03-07Shell: Fix silly stack overflow in 'cd' builtinAndreas Kling
Let's write in C++ and we won't have as many C problems. :^)
2020-03-07Shell: Set up the PWD environment variable earlyAndreas Kling
This ensures that PWD is set when running "sh -c something"
2020-03-03AK: Make quick_sort() a little more ergonomicAndreas Kling
Now it actually defaults to "a < b" comparison, instead of forcing you to provide a trivial less-than comparator. Also you can pass in any collection type that has .begin() and .end() and we'll sort it for you.
2020-03-02AK: Move the wildcard-matching implementation to StringUtilshowar6hill
Provide wrappers in the String and StringView classes, and add some tests.
2020-03-01Shell: Remove bogus assertionAndreas Kling
2020-03-01Shell: Handle the "delete" key correctlyAndreas Kling
We were deleting the wrong character in the line buffer, oopsie!
2020-03-01AK: Remove unnecessary casts to size_t, after Vector changesAndreas Kling
Now that Vector uses size_t, we can remove a whole bunch of redundant casts to size_t.
2020-02-25Shell: Don't pass nonsense options to waitpid()Andreas Kling
I had these options confused with the options for waitid()
2020-02-25AK: Make Vector use size_t for its size and capacityAndreas Kling
2020-02-22Shell: Make some functions constShannon Booth
2020-02-22Shell: Add basic tilde expansionShannon Booth
This does not work with shell completion yet, but the basics of being able a cd being able to expand "~" to the current user's home directory, and "~foo" to the home directory of user "foo" is added in this commit Work towards: #115
2020-02-15Shell: Use SkipParentAndBaseDir flag in DirIteratorShannon Booth
2020-02-10Shell: Build prompt based on the PROMPT environment variable if presentAndreas Kling
2020-02-06LibCore: Remove leading C from filenamesAndreas Kling
2020-02-02LibCore: Put all classes in the Core namespace and remove the leading CAndreas Kling
I've been wanting to do this for a long time. It's time we start being consistent about how this stuff works. The new convention is: - "LibFoo" is a userspace library that provides the "Foo" namespace. That's it :^) This was pretty tedious to convert and I didn't even start on LibGUI yet. But it's coming up next.
2020-01-27Shell: If a command process is stopped, print the stop signal to stderrAndreas Kling
2020-01-25Shell: Don't start a new session in every new shellAndreas Kling
The session should be started at a higher level, i.e the Terminal app.
2020-01-25Shell: Allow empty tokens if enclosed in single or double quotesAndreas Kling
Previously the shell parser would discard empty tokens. We now allow them when they are enclosed in quotes (either '' or "") This means that a command like _echo ""_ will actually pass an empty string to /bin/echo in argv[1] now.
2020-01-21Shell: Disable SH_DEBUG by default and tidy up command timing loggingAndreas Kling
2020-01-19Shell: Don't crash when stdout is not a TTYAndreas Kling
Let's just pretend we have 80 columns while running non-interactively. There are definitely nicer solutions here, and we should find them.
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2020-01-12Shell: Fix broken debug logging about waiting on childrenAndreas Kling
2020-01-11Shell: Use pledge()Andreas Kling
2019-12-25Build: support library and generator dependenciesjoshua stein
Instead of directly manipulating LDFLAGS, set LIB_DEPS in each subdirectory Makefile listing the libraries needed for building/linking such as "LIB_DEPS = Core GUI Draw IPC Core". This adds each library as an -L and -l argument in LDFLAGS, but also adds the library.a file as a link dependency on the current $(PROGRAM). This causes the given library to be (re)built before linking the current $(PROGRAM), but will also re-link any binaries depending on that library when it is modified, when running make from the root directory. Also turn generator tools like IPCCompiler into dependencies on the files they generate, so they are built on-demand when a particular directory needs them. This all allows the root Makefile to just list directories and not care about the order, as all of the dependency tracking will figure it out.
2019-12-20Build: clean up build system, use one shared Makefilejoshua stein
Allow everything to be built from the top level directory with just 'make', cleaned with 'make clean', and installed with 'make install'. Also support these in any particular subdirectory. Specifying 'make VERBOSE=1' will print each ld/g++/etc. command as it runs. Kernel and early host tools (IPCCompiler, etc.) are built as object.host.o so that they don't conflict with other things built with the cross-compiler.
2019-12-17Shell: Tab completion now gives suggestionsJesse Buhagiar
Pushing the TAB key in the shell now prints suggestions to terminal. This makes it easier to the user to actually see what files are available before executing the command they currently have typed.
2019-12-11Shell: Tab completion for pathsWilliam McPherson
If the cursor is in front of a token that is not the first token, we try to split it on the last slash. If there is a slash, the first part is the directory to search and the second part is the token to complete. If there is no slash, we search the current directory and use the entire token for completion. If we find a single match and it's a directory, we add a slash. If it's a normal file, we add a space, unless there already is one. Also renamed cut_mismatching_chars() parameters to be more appropriate.
2019-12-11Shell: Improve tab completion behaviourWilliam McPherson
A space is added if only one match is found, but we avoid adding redundant spaces. We complete "empty" tokens, i.e. when the cursor is at the start of the line or in front of a space. For example: mkdir test cd test touch test chmod +x test export PATH=/home/anon/test Now if you press tab, or space and then tab, you will get "test". Notice that you also get a space. Completion is now done relative to the cursor. You can enter two words and then go back and complete the first one.
2019-12-11Shell: Refactor append/insert procedureWilliam McPherson
This patch just factors out the procedure of adding characters at the cursor position. It makes tab completion code much nicer.
2019-12-11Shell: Improve readability of cache_path()William McPherson
I prefer String::format over StringBuilder here. Also simplified a weird continue statement.
2019-12-09AK: Use size_t for the length of stringsAndreas Kling
Using int was a mistake. This patch changes String, StringImpl, StringView and StringBuilder to use size_t instead of int for lengths. Obviously a lot of code needs to change as a result of this.
2019-12-07Shell: Use _exit() in the forked child if execvp() failsAndreas Kling
If we can't find an executable to exec() after forking, we don't want to run the atexit() handlers in the child process. Just use _exit() instead to avoid this. This was causing us to write out the shell history to ~/.history every time a "command not found" error was printed.