Posts

Showing posts with the label Zsh

Add Timestamp To Oh-my-zsh Robbyrussell Theme

Image
Answer : According to the zshmisc man page there are several % codes for date and time, eg: %D The date in yy-mm-dd format. %T Current time of day, in 24-hour format. %t %@ Current time of day, in 12-hour, am/pm format. %* Current time of day in 24-hour format, with seconds. %w The date in day-dd format. %W The date in mm/dd/yy format. %D{strftime-format} The last one allows codes listed in the strftime(3) man page. Edit your ~/.zshrc file and add at the end a new PROMPT value, eg: PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} %D %T % %{$reset_color%}' If you want add date/time to the right, you set RPROMPT local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )" PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)' RPROMPT="[%D{%y/%m/%f}|%@]" I added this %D{%m/%f/%y}|%D{%L:%M:%S} to the main theme to disp...

Add Newline To Oh My ZSH Theme

Image
Answer : I was actually searching for the same answer. But my needs was a little more specific since I only wanted to add a newline in the agnoster theme, the one I'm using now. In my research, I find a lot of forked themes that already do it, but I thought that this was an overkill solution for only add a new line. So I read the agnoster code and come up with this simple solution of overwrite the prompt_end() function in my .zshrc file. To do it, just add the code bellow in your .zshrc file: prompt_end() { if [[ -n $CURRENT_BG ]]; then print -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" else print -n "%{%k%}" fi print -n "%{%f%}" CURRENT_BG='' #Adds the new line and ➜ as the start character. printf "\n ➜"; } Hope it helps you to have a clue on how to customize your chosen theme. Here is the result: I think the proper place to change one's prompt is in the theme itself. On my syst...

Apple - Change Default Shell From Bash To Zsh

Image
Answer : macOS Catalina and later (10.15+) Apple replaced bash with zsh as the default shell. See article. So no need to do anything. You can verify the default shell by typing echo $0 in the terminal. macOS Mojave and earlier (10.14-) See Apple Support page, Use zsh as the default shell on your Mac Surprisingly this doesn't work with the command line tools as one would expect. This needs to be done with the System Preferences app. The following steps work with multiple versions of Mac OS X through at least 10.11 (El Capitan). Open up the "User's & Groups" panel in the "System Preferences" app. Make sure the panel is unlocked (bottom left) Control click on your username (top left) and select "Advanced Options..." This is only available if you are an Administrator. 4. Change the "Login shell" value to /bin/zsh . 5. Press the OK button to save your change. You should be careful not to change any other f...