Problem with setting vi as my default editor in ksh


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Problem with setting vi as my default editor in ksh
# 1  
Old 05-03-2012
Problem with setting vi as my default editor in ksh

Hi ,

Below is the content of my .profile

Code:
 
$cat .profile
# Workstation users:  Make changes to your .profile file in your home dir.
. /.profile
set -o vi
PS1=$

But anytime I login I have to source "set -o vi" separately.Please suggest
# 2  
Old 05-03-2012
It may be aborting because the syntax for the sourced profile is pointing to a file that doesn't exist. This line
Code:
. /.profile

is looking in the root folder. It probably needs to be
Code:
. ~/.profile

# 3  
Old 05-03-2012
This would lead to an endless loop. Possibly there is a system-wide profile /.profile. You might try this:
Code:
[[ -r /.profile ]] && . /.profile
set -o vi 
PS1=$

# 4  
Old 05-03-2012
Hi Thomas/hfreyer,

Thanks for your response.

The file .profile in my home directory is getting sourced properly .

As I login I think the /.profile of root gets sourced gets sourced first

Code:
. /.profile

and then whatever i have mentioned below

Code:
 
set -o vi 
PS1=$

My Prompt which should be the Directory path by default is changed to $ after I login. If I remove "PS1=$" from my .profile it changes to <Directory name>

By someway its not setting the vi editor . Correct me if I am wrong.
# 5  
Old 05-03-2012
This is the correct way to set vi in a .profile:
Code:
# Set up the shell variables you use here:
        EDITOR=vi
        export EDITOR

now
Code:
export EDITOR=vi

is acceptable
# 6  
Old 05-03-2012
Hi Vbe,

Thanks for the reply,But still no luck.

Code:
 
$cat .profile
# Workstation users:  Make changes to your .profile file in your home dir.
. /.profile
EDITOR=vi
export EDITOR
PS1=$
alias dir='cd /ford/mksc01/site_cons/sc_work/RRAMESHS/'

I validate as follows. After login I do a Esc[k] in my command line to get my previous commands . I am still not getting them.

In the command line I do a

Code:
 
set -o vi

and the do a Esc[k] I can get my previous commands one by one.

Thanks
Ramesh
# 7  
Old 05-03-2012
Code:
 set -o vi

is what you would type in interactive mode to set vi ...
Since you are using ksh, you could modify your .profile so you can use a .kshrc file:
Code:
# Set up the shell variables you use here:
        EDITOR=vi
        export EDITOR

        ENV=$HOME/.kshrc
        export ENV

Now in .kshrc you could put all your ksh stuff...
but I will show you how to define vi first:
Code:
set -o vi   # Does that remind you of something?
# but what follows is the standard way to do things:
FCEDIT=/usr/bin/vi
export FCEDIT
HISTFILE=$HOME/.sh_history
export HISTFILE
HISTORY=2048
export HISTORY

now why want to use a .kshrc?
You can enter all your aliases in this file e.g.
Code:
alias rm="rm -i"
alias dir="ll | grep drwx"
alias bell='echo "\007\007\007\007\007\007\007\c"'
alias exe='chmod +x '
alias prot='chmod -w '
alias unpro='chmod +w '

Dont forget to change perms on your file to only you can read-write-execute, nothing fot the others...

What OS are you using?
This User Gave Thanks to vbe For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh script to edit a file using vi editor

I was wondering if it is possible to execute a script that will remove a certain search pattern from a file and save it? Manually I would just hit escape to enter command mode then search and delete the pattern "./srv 135.0.0.1.11111 210;=1" then save & exit the file vi command to search and... (3 Replies)
Discussion started by: seekryts15
3 Replies

2. UNIX Desktop Questions & Answers

GNOME Desktop - Setting missing from dconf-editor?

Hello All, Last night I installed OpenSuSE 12.1 (i586) on a HP Mini 110 laptop. And I selected GNOME as my Desktop during install... So I was trying to customize some things about the desktop, for example adding the Maximize/Minimize/Close options to the titlebar of a window. I did this... (2 Replies)
Discussion started by: mrm5102
2 Replies

3. Shell Programming and Scripting

Setting up env variable in ksh

I am facing a very strange issue. I have script in ksh with #!/bin/ksh as shebang. This script has function which sets the env variable before running other functions of the script. by set_up_env() { CONFIG_FILE="/opt/app/tools/deepmarking/latestVersion/script/UploadEnv" if then ... (7 Replies)
Discussion started by: Tuxidow
7 Replies

4. Shell Programming and Scripting

Setting Varible with AWK in KSH

I am trying to set a variable from this AWK command in KSH but I keep getting an error that says my variable cannot be found. LOADNO = $(awk -F"|" 'NR==1{print $2}' file.txt) If I just run awk -F"|" 'NR==1{print $2}' file.txt I get the right value but as soon as I try to assign this... (1 Reply)
Discussion started by: cvigeant
1 Replies

5. Shell Programming and Scripting

Setting a variable in a while loop (.ksh script)

Hello Everyone, I'm still trying to grasp many concepts in .ksh scripting, one of them being variables inside loops. My problem is the following: * I'm trying to set a variable inside a while read loop to reuse it outside of said loop. My lines are the following :... (13 Replies)
Discussion started by: jimmy75_13
13 Replies

6. Shell Programming and Scripting

Setting Variable in TCL to be understood by KSH Shell

Hi , I am having one TCL TK script , I am setting some variables in the GUI TK interface set DI 1 set MODELS_PATH /a/d/path but I want to make ksh shell understand the variables when I am running TK script I tried to do like this set a but it is not working ... (1 Reply)
Discussion started by: kshitij
1 Replies

7. Shell Programming and Scripting

setting ksh environmental variable

Hi, I have problem setting up environmental variables. The idea is to start with main.ksh script that will run setting.ksh, and in side of it I'll set up variables. Please take a look at my code, and help me to find my mistake. Thanks, Mila Main.ksh look like this: #!/usr/bin/ksh #... (2 Replies)
Discussion started by: mefquik
2 Replies

8. Shell Programming and Scripting

set EDITOR=vi -> default editor not setting for cron tab

Hi All, I am running a script , working very fine on cmd prompt. The problem is that when I open do crontab -e even after setting editor to vi by set EDITOR=vi it does not open a vi editor , rather it do as below..... ///////////////////////////////////////////////////// $ set... (6 Replies)
Discussion started by: aarora_98
6 Replies

9. Shell Programming and Scripting

KSH Setting multiples variables with an array

ih all, info=$(get_Info $daemon) # $info give : # "ev20 8800 TTIOGC 12345 astos EDITEUR 0 0 . ." server=$(echo $info | cut -d" " -f1) port=$(echo $info | cut -d" " -f2) dname=$(echo $info | cut -d" " -f3) dport=$(echo... (1 Reply)
Discussion started by: wolfhurt
1 Replies

10. UNIX for Advanced & Expert Users

Urgent help needed for ksh shell setting

Today I logged as root on my HP-UX server and by mistake executed below command # ksh -i vi Then onwards for every root logging the ksh shell giving wired output to every command e.g # ls kÚ .brw_history .brwpause .brwtmp : : : 1+~H4p+À+~KÑ 1+Ðè d 15kÚ 1d+~èYÑd:ðè½h|À+~èY4:àh|À+ And so... (6 Replies)
Discussion started by: zing_foru
6 Replies
Login or Register to Ask a Question