My command line isn't behaving as expected. When I write something that is longer than the window width, the cursor goes back to the beginning of the same line and continues to write on top of the same line instead of automatically moving to the next line. For example, if I write "this is a line to illu" on the command line of my terminal the following is what I see:
Last login: Thu Jun 19 18:32:24 on
e to illu > ~] $ this is a lin
Note how the end of the text was being shown at the beginning of the same line. If the terminal window is wide enough I see this:
Last login: Thu Jun 19 18:32:24 on
[MacBook > ~] $ this is a line to illu
I'd like it to behave like this:
Last login: Thu Jun 19 18:32:24 on
[MacBook > ~] $ this is a line to illustrate
the problem
How can I solve this?
Thanks.
Unusual but I found the solution. #Barmar, you're right. I customised the colours of my terminal by configuring my PS1. It turned out that I was missing a backslash inside my PS1 quote preceding the color set. My PS1 was:
PS1="\e[0;30m[\h > \W] \$ \e[m "
resulting in the command lines not wrapping to the next line. I changed to:
PS1="\\[\e[0;30m[\h > \W] \$ \e[m "
Problem solved!
Related
sed -i '/#if UTS_UBUNTU_RELEASE_ABI > 255/c\/*#if UTS_UBUNTU_RELEASE_ABI > 255' /usr/src/ixgbevf-2.16.4/src/kcompat.h
I am trying to understand the above command but couldn't figure out what c\ is doing here?
This sed command says to test lines for the regular expression #if UTS_UBUNTU_RELEASE_ABI > 255 (because it starts with forward slash), if so, use the change command to replace the whole line with whatever follows. (the -i means in place.)
In this case, it will change the matching line to be the beginning of a block comment (inserts /*) per my local testing.
i run this command :echom system("date")<CR> in vim.
my expected output is something like this: Sat Jan 10 12:28:58 CET 2015
but it always appends an annoying ^#
so that the output is like this: Sat Jan 10 12:28:58 CET 2015^#
why?
and how can i easily avoid this?
when i run date in terminal it gives me the expected output. plus a newline of course (*1). so my guess is, that the ^# comes from the newline, right?
i run vim 7.3 on debian (the version from the official repositories) in the terminal version, (not the gui version!) in a gnome-terminal with utf-8 encoding.
(*1): the prompt looks like this
user#host$ date
Sam Jän 10 12:28:58 CET 2015
user#host$
not like this:
user#host$ date
Sam Jän 10 12:28:58 CET 2015user#host$
The ^# does come from the fact that date ends with a newline (\n).
You can either :
remove the trailing characters (this will only output the expected result if the command ends with a newline) :
:echom system("date")[:-2]
substitute the trailing \n (a bit more verbose) :
:echom substitute(system("date"), '\n$', '', '')
I used ksh a lot but now moving to csh as this company has all scripts etc written in that.
One thing I loved about ksh was the ease of using the command history.
In case I have to edit the last command or second last command, I could easily press "Escape - k" to cycle through the commands and easily edit them.
csh does not seem to have a good equivalent. It displays all the history of commands then I have to copy paste one of them and then edit.
That's a pain when you want just change the number of in the file name for example :
cat abcdef1 | grep "Linking"
You could use (as a workaround):
"The most commonly used feature of csh command history is "!!" (pronounced "bang bang") which recalls the previous command":
% date
Mon Nov 25 13:52:36 PST 1996
% !!
date
Mon Nov 25 13:52:52 PST 1996
Here some other useful commands.
But you could just work in ksh and make script and whatever in csh.
If it is istalled simply launch:
/bin/ksh
I couldn't find an answer for this exact problem, so I'll ask it.
I'm working in Cygwin and want to reference previous commands using !n notation, e.g., if command 5 was which ls, then !5 runs the same command.
The problem is when trying to do substitution, so running:
!5:s/which \([a-z]\)/\1/
should just run ls, or whatever the argument was for which for command number 5.
I've tried several ways of doing this kind of substitution and get the same error:
bash: :s/which \([a-z]*\)/\1/: substitution failed
As far as I can tell the s/old/new/ history substitution syntax only does simple string substitution; it does not support full regexes. Here's what man bash has to say:
s/old/new/
Substitute new for the first occurrence of old in the event line. Any delimiter can be used in place of /. The final delimiter is optional if it is the last character of the event line. The delimiter may be quoted in old and new with a single backslash. If & appears in new, it is replaced by old. A single backslash will quote the &. If old is null, it is set to the last old substituted, or, if no previous history substitutions took place, the last string in a !?string[?] search.
Never fear, though. There are in fact easier ways to accomplish what you are trying to do:
!$ evaluates to the last argument of the previous command:
# ls /etc/passwd
/etc/passwd
# vim !$
vim /etc/passwd
!5:$ evaluates to the last argument of command #5:
# history
...
5: which ls
...
# !5:$
ls
You can also use Alt+. to perform an immediate substitution equivalent to !$. Alt+. is one of the best bash tricks I know.
This worked for me using Bash in Cygwin (note that my which ls command was number 501 in my history list; not 5 like yours):
$(!501 | sed 's/which \([a-z]\)/\1/')
You could also do it this way (which is shorter/cleaner):
$(!501 | sed 's/which //')
rpm automatically place a new installed kernel as the first option. However, I want to move it as the last one - to end of the file.
Grub configuration file looks like this:
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Fedora (2.6.29.6-217.2.7.fc11.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.29.6-217.2.7.fc11.x86_64 ro root=/dev/mapper/main-root rhgb quiet
initrd /initrd-2.6.29.6-217.2.7.fc11.x86_64.img
title Fedora (2.6.29.6-217.2.3.fc11.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.29.6-217.2.3.fc11.x86_64 ro root=/dev/mapper/main-root rhgb quiet
initrd /initrd-2.6.29.6-217.2.3.fc11.x86_64.img
title Fedora (2.6.29.6-213.fc11.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.29.6-213.fc11.x86_64 ro root=/dev/mapper/main-root rhgb quiet
initrd /initrd-2.6.29.6-213.fc11.x86_64.img
My goal is to move first option (217.2.3) to end. Now I figure out how to delete it:
sed -e '/(2.6.29.6-217.2.7.fc11.x86_64)/,+3d' /boot/grub/menu.lst
p command only prints current line (not as in vim, where it means paste).
Do you have any ideas how to automatically move this part of file to its end?
I have to answer myself. :-)
sed '/\(2.6.18-157.el5\)/,+4 { H; d; }; $ { p; x; }' /boot/grub/menu.lst
If you are not fluent with sed (me neither), there is more verbose version
sed '
/\(2.6.18-157.el5\)/,+3 { #Find line which contains version of our kernel in parentheses and took also 3 following lines
H # Append this line into buffer
d # Delete line
}
$ { # On the last line
p # Print current line
x # Change current line with buffer and vice versa
# Afterwards sed print current line => in our case deleted line
}' /boot/grub/menu.lst
A very similar task was covered extensively here
Yes, there is some satisfaction in a well crafted sed command, but I think I would tend to use an editor, so I could see the lines I was going to move around, and not have to worry about getting the line numbers wrong in a command.