Archive

Archive for the ‘zsh’ Category

A Powerline style prompt for your shell

July 23, 2017 Leave a comment

For a hassle free powerline like shell. Works with bash and zsh.

* Shows some important details about the git/svn/hg/fossil branch (see below)
* Changes color if the last command exited with a failure code
* If you’re too deep into a directory tree, shortens the displayed path with an ellipsis
* Shows the current Python virtualenv environment
* It’s easy to customize and extend. See below for details.

https://github.com/banga/powerline-shell

Advertisements
Categories: bash, zsh Tags:

Ctrl + Left or Right arrow

November 17, 2016 Leave a comment

Problem:
A colleague introduced me to using “Option + Left” shortcut on OSX. I’d like to set this up on my debian box.

Option/Alt + Left or Right

This shortcut allows you to move the cursor between separate words in a command line. Use Option and the left arrow to move back and use Option with the right arrow to move forward down the line.

Solution:
I’ll be using “Ctl + Left” to move back and “Ctl + Right” to move forward between separate words.

For bash:
Add the following to .inputrc

"\e[1;5D": backward-word
"\e[1;5C": forward-word

For zsh:
Add this to .zshrc

bindkey '^[[1;5C' forward-word
bindkey '^[[1;5D' backward-word

Troubleshooting
To find out what is being sent by the keyboard. Type Ctrl + C to quit.

$ cat -v    
# When pressing Ctrl + Left Arrow                           
^[[1;5D

# When pressing Ctrl + Right Arrow
^[[1;5C

Source:
http://superuser.com/questions/357355/how-can-i-get-controlleft-arrow-to-go-back-one-word-in-iterm2
http://invisible-island.net/ncurses/ncurses.faq.html#modified_keys (Look at the “How can I see what my keyboard sends?” section)

http://www.techrepublic.com/article/20-terminal-shortcuts-developers-need-to-know/

Categories: bash, Interesting, zsh Tags: