massive removal of aligning (since it has been added to css)

This commit is contained in:
arcan1s
2014-06-23 04:51:32 +04:00
parent cc462bc930
commit 27fce352a2
36 changed files with 707 additions and 707 deletions

View File

@ -8,16 +8,16 @@ short: about-zshrc
description: It is first paper in my blog (I think I need something here for tests =)). There are many similar articles, and I'll not be an exception. I just want to show my <code>.zshrc</code> and explain what it does and why it is needed. Also any comments or additions are welcome. It is a translated paper from Russian (<a href="http://archlinux.org.ru/forum/topic/12752/">original</a>).
---
<h2><a name="prepare" class="anchor" href="#prepare"><span class="octicon octicon-link"></span></a>Prepare</h2>
<p align="justify">First install recommended minima:</p>
<p>First install recommended minima:</p>
{% highlight bash %}
pacman -Sy pkgfile zsh zsh-completions zsh-syntax-highlighting
{% endhighlight %}
<p align="justify"><a href="https://www.archlinux.org/packages/pkgfile/">pkgfile</a> is a very useful utility. Also this command will install shell, additional completion and syntax highlighting.</p>
<p><a href="https://www.archlinux.org/packages/pkgfile/">pkgfile</a> is a very useful utility. Also this command will install shell, additional completion and syntax highlighting.</p>
<h2><a name="configuration" class="anchor" href="#configuration"><span class="octicon octicon-link"></span></a>Shell configuration</h2>
<p align="justify">All options are avaible <a href="http://zsh.sourceforge.net/Doc/Release/Options.html">here</a>.</p>
<p>All options are avaible <a href="http://zsh.sourceforge.net/Doc/Release/Options.html">here</a>.</p>
<p align="justify">Set history file and number of commands in cache of the current session and in the history file:</p>
<p>Set history file and number of commands in cache of the current session and in the history file:</p>
{% highlight bash %}
# history
HISTFILE=~/.zsh_history
@ -25,7 +25,7 @@ HISTSIZE=500000
SAVEHIST=500000
{% endhighlight %}
<p align="justify">I can not remember all <code>Ctrl+</code> combinations so I bind keys to its default usages:</p>
<p>I can not remember all <code>Ctrl+</code> combinations so I bind keys to its default usages:</p>
{% highlight bash %}
# bindkeys
bindkey '^[[A' up-line-or-search # up arrow for back-history-search
@ -37,9 +37,9 @@ bindkey '\e[4~' end-of-line # end
bindkey '\e[5~' up-line-or-history # page-up
bindkey '\e[6~' down-line-or-history # page-down
{% endhighlight %}
<p align="justify">But in this case <code>Up</code>/<code>Down</code> arrows are used to navigate through the history based on <b>already entered part</b> of a command. And <code>PgUp</code>/<code>PgDown</code> <b>will ignore</b> already entered part of a command.</p>
<p>But in this case <code>Up</code>/<code>Down</code> arrows are used to navigate through the history based on <b>already entered part</b> of a command. And <code>PgUp</code>/<code>PgDown</code> <b>will ignore</b> already entered part of a command.</p>
<p align="justify">Command autocomplete:</p>
<p>Command autocomplete:</p>
{% highlight bash %}
# autocomplete
autoload -U compinit
@ -47,65 +47,65 @@ compinit
zstyle ':completion:*' insert-tab false
zstyle ':completion:*' max-errors 2
{% endhighlight %}
<p align="justify">Full command autocomplete will be enabled. <code>insert-tab false</code> will enable autocomplete for <b>non-entered</b> commands. <code>max-errors</code> sets maximum number of errors that could be corrected.</p>
<p>Full command autocomplete will be enabled. <code>insert-tab false</code> will enable autocomplete for <b>non-entered</b> commands. <code>max-errors</code> sets maximum number of errors that could be corrected.</p>
<p align="justify">Prompt:</p>
<p>Prompt:</p>
{% highlight bash %}
# promptinit
autoload -U promptinit
promptinit
{% endhighlight %}
<p align="justify">Enable colors:</p>
<p>Enable colors:</p>
{% highlight bash %}
# colors
autoload -U colors
colors
{% endhighlight %}
<p align="justify">Here are some other options.</p>
<p align="justify">Change directory without <code>cd</code>:</p>
<p>Here are some other options.</p>
<p>Change directory without <code>cd</code>:</p>
{% highlight bash %}
# autocd
setopt autocd
{% endhighlight %}
<p align="justify">Correcting of typos (and question template):</p>
<p>Correcting of typos (and question template):</p>
{% highlight bash %}
# correct
setopt CORRECT_ALL
SPROMPT="Correct '%R' to '%r' ? ([Y]es/[N]o/[E]dit/[A]bort) "
{% endhighlight %}
<p align="justify">Disable f#$%ing beep:</p>
<p>Disable f#$%ing beep:</p>
{% highlight bash %}
# disable beeps
unsetopt beep
{% endhighlight %}
<p align="justify">Enable calculator:</p>
<p>Enable calculator:</p>
{% highlight bash %}
# calc
autoload zcalc
{% endhighlight %}
<p align="justify">Append history (<b>do not recreate</b> the history file):</p>
<p>Append history (<b>do not recreate</b> the history file):</p>
{% highlight bash %}
# append history
setopt APPEND_HISTORY
{% endhighlight %}
<p align="justify">Do not save dups to history file:</p>
<p>Do not save dups to history file:</p>
{% highlight bash %}
# ignore spaces in history
setopt HIST_IGNORE_ALL_DUPS
{% endhighlight %}
<p align="justify">...and additional spaces:</p>
<p>...and additional spaces:</p>
{% highlight bash %}
# ignore dups in history
setopt HIST_IGNORE_SPACE
{% endhighlight %}
<p align="justify">...and blank lines too:</p>
<p>...and blank lines too:</p>
{% highlight bash %}
# reduce blanks in history
setopt HIST_REDUCE_BLANKS
{% endhighlight %}
<p align="justify">Enable <code>pkgfile</code>:</p>
<p>Enable <code>pkgfile</code>:</p>
{% highlight bash %}
# pkgfile
source /usr/share/doc/pkgfile/command-not-found.zsh
@ -158,10 +158,10 @@ ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=yellow'
# root example
#ZSH_HIGHLIGHT_STYLES[root]='bg=red'
{% endhighlight %}
<p align="justify">In first line highlighting is turned on. Next main, brackets and pattern highlighting are turned on. Patterns are set below (<code>rm -rf *</code> in the example). Also <code>root</code> and <code>cursor</code> highlighting may be turned on. Colors syntax is understandable, <code>fg</code> is font color, <code>bg</code> is background color.</p>
<p>In first line highlighting is turned on. Next main, brackets and pattern highlighting are turned on. Patterns are set below (<code>rm -rf *</code> in the example). Also <code>root</code> and <code>cursor</code> highlighting may be turned on. Colors syntax is understandable, <code>fg</code> is font color, <code>bg</code> is background color.</p>
<h2><a name="prompt" class="anchor" href="#prompt"><span class="octicon octicon-link"></span></a>$PROMPT and $RPROMPT</h2>
<p align="justify">The general idea is the use single <code>.zshrc</code> for root and normal user:</p>
<p>The general idea is the use single <code>.zshrc</code> for root and normal user:</p>
{% highlight bash %}
# PROMPT && RPROMPT
if [[ $EUID == 0 ]]; then
@ -183,7 +183,7 @@ else
fi
{% endhighlight %}
<p align="justify"><code>fg</code> is font color, <code>bg</code> is background color. <code>_bold</code> and <code>_no_bold</code> regulate the tint. Commands should be in <code>%{ ... %}</code> so they do not appear. Avaible colors are:</p>
<p><code>fg</code> is font color, <code>bg</code> is background color. <code>_bold</code> and <code>_no_bold</code> regulate the tint. Commands should be in <code>%{ ... %}</code> so they do not appear. Avaible colors are:</p>
{% highlight bash %}
black
red
@ -195,7 +195,7 @@ cyan
white
{% endhighlight %}
<p align="justify">Avaible variables are:</p>
<p>Avaible variables are:</p>
{% highlight bash %}
%n - the username
%m - the computer's hostname (truncated to the first period)
@ -211,7 +211,7 @@ white
%1/ - the same as %d but only last directory
{% endhighlight %}
<p align="justify">RPROMPT (<code>acpi</code> package is necessary):</p>
<p>RPROMPT (<code>acpi</code> package is necessary):</p>
{% highlight bash %}
precmd () {
# battery charge
@ -236,12 +236,12 @@ $(batcharge)\
$returncode\
"%{$fg_bold[white]%}]%{$reset_color%}"
{% endhighlight %}
<p align="justify">My RPROMPT shows current time, battery change and last returned code. <code>precmd()</code> is necessary for automatic updating. The construct <code>$(if.true.false)</code> is conditional statement in <code>zsh</code>.</p>
<p>My RPROMPT shows current time, battery change and last returned code. <code>precmd()</code> is necessary for automatic updating. The construct <code>$(if.true.false)</code> is conditional statement in <code>zsh</code>.</p>
<h2><a name="aliases" class="anchor" href="#aliases"><span class="octicon octicon-link"></span></a>Aliases</h2>
<p align="justify"><b>Copy only those aliases that you need.</b> If any alias uses application that is not installed it will leads to fail of loading of configuration file.</p>
<p><b>Copy only those aliases that you need.</b> If any alias uses application that is not installed it will leads to fail of loading of configuration file.</p>
<p align="justify">Small useful (or maybe not) function:</p>
<p>Small useful (or maybe not) function:</p>
{% highlight bash %}
show_which() {
OUTPUT=$(which $1 | cut -d " " -f7-)
@ -249,7 +249,7 @@ show_which() {
}
{% endhighlight %}
<p align="justify">Here is the first group of aliases:</p>
<p>Here is the first group of aliases:</p>
{% highlight bash %}
## alias
# colored grep
@ -268,7 +268,7 @@ alias less='vimpager'
alias zless='vimpager'
{% endhighlight %}
<p align="justify">Here are ls aliases (see <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?ls">man ls</a>):</p>
<p>Here are ls aliases (see <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?ls">man ls</a>):</p>
{% highlight bash %}
alias ls='show_which ls && ls --color=auto --group-directories-first'
alias ll='show_which ll && ls -l --human-readable'
@ -280,7 +280,7 @@ alias lt='show_which lt && ll -t --reverse'
alias lm='show_which lm && la | more'
{% endhighlight %}
<p align="justify">Here are aliases to quick file view from console (just type a file name!):</p>
<p>Here are aliases to quick file view from console (just type a file name!):</p>
{% highlight bash %}
# alias -s
alias -s {avi,mpeg,mpg,mov,m2v,mkv}=mpv
@ -291,7 +291,7 @@ autoload -U pick-web-browser
alias -s {html,htm}=opera
{% endhighlight %}
<p align="justify">Here are "sudo" aliases:</p>
<p>Here are "sudo" aliases:</p>
{% highlight bash %}
# sudo alias
if [[ $EUID == 0 ]]; then
@ -314,7 +314,7 @@ else
fi
{% endhighlight %}
<p align="justify">Here are global aliases. If they are enable the command <code>cat foo g bar</code> will be equivalent the command <code>cat foo | grep bar</code>:</p>
<p>Here are global aliases. If they are enable the command <code>cat foo g bar</code> will be equivalent the command <code>cat foo | grep bar</code>:</p>
{% highlight bash %}
# global alias
alias -g g="| grep"
@ -325,7 +325,7 @@ alias -g dn="&> /dev/null &"
{% endhighlight %}
<h2><a name="functions" class="anchor" href="#functions"><span class="octicon octicon-link"></span></a>Functions</h2>
<p align="justify">Here is a special function for <code>xrandr</code>:</p>
<p>Here is a special function for <code>xrandr</code>:</p>
{% highlight bash %}
# function to contorl xrandr
@ -350,7 +350,7 @@ projctl () {
}
{% endhighlight %}
<p align="justify">Unfortunately I can not remember <code>tar</code> flags thus I use special functions:</p>
<p>Unfortunately I can not remember <code>tar</code> flags thus I use special functions:</p>
{% highlight bash %}
# function to extract archives
# EXAMPLE: unpack file
@ -403,7 +403,7 @@ pack () {
}
{% endhighlight %}
<p align="justify">Here is a special function for <code>su</code>:</p>
<p>Here is a special function for <code>su</code>:</p>
{% highlight bash %}
su () {
CHECKSU=0
@ -421,7 +421,7 @@ su () {
}
{% endhighlight %}
<p align="justify">Function that replaces original <code>rm</code> command. If you type <code>rm</code> it will be equivalent moving to trash an you can easily restore a file:</p>
<p>Function that replaces original <code>rm</code> command. If you type <code>rm</code> it will be equivalent moving to trash an you can easily restore a file:</p>
{% highlight bash %}
rm () {
# error check
@ -464,7 +464,7 @@ rm () {
}
{% endhighlight %}
<p align="justify">Functions with automatic rehash after installing/removing packages are:</p>
<p>Functions with automatic rehash after installing/removing packages are:</p>
{% highlight bash %}
pacman () {
/usr/bin/sudo /usr/bin/pacman $* && echo "$*" | grep -q "S\|R\|U" && rehash
@ -477,12 +477,12 @@ yatest () {
/usr/bin/yaourt --config /etc/pactest.conf $* && echo "$*" | grep -q "S\|R\|U" && rehash
}
{% endhighlight %}
<p align="justify">But autocomplete for <code>yaourt -Ss</code> <a href="https://github.com/zsh-users/zsh-completions/pull/205">will require</a> root privileges.</p>
<p>But autocomplete for <code>yaourt -Ss</code> <a href="https://github.com/zsh-users/zsh-completions/pull/205">will require</a> root privileges.</p>
<h2><a name="variables" class="anchor" href="#variables"><span class="octicon octicon-link"></span></a>Variables</h2>
<p align="justify">It is recommended to set own variables in <code>~/.zshenv</code>. But I have everything stored in the single file.</p>
<p>It is recommended to set own variables in <code>~/.zshenv</code>. But I have everything stored in the single file.</p>
<p align="justify">Here are path, mask of new files, editor and pager:</p>
<p>Here are path, mask of new files, editor and pager:</p>
{% highlight bash %}
# path
export PATH="$PATH:$HOME/.local/bin"
@ -493,7 +493,7 @@ export EDITOR="vim"
export PAGER="vimpager"
{% endhighlight %}
<p align="justify">Here is hashes. If they are enable the command <code>~global</code> will be equivalent the command <code>/mnt/global</code>:</p>
<p>Here is hashes. If they are enable the command <code>~global</code> will be equivalent the command <code>/mnt/global</code>:</p>
{% highlight bash %}
# hash
hash -d global=/mnt/global
@ -504,7 +504,7 @@ hash -d u2=/mnt/usbdev
{% endhighlight %}
<h2><a name="screenshot" class="anchor" href="#screenshot"><span class="octicon octicon-link"></span></a>Screenshot</h2>
<p align="justify"><a href="/resources/screenshots/zshrc_demo.png"><img src="/resources/preview/zshrc_demo_prev.jpg"></a></p>
<p><a href="/resources/screenshots/zshrc_demo.png"><img src="/resources/preview/zshrc_demo_prev.jpg"></a></p>
<h2><a name="file" class="anchor" href="#file"><span class="octicon octicon-link"></span></a>File</h2>
<p align="justify"><a href="https://raw.github.com/arcan1s/dotfiles/master/zshrc">Here is</a> my <code>.zshrc</code>.</p>
<p><a href="https://raw.github.com/arcan1s/dotfiles/master/zshrc">Here is</a> my <code>.zshrc</code>.</p>