openbsd-dotfiles

Base configurations for my Openbsd desktop
git clone https://git.kausban.com/openbsd-dotfiles/raw/.git
Log | Files | Refs

.zshrc.local (12489B)


      1 alias lconf='git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
      2 dotfiles_autoupdate() {
      3 	MSG="Update $(date +"%Y-%m-%d %H:%M") $(uname -s)/$(uname -m)"
      4       	lconf commit -am "$MSG" && \
      5       	lconf push
      6 }
      7 
      8 alias kbus="setxkbmap us altgr-intl  -option 'ctrl:swap_lalt_lctl' -option 'caps:ctrl_modifier' -option 'shift:breaks_caps'"
      9 alias kbde="setxkbmap de  -option 'ctrl:swap_lalt_lctl' -option 'caps:ctrl_modifier' -option 'shift:breaks_caps'"
     10 
     11 alias home_pool="mount_nfs -T 10.0.1.30:/mnt/zpool/home_pool ~/sync/home_pool"
     12 
     13 source <(fzf --zsh)
     14 
     15 #xterm title
     16 function xterm_title_precmd () {
     17 	print -Pn -- '\e]2;%n@%m %~\a'
     18 	[[ "$TERM" == 'screen'* ]] && print -Pn -- '\e_\005{g}%n\005{-}@\005{m}%m\005{-} \005{B}%~\005{-}\e\\'
     19 }
     20 
     21 function xterm_title_preexec () {
     22 	print -Pn -- '\e]2;%n@%m %~ %# ' && print -n -- "${(q)1}\a"
     23 	[[ "$TERM" == 'screen'* ]] && { print -Pn -- '\e_\005{g}%n\005{-}@\005{m}%m\005{-} \005{B}%~\005{-} %# ' && print -n -- "${(q)1}\e\\"; }
     24 }
     25 
     26 if [[ "$TERM" == (alacritty*|st-256color|gnome*|konsole*|putty*|rxvt*|screen*|tmux*|xterm*) ]]; then
     27 	add-zsh-hook -Uz precmd xterm_title_precmd
     28 	add-zsh-hook -Uz preexec xterm_title_preexec
     29 fi
     30 
     31 
     32 ix() {
     33     local opts
     34     local OPTIND
     35     [ -f "$HOME/.netrc" ] && opts='-n'
     36     while getopts ":hd:i:n:" x; do
     37         case $x in
     38             h) echo "ix [-d ID] [-i ID] [-n N] [opts]"; return;;
     39             d) $echo curl $opts -X DELETE ix.io/$OPTARG; return;;
     40             i) opts="$opts -X PUT"; local id="$OPTARG";;
     41             n) opts="$opts -F read:1=$OPTARG";;
     42         esac
     43     done
     44     shift $(($OPTIND - 1))
     45     [ -t 0 ] && {
     46         local filename="$1"
     47         shift
     48         [ "$filename" ] && {
     49             curl $opts -F f:1=@"$filename" $* ix.io/$id
     50             return
     51         }
     52         echo "^C to cancel, ^D to send."
     53     }
     54     curl $opts -F f:1='<-' $* ix.io/$id
     55 }
     56 
     57 0x0() {
     58     [ -t 0 ] && {
     59         local filename="$1"
     60         shift
     61         [ "$filename" ] && {
     62             curl -F file=@"$filename" $* https://0x0.st
     63             return
     64         }
     65         echo "^C to cancel, ^D to send."
     66     }
     67     return
     68 }
     69 
     70 # Filename:      /etc/skel/.zshrc
     71 # Purpose:       config file for zsh (z shell)
     72 # Authors:       (c) grml-team (grml.org)
     73 # Bug-Reports:   see http://grml.org/bugs/
     74 # License:       This file is licensed under the GPL v2 or any later version.
     75 ################################################################################
     76 # Nowadays, grml's zsh setup lives in only *one* zshrc file.
     77 # That is the global one: /etc/zsh/zshrc (from grml-etc-core).
     78 # It is best to leave *this* file untouched and do personal changes to
     79 # your zsh setup via ${HOME}/.zshrc.local which is loaded at the end of
     80 # the global zshrc.
     81 #
     82 # That way, we enable people on other operating systems to use our
     83 # setup, too, just by copying our global zshrc to their ${HOME}/.zshrc.
     84 # Adjustments would still go to the .zshrc.local file.
     85 ################################################################################
     86 
     87 ## Inform users about upgrade path for grml's old zshrc layout, assuming that:
     88 ## /etc/skel/.zshrc was installed as ~/.zshrc,
     89 ## /etc/zsh/zshrc was installed as ~/.zshrc.global and
     90 ## ~/.zshrc.local does not exist yet.
     91 if [ -r ~/.zshrc -a -r ~/.zshrc.global -a ! -r ~/.zshrc.local ] ; then
     92     printf '-!-\n'
     93     printf '-!- Looks like you are using the old zshrc layout of grml.\n'
     94     printf '-!- Please read the notes in the grml-zsh-refcard, being'
     95     printf '-!- available at: http://grml.org/zsh/\n'
     96     printf '-!-\n'
     97     printf '-!- If you just want to get rid of this warning message execute:\n'
     98     printf '-!-        touch ~/.zshrc.local\n'
     99     printf '-!-\n'
    100 fi
    101 
    102 ## Settings for umask
    103 #if (( EUID == 0 )); then
    104 #    umask 002
    105 #else
    106 #    umask 022
    107 #fi
    108 
    109 ## Now, we'll give a few examples of what you might want to use in your
    110 ## .zshrc.local file (just copy'n'paste and uncomment it there):
    111 
    112 ## Prompt theme extension ##
    113 
    114 # Virtualenv support
    115 
    116 #function virtual_env_prompt () {
    117 #    REPLY=${VIRTUAL_ENV+(${VIRTUAL_ENV:t}) }
    118 #}
    119 #grml_theme_add_token  virtual-env -f virtual_env_prompt '%F{magenta}' '%f'
    120 #zstyle ':prompt:grml:left:setup' items rc virtual-env change-root user at host path vcs percent
    121 
    122 ## ZLE tweaks ##
    123 
    124 ## use the vi navigation keys (hjkl) besides cursor keys in menu completion
    125 #bindkey -M menuselect 'h' vi-backward-char        # left
    126 #bindkey -M menuselect 'k' vi-up-line-or-history   # up
    127 #bindkey -M menuselect 'l' vi-forward-char         # right
    128 #bindkey -M menuselect 'j' vi-down-line-or-history # bottom
    129 
    130 ## set command prediction from history, see 'man 1 zshcontrib'
    131 #is4 && zrcautoload predict-on && \
    132 #zle -N predict-on         && \
    133 #zle -N predict-off        && \
    134 #bindkey "^X^Z" predict-on && \
    135 #bindkey "^Z" predict-off
    136 
    137 ## press ctrl-q to quote line:
    138 #mquote () {
    139 #      zle beginning-of-line
    140 #      zle forward-word
    141 #      # RBUFFER="'$RBUFFER'"
    142 #      RBUFFER=${(q)RBUFFER}
    143 #      zle end-of-line
    144 #}
    145 #zle -N mquote && bindkey '^q' mquote
    146 
    147 ## define word separators (for stuff like backward-word, forward-word, backward-kill-word,..)
    148 #WORDCHARS='*?_-.[]~=/&;!#$%^(){}<>' # the default
    149 #WORDCHARS=.
    150 #WORDCHARS='*?_[]~=&;!#$%^(){}'
    151 #WORDCHARS='${WORDCHARS:s@/@}'
    152 
    153 # just type '...' to get '../..'
    154 #rationalise-dot() {
    155 #local MATCH
    156 #if [[ $LBUFFER =~ '(^|/| |	|'$'\n''|\||;|&)\.\.$' ]]; then
    157 #  LBUFFER+=/
    158 #  zle self-insert
    159 #  zle self-insert
    160 #else
    161 #  zle self-insert
    162 #fi
    163 #}
    164 #zle -N rationalise-dot
    165 #bindkey . rationalise-dot
    166 ## without this, typing a . aborts incremental history search
    167 #bindkey -M isearch . self-insert
    168 
    169 #bindkey '\eq' push-line-or-edit
    170 
    171 ## some popular options ##
    172 
    173 ## add `|' to output redirections in the history
    174 #setopt histallowclobber
    175 
    176 ## try to avoid the 'zsh: no matches found...'
    177 #setopt nonomatch
    178 
    179 ## warning if file exists ('cat /dev/null > ~/.zshrc')
    180 #setopt NO_clobber
    181 
    182 ## don't warn me about bg processes when exiting
    183 #setopt nocheckjobs
    184 
    185 ## alert me if something failed
    186 #setopt printexitvalue
    187 
    188 ## with spelling correction, assume dvorak kb
    189 #setopt dvorak
    190 
    191 ## Allow comments even in interactive shells
    192 #setopt interactivecomments
    193 
    194 
    195 ## compsys related snippets ##
    196 
    197 ## changed completer settings
    198 #zstyle ':completion:*' completer _complete _correct _approximate
    199 #zstyle ':completion:*' expand prefix suffix
    200 
    201 ## another different completer setting: expand shell aliases
    202 #zstyle ':completion:*' completer _expand_alias _complete _approximate
    203 
    204 ## to have more convenient account completion, specify your logins:
    205 #my_accounts=(
    206 # {grml,grml1}@foo.invalid
    207 # grml-devel@bar.invalid
    208 #)
    209 #other_accounts=(
    210 # {fred,root}@foo.invalid
    211 # vera@bar.invalid
    212 #)
    213 #zstyle ':completion:*:my-accounts' users-hosts $my_accounts
    214 #zstyle ':completion:*:other-accounts' users-hosts $other_accounts
    215 
    216 ## add grml.org to your list of hosts
    217 #hosts+=(grml.org)
    218 #zstyle ':completion:*:hosts' hosts $hosts
    219 
    220 ## telnet on non-default ports? ...well:
    221 ## specify specific port/service settings:
    222 #telnet_users_hosts_ports=(
    223 #  user1@host1:
    224 #  user2@host2:
    225 #  @mail-server:{smtp,pop3}
    226 #  @news-server:nntp
    227 #  @proxy-server:8000
    228 #)
    229 #zstyle ':completion:*:*:telnet:*' users-hosts-ports $telnet_users_hosts_ports
    230 
    231 ## the default grml setup provides '..' as a completion. it does not provide
    232 ## '.' though. If you want that too, use the following line:
    233 #zstyle ':completion:*' special-dirs true
    234 
    235 ## aliases ##
    236 
    237 ## translate
    238 #alias u='translate -i'
    239 
    240 ## ignore ~/.ssh/known_hosts entries
    241 #alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null" -o "PreferredAuthentications=keyboard-interactive"'
    242 
    243 
    244 ## global aliases (for those who like them) ##
    245 
    246 #alias -g '...'='../..'
    247 #alias -g '....'='../../..'
    248 #alias -g BG='& exit'
    249 #alias -g C='|wc -l'
    250 #alias -g G='|grep'
    251 #alias -g H='|head'
    252 #alias -g Hl=' --help |& less -r'
    253 #alias -g K='|keep'
    254 #alias -g L='|less'
    255 #alias -g LL='|& less -r'
    256 #alias -g M='|most'
    257 #alias -g N='&>/dev/null'
    258 #alias -g R='| tr A-z N-za-m'
    259 #alias -g SL='| sort | less'
    260 #alias -g S='| sort'
    261 #alias -g T='|tail'
    262 #alias -g V='| vim -'
    263 
    264 ## instead of global aliase it might be better to use grmls $abk assoc array, whose contents are expanded after pressing ,.
    265 #$abk[SnL]="| sort -n | less"
    266 
    267 ## get top 10 shell commands:
    268 #alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
    269 
    270 ## Execute \kbd{./configure}
    271 #alias CO="./configure"
    272 
    273 ## Execute \kbd{./configure --help}
    274 #alias CH="./configure --help"
    275 
    276 ## miscellaneous code ##
    277 
    278 ## Use a default width of 80 for manpages for more convenient reading
    279 #export MANWIDTH=${MANWIDTH:-80}
    280 
    281 ## Set a search path for the cd builtin
    282 #cdpath=(.. ~)
    283 
    284 ## variation of our manzsh() function; pick you poison:
    285 #manzsh()  { /usr/bin/man zshall |  most +/"$1" ; }
    286 
    287 ## Switching shell safely and efficiently? http://www.zsh.org/mla/workers/2001/msg02410.html
    288 #bash() {
    289 #    NO_SWITCH="yes" command bash "$@"
    290 #}
    291 #restart () {
    292 #    exec $SHELL $SHELL_ARGS "$@"
    293 #}
    294 
    295 ## Handy functions for use with the (e::) globbing qualifier (like nt)
    296 #contains() { grep -q "$*" $REPLY }
    297 #sameas() { diff -q "$*" $REPLY &>/dev/null }
    298 #ot () { [[ $REPLY -ot ${~1} ]] }
    299 
    300 ## get_ic() - queries imap servers for capabilities; real simple. no imaps
    301 #ic_get() {
    302 #    emulate -L zsh
    303 #    local port
    304 #    if [[ ! -z $1 ]] ; then
    305 #        port=${2:-143}
    306 #        print "querying imap server on $1:${port}...\n";
    307 #        print "a1 capability\na2 logout\n" | nc $1 ${port}
    308 #    else
    309 #        print "usage:\n  $0 <imap-server> [port]"
    310 #    fi
    311 #}
    312 
    313 ## List all occurrences of programm in current PATH
    314 #plap() {
    315 #    emulate -L zsh
    316 #    if [[ $# = 0 ]] ; then
    317 #        echo "Usage:    $0 program"
    318 #        echo "Example:  $0 zsh"
    319 #        echo "Lists all occurrences of program in the current PATH."
    320 #    else
    321 #        ls -l ${^path}/*$1*(*N)
    322 #    fi
    323 #}
    324 
    325 ## Find out which libs define a symbol
    326 #lcheck() {
    327 #    if [[ -n "$1" ]] ; then
    328 #        nm -go /usr/lib/lib*.a 2>/dev/null | grep ":[[:xdigit:]]\{8\} . .*$1"
    329 #    else
    330 #        echo "Usage: lcheck <function>" >&2
    331 #    fi
    332 #}
    333 
    334 ## Download a file and display it locally
    335 #uopen() {
    336 #    emulate -L zsh
    337 #    if ! [[ -n "$1" ]] ; then
    338 #        print "Usage: uopen \$URL/\$file">&2
    339 #        return 1
    340 #    else
    341 #        FILE=$1
    342 #        MIME=$(curl --head $FILE | \
    343 #               grep Content-Type | \
    344 #               cut -d ' ' -f 2 | \
    345 #               cut -d\; -f 1)
    346 #        MIME=${MIME%$'\r'}
    347 #        curl $FILE | see ${MIME}:-
    348 #    fi
    349 #}
    350 
    351 ## Memory overview
    352 #memusage() {
    353 #    ps aux | awk '{if (NR > 1) print $5;
    354 #                   if (NR > 2) print "+"}
    355 #                   END { print "p" }' | dc
    356 #}
    357 
    358 ## print hex value of a number
    359 #hex() {
    360 #    emulate -L zsh
    361 #    if [[ -n "$1" ]]; then
    362 #        printf "%x\n" $1
    363 #    else
    364 #        print 'Usage: hex <number-to-convert>'
    365 #        return 1
    366 #    fi
    367 #}
    368 
    369 ## log out? set timeout in seconds...
    370 ## ...and do not log out in some specific terminals:
    371 #if [[ "${TERM}" == ([Exa]term*|rxvt|dtterm|screen*) ]] ; then
    372 #    unset TMOUT
    373 #else
    374 #    TMOUT=1800
    375 #fi
    376 
    377 ## associate types and extensions (be aware with perl scripts and anwanted behaviour!)
    378 #check_com zsh-mime-setup || { autoload zsh-mime-setup && zsh-mime-setup }
    379 #alias -s pl='perl -S'
    380 
    381 ## ctrl-s will no longer freeze the terminal.
    382 #stty erase "^?"
    383 
    384 ## you want to automatically use a bigger font on big terminals?
    385 #if [[ "$TERM" == "xterm" ]] && [[ "$LINES" -ge 50 ]] && [[ "$COLUMNS" -ge 100 ]] && [[ -z "$SSH_CONNECTION" ]] ; then
    386 #    large
    387 #fi
    388 
    389 ## Some quick Perl-hacks aka /useful/ oneliner
    390 #bew() { perl -le 'print unpack "B*","'$1'"' }
    391 #web() { perl -le 'print pack "B*","'$1'"' }
    392 #hew() { perl -le 'print unpack "H*","'$1'"' }
    393 #weh() { perl -le 'print pack "H*","'$1'"' }
    394 #pversion()    { perl -M$1 -le "print $1->VERSION" } # i. e."pversion LWP -> 5.79"
    395 #getlinks ()   { perl -ne 'while ( m/"((www|ftp|http):\/\/.*?)"/gc ) { print $1, "\n"; }' $* }
    396 #gethrefs ()   { perl -ne 'while ( m/href="([^"]*)"/gc ) { print $1, "\n"; }' $* }
    397 #getanames ()  { perl -ne 'while ( m/a name="([^"]*)"/gc ) { print $1, "\n"; }' $* }
    398 #getforms ()   { perl -ne 'while ( m:(\</?(input|form|select|option).*?\>):gic ) { print $1, "\n"; }' $* }
    399 #getstrings () { perl -ne 'while ( m/"(.*?)"/gc ) { print $1, "\n"; }' $*}
    400 #getanchors () { perl -ne 'while ( m/«([^«»\n]+)»/gc ) { print $1, "\n"; }' $* }
    401 #showINC ()    { perl -e 'for (@INC) { printf "%d %s\n", $i++, $_ }' }
    402 #vimpm ()      { vim `perldoc -l $1 | sed -e 's/pod$/pm/'` }
    403 #vimhelp ()    { vim -c "help $1" -c on -c "au! VimEnter *" }
    404 
    405 ## END OF FILE #################################################################