so I set up my terminal banner with figlet and I really like it. But it will only be displayed after opening a new terminal. My question is: Can I somehow display a banner after I hit "clear"?
You'll have to edit your .bashrc file and add the following line:
alias clear='clear && (the figlet command you use)'
Then it will start up every time you type clear.
Related
I have a hw problem where I need to make the date appear at the start up screen of the terminal in bash shell. I was able to save date script using nano, but am now stumped on how to get it to show up when launching terminal. Any help is appreciated.
You can create a desktop shortcut launcher that will start your script in a terminal.
$ gedit ~/Desktop/dateterminal.desktop
Copy the following (change the exec line to your script)
[Desktop Entry]
Version=1.0
Type=Application
Terminal=true
Exec=/path/to/your/date/script
Name=whatever you want
Icon=
After creating right click on the launcher > Properties > Permissions > & check the Execute: box
Here you go:
I am not really sure if you want a motd in CLI or if you want a message for everytime you opening a new tab or logging in or if it's before you logging in(MOTD) but since you have a script I guess it's in a terminal window everytime you opening a new tab:
mkdir -p ~/.scripts
# Put your script in ~/.scripts
echo ". ~/scripts/yourscript.sh" >> ~/.bashrc
source ~/.bashrc
I use perforce as source code repository. p4 change command is used to create a changelist of opened files. If I set setenv EDITOR gvim and then run this command then gvim opens and I add some description and then save and quit. I get below error. Same error does not come if EDITOR is not set, I mean in that case vim opens. Any idea to fix this issue?
sachina#inn-sachina-vm[285] p4 change
Error in change specification.
Error detected at line 29.
Change description missing. You must enter one.
Hit return to continue...
Applications that invoke EDITOR assume that the command blocks until editing is done and the editor was closed. While true for vim, the GUI version gvim launches in the background; i.e. the command returns immediately.
You can avoid this via the :help -f command-line option:
setenv EDITOR 'gvim -f'
Issue: Create a script that opens a terminal window with multiple tabs, each tab requires a different title to identify its purpose, in addition each tab should display a specific commmand (will not execute the command, the user will need to hit Enter to execute the command).
Example: The user needs to execute 3 commands: ifconfig, route -n and top, the user executes the script and it opens the terminal with 3 tabs, the first tab shows in the title Network and the prompt shows root$ ifconfig, the second tab shows in the title Routing and the prompt is like root$ route -n, the third tab shows the title Performance and the prompt shows root$ top. The commands are not running when the script is executed, the user needs to go into each tab and manually hit "Enter" to execute each command.
I am using the following script to open the terminal with multiple tabs, but am stuck trying to get the other features working, any assistance will be highly appreciated:
#bin/bash
tab="--tab"
cmd="bash -c 'pwd';bash"
foo=""
for i in 1 2 3; do
foo+=($tab -e "$cmd")
done
gnome-terminal "${foo[#]}"
exit 0
You can save the state of your terminal using:
gnome-terminal --save-config=FILE
And call the load with:
gnome-terminal --load-config=FILE
Where FILE is the filename you would like to save.
So you can open 3 tabs and give them names etc, then save the config and in your script you can load it.
On the saved file you can edit properties like:
WorkingDirectory=
Title=
As for displaying a command and not running it, I don't have a solution.
You can check this:
http://www.techrepublic.com/blog/linux-and-open-source/how-to-make-your-own-gnome-terminals/
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.
I have a redhat machine which I use remotely using putty and this is what have been bugging me a lot now...
Each time I open and close a file with any editor, my prompt shows up on the bottom line without the content of the screen being refreshed. This is really problematic because then I can't see previous outputs that were on the screen just before I opened that file which is still showing up after closing.
Is there a way to fix this. I want it to behave like the gnome-terminal. I don't think this use to happen when I was using an ubuntu server.
I understand that this is the traditional tty behavior, but I don't want it...
Thanks in advance.
If your terminal supports an alternate screen buffer, it should have rmcup and smcup define in its terminfo entry
% infocmp | grep -e rmcup -e smcup
ri=\EM, rmacs=^O, rmcup=\E[2J\E[?47l\E8, rmir=\E[4l,
smcup=\E7\E[?47h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m,
If enabling altscreen in your .screenrc doesn't fix it, try adding these 2 lines to your .vimrc:
set t_ti=^[[?47h
set t_te=^[[?47l
(note that ^[ is escape, I typed ctrl-v esc)
Vim will echo ti to the terminal on startup and te on exit, instructing the shell/xterm/screen to switch screen buffers.