Bash/vi: Make file go away once I close it.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Bash/vi: Make file go away once I close it.
# 1  
Old 10-10-2013
Bash/vi: Make file go away once I close it.

Hi Everyone,

It's a little difficult to explain what exactly I am looking for.

When I open a file in vi, and then close it, I get back the prompt, but I can still see the file on top. I don't want that. I want to be able to see all the previous commands which I have typed.

For example: I opened my .bashrc file here, but when I close it, I still see it on top. Is there any way to change that behavior?

Code:
scott:~/build$
scott:~/build$ 
scott:~/build$
scott:~/build$ vi ~/.bashrc <---- Open file
..
..
..
export P4CONFIG='.p4config'
export PATH=$HOME/SayonaraDB/postgresql/src/tools/contrib/apache-ant-1.8.2/bin:$PATH #Apache-ant.
export PATH=$HOME/SayonaraDB/postgresql/install/bin:$PATH #This is where we install postgres executables.
export PATH=/home/vjobanputra/SayonaraDB/postgresql/install/bin/psql:$PATH #TEMPORARY
export PGDATA=$HOME/SayonaraDB/postgresql/installdata #data directory; This is where the database files will live.


[I]# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi
"~/.bashrc" 152L, 5211C written
<---- close the file here, but it is still visible ---->
scott:~/build$ <------------- Got back prompt
scott:~/build$
scott:~/build$


What I am looking for is something like:

Code:
scott:~/build$
scott:~/build$ 
scott:~/build$
scott:~/build$ 
scott:~/build$ cd ~/Downloads/
scott:~/Downloads$ 
scott:~/Downloads$ ls
file1 file2 file3
scott:~/Downloads$ 
scott:~/Downloads$  vi ~/.bashrc 
<----- file is closed now. I don't see it anymore ----->
scott:~/Downloads$ 
scott:~/Downloads$ 
scott:~/Downloads$

Thanks in advance =).

Moderator's Comments:
Mod Comment Please use code tags instead of quote tags for code or data

Last edited by Scrutinizer; 10-10-2013 at 03:27 PM.. Reason: code tags instead of quote tags
# 2  
Old 10-10-2013
What terminal are you using? Post the output of echo $TERM

Some *nix terminals support t_ti and t_te variables (these control the behavior you describe).

Some others like vt100 or sco do not support it, as far as I know.

You may have success by just changing the terminal to something more "full-featured" like xterm:
Code:
export TERM="xterm"

However, there's no guarantee that xterm is available on your system.

Last edited by verdepollo; 10-10-2013 at 04:32 PM.. Reason: command typo... No wonder why the command didn't work.
# 3  
Old 10-10-2013
You could add, as a workaround:
Code:
alias vi="vi $1;clear"

To either .basrc / .zshrc / .cshrc

Well ok, one can still scroll up and will see the files content, but at least the prompt is 'clean'.

hth
# 4  
Old 10-11-2013
Thanks guys!

I did:
Code:
export TERM="xterm"

And I also set the following in my ~/.vimrc:
Code:
set term=xterm

This seems to have sold the problem.

Unfortunately it doesn't work when I use 'screen'. I did try using:
Code:
screen -T xterm

And echo $TERM in screen shows 'xterm':
Code:
scott:~$ echo $TERM
xterm
scott:~$

Anyway I think I am just going to live with the problem for now when I am using 'screen' =).

Appreciate the help folks!!!
# 5  
Old 10-13-2013
The term you are looking for is "screen redraw" and as far as i know it is the default behavior of vim (much to my chagrin, because i hate that). I do not know vim that well, but i am sure you find an option to configure that if you search the help pages of it for "screen redraw [on exit]".

I hope this helps.

bakunin
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Terminal running bash/rsync script does not close with exit (MacOS High SIerra)

Hello, I am running a bash script to do an rsync back on a computer running MacOS High Sierra. This is the script I am using, #!/bin/bash # main backup location, trailing slash included backup_loc="/Volumes/Archive_Volume/00_macos_backup/" # generic backup function function backup {... (12 Replies)
Discussion started by: LMHmedchem
12 Replies

2. Shell Programming and Scripting

Bash - make csv file

Hello, im trying to make csv file from a text file that it is the output of pssh command (multiple ssh ) now if i run the command date on all of our servers: i get this output : 14:02:46 192.168.25.230:22 Thu Jul 6 14:02:46 EEST 2017 192.168.70.230: Thu Jul 6 12:02:46 BST 2017 ... (1 Reply)
Discussion started by: batchenr
1 Replies

3. Shell Programming and Scripting

Make a password protected bash script resist/refuse “bash -x” when the password is given

I want to give my long scripts to customer. The customer must not be able to read the scripts even if he has the password. The following command locks and unlocks the script but the set +x is simply ignored. The code: read -p 'Script: ' S && C=$S.crypt H='eval "$((dd if=$0 bs=1 skip=//|gpg... (7 Replies)
Discussion started by: frad
7 Replies

4. Programming

when parent process close, how to close the child?

can someone provide an example, where if the parent process quits for any reason, then the child process will also close? (3 Replies)
Discussion started by: omega666
3 Replies

5. Shell Programming and Scripting

how to make my own file as a running log file in bash

Hi, I have written a small script from that iam appending the output to a file.If multiple users invoke the same script or if i invoke the same script n number of times (using &), the output file(ZZ/OUT) contains messup information. #!/bin/bash # echo "Hello" >> /tmp/ZZ/OUT sleep 10 echo... (4 Replies)
Discussion started by: blrguest
4 Replies

6. UNIX for Dummies Questions & Answers

How do you close and launch X Window in the Bash shell?

What is the Unix command(s) to close the X Window in the Bash shell to get me into text mode. Also need the command to relaunch it from the text mode. Thanks. (1 Reply)
Discussion started by: jacatone
1 Replies

7. UNIX for Dummies Questions & Answers

Emptying a file (bring the size of the file down to 0 , or close to 0)

Hi I tried to empty an existing file (bring the size of the file down to 0). When I used “> myFile” or “cat </dev/null >myFile”, when I do a “ls –la”, the file size shows as 0. I then wrote 540 lines to the file, and then opened it using vi, I see something like this: "myFile" 540 lines,... (3 Replies)
Discussion started by: qmqmqm
3 Replies

8. Windows & DOS: Issues & Discussions

Can DOS close an open file?

I'm trying to setup a cron job for my brother that goes out to the web and retrieves an excel file and overwrites the existing copy on his desktop. The problem I'm facing is I have to kill the process (excel.exe) if the file is open while the batch file runs, otherwise, it will create another copy... (2 Replies)
Discussion started by: quattro20v
2 Replies

9. Shell Programming and Scripting

how to make your bash script run on a machine with csh and bash

hi, i have a script that runs on bash and would like to run it on a machine that has csh and bash. the default setting on that machine is csh. i dont want to change my code to run it with a csh shell. is there any way i can run the script (written in bash) on this machine? in other words is there... (3 Replies)
Discussion started by: npatwardhan
3 Replies

10. UNIX for Dummies Questions & Answers

File status - open/close ??

Is there any commands in UNIX, like isopen(),isclose() to know whether a file has been opened for read/write purpose.? Thanks (3 Replies)
Discussion started by: Pal
3 Replies
Login or Register to Ask a Question