How to make xterm command line works like vim [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I'm working on RHEL environment, and using xterm.
My question is that how to make the xterm command line works like vim instead of emacs (eg, selection, copy, paste, keyboard shortcuts)
Thanks!

The bash command to turn on vim-style editing is
set -o vi

As it was already mentioned, this has nothing to do with the terminal(emulator) you're using. In case you use zsh, you can enable vi-like bindings with:
bindkey -v

The Emacs-style keybindings to which you are referring are actually a feature of the Readline utility.
While adding, set -o vi to the end of your ~/.bash_profile should suffice (if you're a bash user), this utility can also be controlled through the use of an ~/.inputrc file.
Create an ~/.inputrc if it doesn't already exist and append this:
set editing-mode vi
set keymap vi-command
The benefit of this approach over set -o vi is that this is read wherever readline is used include the MySQL command line interface and Ruby's IRB.
See this post for more Vim-related readline tips:
http://vim.wikia.com/wiki/Use_vi_shortcuts_in_terminal

Related

how can I set my new new terminal to retain session of previous terminals? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
In linux, (on my mac, i can do this in the settings in iterm2) how can I set up my terminal emulator so that my session is maintained for each new terminal I open?
eg: if I am in ~/code/ folder in my terminal, the I open a new terminal, i should be in the ~/code/ folder in the new terminal too, not ~/
my usecase is that I don't lose context when working with i3
is there a setting or a recommended emulator that can do this, is it possible to complete this implementation programmatically?
I'm not sure why you want to do this, as you can simply reach a "frequently" cded directory by searching in the history of commands.
However, if you really want to do it, one (dirty?) trick would be adding this in your .bashrc:
# this is in ~/.bashrc
exit() {
sed -i '${
/^cd /{c\cd '"$PWD
"'q};a\cd '"$PWD
}" $HOME/.bashrc
command exit
}
What it does is (implicitly) printing all lines up to and including the second to last line, then on the last line ($) it checks if the last line starts with cd followed by space; if it does, it changes it to cd $PWD and quits; if it doesn't, the cd $PWD line is _aappended.

Load some alias just after SSH login [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
In my daily work I often need to use a ssh connection on a device (which you can consider as read only), and the commands I write are long.
That's why I would like to load some alias just after ssh login.
But when I try something as follow, it don't works:
ssh name#ipAdress "bash -l ; alias short='veryLongCommandThatIWriteOften'"
I guess that's because bash stop the processing of the other commands which are just after.
So is it possible to set aliases directly as an argument of bash, or is there another solution to do what I want?
Instead of an alias, you can use a shell function, which bash allows you to export. This way, you first define the function, then export its name, and finally start a new interactive shell which inherits your function. For example:
ssh -t name#ipAddress "short () { veryLongCommandThatIWriteOften; }; export -f short; bash"
The -t is necessary to set up the pseudo terminal for the interactive bash shell, as ssh won't do it automatically for an apparently non-interactive command.
Note that you many need to be careful about quoting, depending on what the body of short is.
Edit the file ~/.bashrc
nano ~/.bashrc
It has examples of how to set aliases also. Log back in to have new alias work.

Setting clipboard options from the vim console [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I'm trying to use vim on a remote Ubuntu server and I'm noticing that the start up for vim is too slow unless I use the -X flag or have set clipboard=exclude:.* in my .vimrc.
When I use either options, vim starts up fast but the problem is I can't copy from vim to the system clipboard. I've tried numerous times to do :set clipboard=unnamed and the like from the console but it won't register anything because it seems to only connect to the x server if that line is in .vimrc.
How can I start vim with the -X option but start the x server afterwards (only if I need to copy stuff)? Or how can I change clipboard settings from within the console?
If you have to start Vim with -X, I don't think there's a way to later enable clipboard support. You either have to find and fix the root cause for the slowness of connecting to X, or work around this with external tools, e.g.
:3,5w !xsel --clipboard
or
:3,5w !xclip -in -selection clipboard

Unix command for picking out run commands [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am relatively new to linux environment. My doubt is this:
I run a lot of commands of various types , so when ever i want to rerun a old one i have to look through the entire history. is there any bash command that displays just the commands that begin with a particular combination of characters( my case here is i just want a list of all the ./ eg: ./ifv_script , ./run_regression i've run from the terminal)
Three methods:
You can grep your current history, e.g.:
$ history | grep ifv
You can also recall commands from the history by typing ControlR and then type a few characters from the command.
Finally you can grep your saved history file for older invocations from previous sessions, e.g.:
$ grep ifv ~/.bash_history
Just press Ctrl+R, and you will enter into reverse-i-search mode.
Now you can type a few characters that appear anywhere in the command and bash will start finding matches.
Final approach (bash only):
history | grep term

Two questions about bash commands / Linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I need answers for those questions:
How and where can I change default app in user profile in Linux?
How can I save changes in vi editor without exiting? I guess it's w q q! but I'm not sure.
How and where can I change default app in user profile in Linux?
I guess you refer to the editor. If so, use the following:
export EDITOR=vi #or whatever other editor
To make it permanent, add this line to the .bashrc file in the home of the user, that is in ~/.bashrc.
How can I save changes in vi editor without exiting? I guess it's w q q! but I'm not sure.
use :w to save. You have to be in the command mode (go there pushing Esc).

Resources