I am not sure if this is possible but I couldn't find the answer anywhere else or even people who have tried it but my current PS1 is this:
export PS1="\[\e[00;32m\]??\[\e[0m\]\[\e[00;37m\]\n\[\e[0m\]\[\e[01;31m\]\d\[\e[0m\]\[\e[00;37m\] \[\e[0m \]\[\e[01;31m\]\T\[\e[0m\]\[\e[00;37m\]\n\[\e[0m\]\[\e[00;32m\]>\[\e[0m\]"
It is showing up and working upon opening the terminal however I am wondering if it was possible to clear the screen after a command finishes (with a prompt similar to windows cmd 'pause' command if possible) so that it isn't repeated or shown at the bottom of the window
I am running Manjaro XFCE if it makes a difference.
Thanks!
You can try something like this:
PS1='$(echo "(press enter to continue)" > /dev/tty ; read ; clear) $ '
NOTE: You need the redirect > /dev/tty because the standard output of the commands run by PS1 goes nowhere.
Replace the ending $ with whatever prompt you want to show.
I don't really think it is such a good idea. In the short time I've been testing that, it is so irritating!!!
I think you are way better just pressing Ctrl+L befor typing your command to clear the terminal.
Related
I'm wondering if there is a way set a linux or mac terminal so that you are always entering commands at the top of the terminal screen, and previous commands are below it.
Example
-----Screen top----
>EnterCommand
>PreviousCommand 1
>final line of Previous Command 1 output
>second to final line of previous command 1 output
-----Bottom of screen-----
Thanks!
Such a feature is not built into the standard *nix terminal driver; a terminal application would have to be specifically written to translate newlines and line wrapping into upward motion instead of downward. Note that this will likely break a number of TUI applications, so it is not recommended to use them with such a terminal application.
This seems pretty close to what you're asking for:
https://github.com/swirepe/alwaysontop
To use it run:
git clone https://github.com/swirepe/alwaysontop.git
cd alwaysontop/
source alwaysontop.sh
If you decide you like it just source it in your .bashrc or .bash_profile with something like:
echo "source ~/alwaysontop/alwaysontop.sh" >> ~/.bashrc
Hope that helps!
I use the command xdg-open quite a lot in my Ubuntu Linux terminal. However, two things irk me:
Is it possible to suppress the error messages?
Is it possible to get the command to always complete? (That is, not continue running, so that I have another "new line" in my terminal).
I realize 2 may not be possible, because of the way the program works, but I imagine 1 is.
First one is easy. Just
alias xdg-open="xdg-open 2>/dev/null"
If you want it permanently, just add that line to ~/.bashrc file.
I recommend you to think twice if you want to become blind to errors, though.
The second one is quite confusing to me. xdg-open shouldn't be intereactive. In my computer (Debian sid) xdg-open execs the command and ends, even if the command itself has not ended (ie: you have not closed the application opened for the URL). I think this should be the behaviour of xdg-open on any platform (it's supposed to work exactly the same way on any XDG system, that's its very purpose).
Anyway, for any command you launch in a shell, if you want it to be non-interactive, that is, to allow to enter commands even if the previous one hasn't finished, you just attach "&" to the end of it. Example:
# prompt is not shown until you close the calculator
$ gnome-calculator
# prompt is shown right after opening calculator and you can
# work on the shell even if you don't close it
$ gnome-calculator &
I maybe late for the answer, but I got exactly the same problem like you have / had.
I tried to start a URL with xdg-open, my default browser is firefox, and not xdg-open but firefox started with an error:
[user#user-pc ~]$ xdg-open https://www.google.de # the page opens fine, but firefox had an error
[user#user-pc ~]$
(process:3783): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
# needed to press enter here
xdg-open closed fine but the firefox error stayed and I need to press enter to get the bash moving.
To get along this problem I called xdg-open within a new shell putting those output to /dev/null:
bash -c "xdg-open https://www.google.de" 2> /dev/null
The page opened fine, no error shown – rather nothing has been shown. And no need to press enter.
I need an example of gnome-terminal command to read lines of text from a file and executes them one by one in different terminal or a tab.
So this would be the process. I would run gnome terminal command and it would read 10 commands from a file. Then it would execute those 10 commands in 10 different tabs/terminals. And of course those tabs/terminals would remain opened. I found this question Avoid gnome-terminal close after script execution?
The third answer from the top is very helpful. I managed to open 1 command from a file. But I need 1 file with 10 command lines to be opened like I wrote above.
Thanks.
I recommend to use screen for this, if that can be acceptable to you.
You could create a commands.screenrc file like this:
screen bash -c 'command1; echo press any key; read'
screen bash -c 'command2; bash'
screen mutt
screen emacs
screen
You can define as many programs as you want. Start screen with:
screen -c commands.screenrc
I don't know what kind of commands you want to run. If you want to see their output, then write like the first example above: execute the command in a bash shell, which will "pause" after the command was executed. Or the second line, which, after running the command will start another bash shell. Otherwise the screen window would exit automatically.
If you are not familiar with screen, you will need to learn some basic key strokes to get around, and to be able to switch between windows. The first few pages of this presentation should be enough to get you started.
I'll be glad if someone can fix the title to be more appropriate since I'm pretty new to terminal.
I have an issue with terminal. Once I execute a command, if it goes to the next line, I can't close it or revert it. I assume it starts the executable or asks for more parameters using >
For example:
//Windows Machine
vagrant up
//Vagrant Instance Unix Machine
$ git
>
>
>
> ... it goes on like this, I can't close > so I can't execute other commands
The only solution on fixing is restarting the terminal (which means I need to restart Vagrant instance)
It happens on some commands only - not all, so I don't know what makes a difference.
For example, executing composer, I get information about Composer and terminal goes back to main state. However, if I execute things like php, git, mysql, > symbol appears and I can't return from there.
So, two basic questions;
What causes this?
How can I terminate the current command to go back main state?
Any help would be greatly appreciated.
Ps. I use both windows terminal and unix terminal and this issue happens on both.
Normally you'll see a > prompt if you've entered a command that's syntactically incomplete, for example if there's a unterminated string literal:
$ echo 'hello
> '
hello
$
It means that the shell is waiting for you to type the rest of the command, or at least enough of it to make for something that's not a syntax error.
In this example, the default prompt, $PS1, is '$ ', and the secondary prompt, $PS2, is '> '. Read the documentation for your shell (probably bash) for more information.
You can cancel the current command and get back to your primary prompt for a new command by typing Control-C.
This is all about the behavior of your shell; it has nothing to do with your terminal (almost certainly a terminal emulator), which merely provides a GUI for your shell to run in.
I'm having some problems working with my development environment. Specifically, after I invoke the screen utility from within Cygwin I lose the ability to do tab completion. Before I invoke screen however tab completion works just fine.
I messed around with setting different values for the TERM env variable (VT100, xterm etc) but without success. It must be something trivial but I have no idea anymore. Does StackOverflow have any suggestions for me?
when you issue 'screen' from inside cygwin it might put you in another shell like /bin/sh instead of /bin/bash (and bash is where you're getting the tab completion from).
To fix the problem you could edit your .screenrc file (found in your home directory) and add in this line:
shell bash
Then try running screen again and you should see tab completion work within this new window.
The problem is that bash needs to be run as a login shell in order to have tab completion in the default cygwin setup. If you run bash in a cygwin bash you won’t have tab completion either. To set screen to run bash in login mode, add this line to your ~/.screenrc file:
shell -bash
I had a similar problem with git autocompletion not working when using screen on a linux machine, but wasn't due to a different shell. I fixed it using this question: Git autocomplete in screen on mac os and doing the following:
Get the git autocompletion script
curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -OL
why would you want that hanging around?
mv git-completion.bash .git-completion.bash
add this line to your ./bashrc
source ~/.git-completion.bash
Then in your terminal
source ~/.bashrc
That worked for me.
(I imagine after three years you've probably solved your problem, but I hope this helps someone else)