How to fix zsh: corrupt history file /home/mis/.zsh_history (Linux) - zsh

Whenever I open terminal I got his Warning!
[WARNING]: Console output during zsh initialization detected
When using Powerlevel10k with instant prompt, console output during zsh
initialization may indicate issues.
You can:
Recommended: Change ~/.zshrc so that it does not perform console I/O
after the instant prompt preamble. See the link below for details.
You will not see this error message again.
Zsh will start quickly and prompt will update smoothly.
Suppress this warning either by running p10k configure or by manually
defining the following parameter:
typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet
You will not see this error message again.
Zsh will start quickly but prompt will jump down after initialization.
Disable instant prompt either by running p10k configure or by manually
defining the following parameter:
typeset -g POWERLEVEL9K_INSTANT_PROMPT=off
* You will not see this error message again.
* Zsh will start slowly.
Do nothing.
You will see this error message every time you start zsh.
Zsh will start quickly but prompt will jump down after initialization.
console output produced during zsh initialization follows
zsh: corrupt history file /home/mis/.zsh_history

You can solve it by removing the package (purge) and reinstall it back.

Related

Bash Script function not showing segmentation fault for C program in ZSH [duplicate]

I have a program written in C that fails. When I run it in zsh, the program fails, but it's error output is not displayed in command line (note that the second ➜ was red, indicating a failed execution):
hpsc-hw2-USER on  master
➜ ./sort -a 405500
hpsc-hw2-USER on  master
➜
However, when I run it in bash, the error shows up:
[USER#COMPUTER hpsc-hw2-USER]$ ./sort -a 405500
Segmentation fault (core dumped)
Any idea why? I'm running oh-my-zsh with the spaceship theme if that helps.
but it's error output is not displayed in command line
That's not something that your program writes to the screen. It's the shell that's writing it. So the shell is not 'hiding' it.
I'm not using zsh myself, but since a red arrow indicates that the program was abnormally terminated, I guess you can look at the code for the red arrow and create a custom message. Here is a question about the error codes that might help you: What error code does a process that segfaults return?
I remember that I once made a custom bash prompt that showed the last exit code. Maybe I used this, but I'm not sure: Bash Prompt with Last Exit Code
Here is the documentation for how to customize the prompt for spaceship theme: https://denysdovhan.com/spaceship-prompt/docs/Options.html#exit-code-exit_code
I assume that you need to add exit_code to the SPACESHIP_PROMPT_ORDER section in your .zshrc file.
Any idea why?
You probably have to ask the developers. An equally valid question is: "Why does bash print 'segmentation fault'?" It's just a design choice. Bash does not print the memory address where the segfault occurred. Why is that?
Seems like the developers of oh-my-zsh thought it was enough with a red arrow.
Any ideas how to make zsh output the error message?
The result of the last command is stored in the shell variable ?, so you can print it with something like print $? or echo $?. Like most shells, zsh is incredibly configurable, so you can write a script that e.g. includes the result of the last command in your prompt. Here's a blog post in which the author configures zsh to display non-zero results in the right prompt: Show Exit Code of Last Command in Zsh.
Or why it doesn't do it to begin with?
Shell commands don't normally crash, and if they encounter errors they typically provide more useful output than just the return code on their own. The return code is most useful for scripts, so that you can write a script that handle error conditions.

When running script: "julia -i run/run_nf.jl", the error following error is displayed "Could not determine command"

When I input the command
"julia -i run/run_nf.jl" the error "could not determine command" is shown.
before the error is shown this is how my cd looks like:
After activating the project with the command "activate." The following text is displayed in purple color ""
Finally with the command "julia -i run/run_nf.jl" I run the script "run_nf.jl" that is located on the folder "run". However, instead of running the script the following error is displayed.
The instruction for running and installing the necessary pachages are described in detail here:
Instruction, which I am based to run my script
As #fredrikekre mentioned in the comments, you are trying to run a terminal command from the Julia REPL's PKG mode, which will not work. You have two options:
Run the command from inside the REPL's shell mode by first using the "delete" or "backspace" key to exit out of the Pkg mode (you will see the prompt change) and then typing in ; which switched the REPL to shell mode and then you can run that command.
Same as above in that you need to exit the Pkg mode by clicking the "delete" or "backspace" key on you computer, and then you can run (from the REPL) include("run/run_nf.jl") which will run the file (assuming that is the correct file path).
I will also make a PR to that package you linked above to update the docs to be more clear. Edit, link to PR: https://github.com/dynamicslab/NormalFormAE/pull/7

oh-my-zsh: plugin 'git-remote-branch' not found

When starting [oh-my-zsh] a message shows up since a few weeks saying
[oh-my-zsh] plugin 'git-remote-branch' not found
How do I get this error message away? I do not care about the plugin.
The repository at https://github.com/webmat/git_remote_branch
says this plugin is no longer maintained.
You can remove the error message on shell in the zsh config file as follows:
Execute on terminal:
nano ~/.zshrc
Find line containing the plugin:
plugins=(... git-remote-branch ...)
Remove
git-remote-branch
from that line.
Then restart the terminal.
Now the error should be gone.

How to debug this scheduled .bat task in task scheduler using cmd and log file?

I'm trying to basically run the following .bat file as a scheduled task, while also logging errors in a .txt file:
In the 'program/script' box, I just have cmd. Then in the add arguments box I have:
/k ""T:\Some_folder\mybatchfile.bat" >>"T:\somelog.txt" 2>&1"
This had been working just fine originally before I tried to add the log function and calling cmd explicitly as seen in several posts, but I'd really like to add this function. I'm using /k for now so that I can watch the cmd window as things happen, but plan to replace it with /c so it closes when its done.
I tried many permutations of where my quotation marks are but am not having a lot of luck. I'm also intentionally using >> vs > in order to append the log, not overwrite it.
The contents of the .bat file are basically:
"C:\RDirectory\R.exe" CMD BATCH "T:\Some_folder1\Preworkforbatch.R"
copy T:\Some_folder2\some_data.csv "C:\Users\ABC1\Another_folder"
copy T:\Some_folder3\some_more_data*.csv "C:\Users\ABC1\Another_folder"
I'm wondering if part of it is that T is a network folder that is mapped? Thanks for your help.
edit:
Here is more info on the task:
"T:\Some_folder\mybatchfile.bat" >> "T:\somelog.txt" 2>&1
When redirecting the output of a batch file to a log file you will not see as much output in the cmd window. You have to repeatedly open, close, open the log file to see your progress. Use the title command in your batch to display progress info in the cmd window.
title This is %~F0. The time is %time%. The date is %date%. SLEEP 3600 FOR :RECORDRADIO
Ok this ended up working for me, by editing the batch file itself, and just running the batch file (not cmd explicitly) in the task scheduler:
mybatchfile.bat:
#echo on
"C:\RDirectory\R.exe" CMD BATCH "T:\Some_folder1\Preworkforbatch.R" >> "C:\Users\ABC1\Logfolder\mylog.txt" 2>&1
copy T:\Some_folder2\some_data.csv "C:\Users\ABC1\Another_folder" >> "C:\Users\ABC1\Logfolder\mylog.txt" 2>&1
copy T:\Some_folder3\some_more_data*.csv "C:\Users\ABC1\Another_folder" >> "C:\Users\ABC1\Logfolder\mylog.txt" 2>&1
Writing the log file to the network was causing errors. Writing to the local computer solved this issue. Not using double quotes also was key, instead just quotes around the file/path. This setup gives me an output for each line, so for every line 2>71 shows up, I get an output if there's an error or a completion message.
This is what the task scheduler looks like:

nohup command getting permission issues

I am trying to run a filewatcher.sh script in background. It further invokes a java code through a jar file.
Whenever I run the command("nohup sh filewatcher.sh") through terminal, everything is ok. I have to hit enter two times so the output file is appended to nohup.out. But whenever I try to run the equivalent command("nohup filewatcher.sh >> nohup.out < /dev/null &") from a shell script automate.sh, I get following permission error.
error-log. Click to see snippet.
Could this an issue of permission for the automate.sh?
I have crossed check to see this script is having same permissions and ownership as the user when I log in and enter the nohup command from command line.
I also checked the ownership of the folders where the files are getting moved but everything is having same permissions and ownership.

Resources