I am on Ubuntu 18.04.1 LTS
As I use very often "clear" in my zsh terminal, I wanted to delete it from my .zshrc_history file.
I found this command line : sed -i '/string/d' .bash_history here ZSH / BASH : Delete specific lines from history.
I know there is no up vote for it, but I did it with my own configuration :
sed -i '/clear/d' .zsh_history (clear as the word I wanted to delete)
But now when I type history in my zsh shell, I have only a few lines shown. I think the lines before hitting the first clear and not all my history.
As I write in the zsh, it now keeps only theses few lines and not incrementing the lines (so the first history line is hidden to show the new one and I always have only 16 lines in my history).
When I open my .zshrc_history file, I have all my history shown as this :
1 : 1543529720:0;sudo apt-get install zsh-syntax-highlighting
... etc.
1556 : 1549402753:0;ls
1557 : 1549403085:0;code .zsh_history
1558 : 1549403818:0;source .zshrc
1559 : 1549405008:0;npm -v
Is there a way to undo this command and have all my history back shown in my shell ?
Thanks for your help.
If you speaks french it is even better for my understanding
UPDATE
Hi #jhnc that's right my .zshrc_history has everything from line 1.
I already backup this .zshrc_history file, thanks to mention it.
So I did echo $HISTSIZE $SAVEHIST $HISTFILE and here is the result :
50000 10000 /home/echayotte/.zsh_history
I started with bash before using zsh this is why I put them both :
in .zshrc_history
Line 1 shows :
: 1543529608:0;sudo apt-get install powerline fonts-powerline
in .bash_history
Line 1 shows :
sudo add-apt-repository ppa:danielrichter2007/grub-customizer
In my folder I have this icons and before that they were the same as the bash history
icons of .zsh/bash_history
UPDATE
So I create a new .zsh_history file but the problem is unsolved.
I don't know what to do ...
Do I need to reinstall zsh; This will fix my problem ?
Related
I just have to install a software cvxopt for a project and the instructions tell me to do this:
Remove all instances of ‘-mno-cygwin’ from c:\Python27\Lib\distutils\cygwinccompiler.py using the command:
sed 's/-mno-cygwin//g' -i'.bak' c:\Python27\Lib\distutils\cygwinccompiler.py
Every time I try to run the command , it says unknown command ' ' '.
I don't know what sed is , I just want to install cvxopt. I have been struggling with it for the last 2 hours. Please Help!
Two things:
Firstly, the -i option doesn't work on all sed versions for Windows. It allows in-place editing. If yours doesn't, create an intermediate file like this and then overwrite your original if/when you are happy with it.
cd \Python27\Lib\distutils
sed "s/-mno-cygwin//g" cygwinccompiler.py > x.tmp
del cygwinccompiler.py
ren x.tmp cygwinccompiler.py
Secondly, Windows doesn't understand single quotes, so use double quotes like this:
cd \Python27\Lib\distutils
sed "s/-mno-cygwin//g" -i".bak" cygwinccompiler.py
Whenever i push through git all my bash scripts seem to be corrupted with the \r character. It doesn't affect the code, but it just adds a significant amount of noise to my work. Looked all over the web, but can't seem to find a solution.
Example:
echo "*************************************************************************"\r
^
Every line in my bash scripts are always ended with this special character. I use STS on Windows 7. Any ideas?
Put this two lines into your .gitconfig file in the root of your repo or into your home if you need to make this settings global :
[core]
eol = lf
You can find more about this here : https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
SOLVED: I had the wrong line endings selected in my text editor
I tried to get a .bashrc going on my iPhone, just for fun. After adding source /var/root/.bashrc to my /etc/profile file I get this every time I log into a terminal emulator, local or over SSH.
: command not found
: command not found
: command not found
: command not found
: command not found
: command not found
: command not found
>
My cursor overwrites the '>' everytime I type
The contents of /var/root/.bashrc
alias install='apt-get install'
alias remove='apt-get remove'
alias aptsearch='apt-cache search'
alias respring='killall SpringBoard'
alias safemode='touch /var/mobile/Library/Preferences/com.saurik.mobilesubstrate.dat && killall SpringBoard'
alias shutdown='halt'
alias poweroff='halt'
alias ls='ls -group-directories-first -Ah'
alias lsl='ls -Ah1 --group-directories-first'
alias killall='killall -v'
alias reload='source /var/root/.bashrc'
export PS1='\w> '
clear
The contents of /etc/profile
export PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games'
export PS1='\h:\w \u\$ '
umask 022
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done
source /var/root/.bashrc
Any and all help is appreciated.
SOLVED: I had the wrong line endings selected in my text editor
Try manually executing the script and taking a look at the output. You should get a line number to help you along.
In iTerm2 we can set the xterm-256color option by going to Preferences -> Profiles -> Terminal -> Terminal Emulation -> Report Terminal Type and chosing xterm-256color
I want to add to my dotfile's installation script so I don't have to change it manually.
Is there a way of setting this option via command line? Maybe via iTerm itself or maybe via apple's defaults write.....
Thank you!
default works only if the setting is a top level key, for example
[admin#mb-125:~] : defaults read com.googlecode.iterm2 | grep -i promptonquit
PromptOnQuit = 1;
[admin#mb-125:~] : defaults write com.googlecode.iterm2 PromptOnQuit -bool FALSE
[admin#mb-125:~] : defaults read com.googlecode.iterm2 | grep -i promptonquit
PromptOnQuit = 0;
xterm-256color is part of a dictionary, and we need to use plistbuddy to change it, here is the command to see the current settings
[admin#mb-125:~] : /usr/libexec/PlistBuddy -c "Print :\"New Bookmarks\":0:\"Terminal Type\"" Library/Preferences/com.googlecode.iterm2.plist
xterm-256color
And this is how you change it from command line
[admin#mb-125:~] : /usr/libexec/PlistBuddy -c "Set :\"New Bookmarks\":0:\"Terminal Type\" xterm" Library/Preferences/com.googlecode.iterm2.plist
[admin#mb-125:~] : /usr/libexec/PlistBuddy -c "Print :\"New Bookmarks\":0:\"Terminal Type\"" Library/Preferences/com.googlecode.iterm2.plist
xterm
In the ~/Library/Preferences folder there's a file called com.googlecode.iterm2.plist. This file contains all your iTerm preferences. What I like to do is keep a copy of that preferences file inside my dotfile repo. When I'm installing on a new system I copy it into ~/Library/Preferences via my installation script .
Hope that helps!
How can I search the command history in cygwin?
I don't want to keep pressing the arrow keys to execute a command from console command history.
If you are using the default editing mode, do ctrl+R to search back through your history.
If you have done set -o vi to use vi editing mode, then it is esc-/
The history command is the way to go. I use
h ()
{
history | cut -f 2- | sort -u | grep -P --color=auto -e "$*"
}
so that I can type something like h git.*MyProgram, h ^tar -c, h svn:ignore, etc to pull up a sorted list of past commands matching a regex.
You might also want to add the following lines to ~/.inputrc:
# Ctrl+Up/Down for searching command history
"\e[1;5A": history-search-backward
"\e[1;5B": history-search-forward
With these in place, you can type a partial command prefix (such as gi or sql) then use Ctrl+Up to scroll back through the list of just your command history entries that match that prefix (such as git clone https://code.google.com/p/double-conversion/ and sqlite3 .svn/wc.db .tables). This can be a lot faster than searching and then cutting and pasting if you want to edit or re-execute a command that was fairly recent.
I use the history command in combination with grep, e.g. history | grep vi shows all commands where vi was used.
Checkout the "Gnu Bash Manual" (man bash) for the command "fc". E.g.fc -l -80 would list the last 80 commands, while other options let you search with RegEx...
Do
vi ~/.inputrc
Add
For arrow up/down bindings:
"\e[A": history-search-backward
"\e[B": history-search-forward
Or for page up/down bindings:
"\e[5~": history-search-backward
"\e[6~": history-search-forward
Close and open cygwin.
Voila.
I think one of the easiest way is to pipeline it with less and press search character ("/") and then type the command you wanna find.
history | less
and then
/text to find
to find the desired command
Another way
is to append the stdout form history command to a file: history > /cygdrive/path/file.txt
and then search in the document.