# 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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://til.yulrizka.com/unix/zsh-ctrl-p-same-behavior-as-up-arrow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
