> For the complete documentation index, see [llms.txt](https://til.yulrizka.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.yulrizka.com/unix/zsh-ctrl-p-same-behavior-as-up-arrow.md).

# zsh ctrl p same behavior as up arrow

By default Ctrl-P just jump back to the history while up arrow behave a little bit smarter.

For example if you have history like this

```
ssh a.com
ls
cd
ssh b.com
cat
grep
```

Normaly if you type `$ ssh` and `Ctrl-P` afterwares, it will give you `grep` not `ssh b.com`

to change this behavior, you can put this in your .zshrc

```
bindkey "^P" up-line-or-beginning-search
bindkey "^N" down-line-or-beginning-search
```
