I'm using iterm2 with zsh and oh my zsh.
When I quit iterm2 and re-open it, my history is gone. I'd like for it to persist. On my old machine, this worked by default, but since it doesn't on my new machine, I'm having to learn a little more about shells than I used to need to know.
Potentially relevant: my .zsh_history file requires sudo in order to open. Also, I don't share history across tabs, the way I know many people with iterm/zsh/ohmyzsh seem to complain about.
Related
I have been using the default bash of linux for over 1 year and one of colleague recommended me switch over to using iTerm2 alongwith zsh and oh-my-zsh. He also recommended this post to install and configure those :
https://www.freecodecamp.org/news/how-to-configure-your-macos-terminal-with-zsh-like-a-pro-c0ab3f3c1156/
When i asked what are they the answer he gave me was kind of confusing, so i ask you overlords kind do tell mewhat actually those are and if you have some insights about what actually a bash is, i would be happy to learn that too :)
Thank you all
Pawan
When you are at a command line, typing in commands and reading output you are working in a program called a terminal (or console on windows). The terminal is taking your commands and forwarding them to a program, called a shell, who's job is to actually execute the commands you type in to the terminal and possibly print some output. The output from the shell is then displayed in your terminal window.
The terminal is like the web browser and the shell is like the javascript engine. Your browser takes your input (click, keypresses, mousemoves) and sends them along to javascript which processes those actions and the browser displays the results.
iTerm2 is a terminal emulator meant to be a replacement for macOS terminal and is far more feature rich. It's the terminal program providing you with a command line interface.
ZSH is a specific shell, as is bash, the same way linux is a specific operating system. There are different shells that provide different syntax, features and functionality. There's bash, cshell, fish, powershell, zsh and others.
Installing ZSH, you are essentially downloading a new program and telling your terminal to use that program (say, instead of bash) to process the commands and run scripts.
oh-my-zsh provides a way of managing your zsh configurations, themes and plugins to extend the look and functionality of your shell.
I can't reccomend this setup enough- it's like the cadillac of command lines. You have a good friend there.
Is there a way to share zsh (shell) history among computers just like browser history ?
Hey You can access the zsh history by typing
Sudo cat ~/.zsh history
And then you will get whole history.
Zsh stores the history in this history file.
I am operating in a linux environment (not familiar to me) and I am handling a bunch of files in django. Bit embarrassing but I seem to have done something subtle to the server that disallows me from setting up separate work stations from my terminal... i.e. emacs file.py & won't work for me; it just says that the emacs window is loading but it won't actually appear - I've waited 5 minutes.
It's not a big deal as emacs file.py works fine and I can "Reset terminal" once I'm done editing the file. However, saving the file could be a problem as the saving options are different between the "&" and "without &" versions of the command. It's such a basic thing that there seems to be no info on it online... any tips?
NOTE: it all started when I mistakenly typed emacs file.py and forgot the & and now something seems to be irreversibly changed that logging in and out again doesn't fix...
When using emacs in a text terminal, start it without the &, you need to run it in foreground. To save a file, use the standard C-xC-s (if your terminal interprets the keystrokes differently, you have to configure the terminal). After saving the file, you can get back to the shell by pressing C-z. It would stop emacs, but you can get back in by typing fg or %em or similar.
To quit emacs, use C-xC-c.
Until recently I have been using bash with tmux. Bash was behaving as I would expect it to behave, where the history is preserved in each separate pane, and is not shared between panes. However it looks like in zsh the default is for the history in the panes is to be shared. Is there a way to overwrite the default in zsh so that they are not shared when using in tmux?
Tmux should have nothing to do with this, really. So let's focus on your Zsh setup.
You’d have to jump through some hoops to get history to be real-time shared among running Zshs, so it’s surprising that you’re seeing this. What settings have you made to control your Zsh history? Run this to see your settings:
setopt |grep hist
For not saving history immediately, you’ll want:
setopt noincappendhistory
setopt nosharehistory
You can put that into your ~/.zshrc. You may want to log out of running shells to ensure your new settings take place.
For info on all the history-related Zsh options, see man 1 zshoptions and look for the “History” section a few pages in. Note that there are also some environment variables that impact history (SAVEHISTORY, HISTFILE, HISTFILEIGNORE, HISTSIE, HISTFILESIZE).
I'm switching from gnu screen to tmux, and I'm observing a weird behaviour where my shell hangs when I create a new window in tmux. I can kill the hang and get to my shell if I hit CTRL-C, but I want to find out what's going wrong.
I've done some echo debugging of my zsh configuration and figured out that the hang happens after ~/.zsh/env is sourced (it doesn't hang w/in ~/.zsh/env, I've checked that), but before ~/.zshrc is sourced. I'm willing to dig further, but I'm not sure what happens between those two steps. Can anyone tell me, so I know where to look?
Ah-ha, it's /etc/zprofile that's causing the issue. I found out from man zsh the order of the sourced files. Thanks!