zshrc

5
# ############################################################################## ################### # zshrc by Nizam-ood-Deen # ############################################################################## ################### # Features # + works on both ubuntu linux and winxp cygwin # + random colorised prompts with time and fortune # + cmd and cmd-args auto-completion with no need for 'cd' cmd # Version Info: # - Updated 01apr2014: adding params for PortableApps, UniformServer (replaces W amp and Xampp) # - Updated 27dec2013: adding jpico params for no backup # - Updated 14sep2013: Added more debug loops # - Updated 27aug2013: Added os check so cowsay not executed on windows; added d ebug loops. # - Updated 17jan2012: Added code for fortune with random cowsay on quasar kolka ta # - Original 12sep2003: Produced for zircon bbsr, some mods for lv cygwin on sam arhp6450 # todo: add lines for new progs in cygwin 2.819 # todo: paste this into scribd, pastebin # Install: $mkzsh -D -P / mkzsh -D -P -A (mk desktop + menuitem + forall); rclic k(icon)>Props>Colors # mkpasswd -d > /etc/passwd if the xp user not part of domain and not exist in / etc/passwd, # - home dir not ~ but c:/documents ... # Path Section: include windows cmds like tree.com, notepad, textpad, and postpe nd normal path # % env -> see all env vars debug=false; # set to true to view debug messages PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/WINNT/System32/:$PA TH PWD=~ cd $PWD # Autocompletion Init Section # autoload -U compinit # compinit # Spell Checking Section setopt correct # correct spelling of commands setopt correct_all # correct spelling of all args # Auto Change Directory Section setopt autocd autopushd setopt pushdignoredups nodosfilewarning="true" # turn off "MS-DOS style path detected: c:/. Preferred P OSIX equivalent is: /cygdrive/c" warnings

Upload: nizamshahii

Post on 11-Jul-2016

213 views

Category:

Documents


1 download

DESCRIPTION

Nice zshrc with a dynamic colourful prompt.

TRANSCRIPT

# ################################################################################################## zshrc by Nizam-ood-Deen# #################################################################################################

# Features# + works on both ubuntu linux and winxp cygwin# + random colorised prompts with time and fortune # + cmd and cmd-args auto-completion with no need for 'cd' cmd

# Version Info:# - Updated 01apr2014: adding params for PortableApps, UniformServer (replaces Wamp and Xampp)# - Updated 27dec2013: adding jpico params for no backup# - Updated 14sep2013: Added more debug loops# - Updated 27aug2013: Added os check so cowsay not executed on windows; added debug loops. # - Updated 17jan2012: Added code for fortune with random cowsay on quasar kolkata# - Original 12sep2003: Produced for zircon bbsr, some mods for lv cygwin on samarhp6450

# todo: add lines for new progs in cygwin 2.819# todo: paste this into scribd, pastebin

# Install: $mkzsh -D -P / mkzsh -D -P -A (mk desktop + menuitem + forall); rclick(icon)>Props>Colors # mkpasswd -d > /etc/passwd if the xp user not part of domain and not exist in /etc/passwd, # - home dir not ~ but c:/documents ...

# Path Section: include windows cmds like tree.com, notepad, textpad, and postpend normal path# % env -> see all env vars

debug=false; # set to true to view debug messagesPATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/WINNT/System32/:$PATHPWD=~cd $PWD

# Autocompletion Init Section

# autoload -U compinit# compinit

# Spell Checking Section

setopt correct # correct spelling of commandssetopt correct_all # correct spelling of all args

# Auto Change Directory Section

setopt autocd autopushdsetopt pushdignoredups

nodosfilewarning="true" # turn off "MS-DOS style path detected: c:/. Preferred POSIX equivalent is: /cygdrive/c" warnings

# Prompt Section

if [[ $debug == "true" ]] then echo "Setting Prompt Options ... ";fiautoload -U promptinitpromptinit# Random prompt# % prompt -l: adam2 bart bigfade clint elite2 elite fade fire off oliver redhat suse walters zeframif [[ $RANDOM > 8000 ]]; # A pseudo-random integer 0-32767 newly gentd each time refcd then if [[ $debug == "true" ]]

then echo Selecting adam1 prompt ... # set adam1 prompt 8/32=1/4 of the time as mostly rnd < 8k fi prompt adam1 blue green green; else prompt random;fi

# RPS1 (Right hand side Prompt Symbol): set to data and timeif [[ $debug == "true" ]] then prompt -c # = echo "Current prompt theme is: ... "fiRPS1=$'%{\e[1;31m%} {%D} %{\e[1;45m%} %{\e[2;33m%} <%*> %{\e[0m%}'

# Fortune: Ubuntu Section with cowsay installed n # %cowsay -l -> show all default cows at /usr/share/cowsay/cows

RANGE=10number=$RANDOMlet "number %= $RANGE"case $number in 0) cow="beavis.zen" ;; 1) cow="cock" ;; 2) cow="dragon" ;; 3) cow="kiss" ;; 4) cow="koala" ;; 5) cow="moose" ;; 6) cow="stegosaurus" ;; 7) cow="turkey" ;; 8) cow="tux"

;; 9) cow="unipony-smaller" ;;esac

RANGE=2number=$RANDOMlet "number %= $RANGE"case $number in 0) cowcommand="cowsay" ;; 1) cowcommand="cowthink" ;;esac

RANGE=10;number=$RANDOM; # A pseudo-random integer 0-32767 newly gentd each time refcdlet "number %= $RANGE";os=$OS; # winxp = "Windows_NT"

if [[ $os == "Linux" && ($number > 5) && ($debug == "true") ]] then echo "Printing offensive fortune on $os using \"$cowcommand -f $cow\" ... "; fortune -o | $cowcommand -f $cowelif [[ $os == "Linux" && ($number > 5) && ($debug == "false") ]] then echo "\n"; fortune -o | $cowcommand -f $cowelif [[ $os == "Linux" && ($number < 6) && ($debug == "true") ]] then echo "Printing normal fortune using \"$cowcommand -f $cow\" ... "; fortune | $cowcommand -f $cow;elif [[ $os == "Linux" && ($number < 6) && ($debug == "false") ]] then echo ""; fortune | $cowcommand -f $cow;elif [[ $os == "Windows_NT" && ($number > 5) && ($debug == "true") ]] then echo "Printing offensive fortune on $os ... "; fortune -oelif [[ $os == "Windows_NT" && ($number > 5) && ($debug == "false") ]] then echo ""; fortune -oelif [[ $os == "Windows_NT" && ($number < 6) && ($debug == "true") ]] then echo "Printing normal fortune on $os ... "; fortune;elif [[ $os == "Windows_NT" && ($number < 6) && ($debug == "false") ]] then echo ""; fortune;fi

# Custom Autocomplete List: host nameshosts=(alpha beta gamma http://localhost/IrSemArchive cyberspace.org m3rl1n.phy457.p177.edu iop.10pb.res.in)compctl -k hosts ssh scp ping host telnet# compctl -k hosts ssh scp ping host telnet links lynx # this stops cmd line autocomplete for links

# Auto list and menu selection Section

setopt auto_list # auto list choices in ambiguous selectn after <tab>

setopt auto_menu # cycle menu options using <tab><tab>setopt menu_complete # insert first matching entry in <tab> listsetopt NO_bash_auto_list # overrides auto_list and forces 3x <tab> presssetopt globsetopt glob_complete # filename generationsetopt list_ambiguoussetopt NO_clobber # don't overwrite existing files

# export DISPLAY to remotemachine (works in telnet only); useful for ssh -X ...

export DISPLAY=$REMOTEHOST:0.0

# History options

if [[ $debug == "true" ]] then echo "Setting History Options ... ";fiHISTSIZE=2000HISTFILE="$HOME/.zsh_history"SAVEHIST=2000setopt append_historysetopt inc_append_historysetopt share_historysetopt extended_history # beginning time:elapsed seconds;command added, ie: 10245234534:0;/usr/games/fortunesetopt hist_expire_dups_first

# Logout Optionssetopt check_jobs # report job status before exit, twice exit ends# if required, add auto-timeout on shared systems: # TMOUT=1800 # or just 0 # export $TMOUT

# Watch Section: Watch for Friend and Foe

WATCHFMT='%n %a %M %T'LOGCHECK=3export LOGCHECKwatch=all

# Alias Section: cygwin only executes .exe, not .com filesif [[ $debug == "true" ]] then echo "Setting Aliases ... ";fialias "rm=rm -i"alias "mv=mv -i"alias "ll=ls -l"alias "nano=nano -D -r 90 -s 'aspell -c'" # dos mode and spell checker with widthalias "pico=nano -D -r 90 -s 'aspell -c'" # dos mode and spell checker with widthalias "jpico=jpico -backpath /cygdrive/c/tmp f"alias "lynx=lynx -nocolor -accept_all_cookies -editor=nano"

if [[ $os == "Windows_NT" ]] then # portable apps aliases alias "anote=/cygdrive/c/Program_Files/PortableApps_11.2/PortableApps/ANotePortable/ANotePortable.exe" alias "npp=/cygdrive/c/Program_Files/PortableApps_11.2/PortableApps/Notepad++Portable/Notepad++Portable.exe"

alias "mplayer=/cygdrive/c/Program_Files/PortableApps_11.2/PortableApps/MPC-HCPortable/MPC-HCPortable.exe" alias "spdf=/cygdrive/c/Program_Files/PortableApps_11.2/PortableApps/SumatraPDFPortable/SumatraPDFPortable.exe" alias "chromium=/cygdrive/c/Program_Files/PortableApps_11.2/PortableApps/ChromiumBSUPortable/ChromiumBSUPortable.exe" alias "kobo=/cygdrive/c/Program_Files/PortableApps_11.2/PortableApps/KoboDeluxePortable/KoboDeluxePortable.exe" alias "tts=/cygdrive/c/Program_Files/PortableApps_11.2/PortableApps/BalabolkaPortable/BalabolkaPortable.exe" alias "balabolka=/cygdrive/c/Program_Files/PortableApps_11.2/PortableApps/BalabolkaPortable/BalabolkaPortable.exe" alias "virtualdub=/cygdrive/c/Program_Files/PortableApps_11.2/PortableApps/VirtualDubPortable/VirtualDubPortable.exe" alias "vdub=/cygdrive/c/Program_Files/PortableApps_11.2/PortableApps/VirtualDubPortable/VirtualDubPortable.exe" alias "vlc=/cygdrive/c/Program_Files/PortableApps_11.2/PortableApps/VLCPortable/VLCPortable.exe" alias "magnifier=/cygdrive/c/Program_Files/PortableApps_11.2/PortableApps/VirtualMagnifyingGlassPortable/VirtualMagnifyingGlassPortable.exe" alias "magnifyingglass=/cygdrive/c/Program_Files/PortableApps_11.2/PortableApps/VirtualMagnifyingGlassPortable/VirtualMagnifyingGlassPortable.exe"

# uniform server aliases alias "php=/cygdrive/c/Program_Files/UniformServer_11.1.1/UniServerZ/core/php54/php.exe" alias "mysql=/cygdrive/c/Program_Files/UniformServer_11.1.1/UniServerZ/core/mysql/bin/mysql.exe" alias "mysqladmin=/cygdrive/c/Program_Files/UniformServer_11.1.1/UniServerZ/core/mysql/bin/mysqladmin.exe" alias "mysqldump=/cygdrive/c/Program_Files/UniformServer_11.1.1/UniServerZ/core/mysql/bin/mysqldump.exe"

# simple cmds alias "tree=tree.com /f /a" # can always exec old tree using tree.com; alias "paint=/cygdrive/c/WINDOWS/system32/mspaint.exe" alias "mspaint=/cygdrive/c/WINDOWS/system32/mspaint.exe"

# defunct due to portable apps, keeping for backward compat alias "mplayerK=/cygdrive/c/Program\ Files/K-Lite\ Codec\ Pack/Media\ Player\ Classic/mpc-hc.exe" alias "spdf=/cygdrive/c/Program\ Files/SumatraPDF/SumatraPDF.exe"; # wxp black ed has sumatraPdf pre-installed alias "acroread=/cygdrive/c/Program_Files/AcrobatReader7.0/Reader/AcroRd32.exe"; # needs acroreader 7 alias "phpWamp=/cygdrive/c/Program_Files/WampServer_2.2e/bin/php/php5.4.3/php.exe"; # needs WampServer 2.2e alias "nppRaw=/cygdrive/c/Program_Files/NotepadPP_6.4.2/notepad++.exe"; # needs notepad++ 6.4.2fi

# scp [email protected]:/home/giga2/hep/user/tmp/*.pdf .# scp "[email protected]:/user1/afsar/dlaug13/*" . # The End