From e88c9752203b06b2b3a00abca77457479101fea8 Mon Sep 17 00:00:00 2001 From: George Rawlinson Date: Tue, 16 May 2017 07:09:49 +1200 Subject: [PATCH] docs(zsh): include omz plugins plugins: * archlinux * coloured man pages * web search --- zsh/.oh-my-zsh/custom/archlinux.zsh | 42 ++++++++++++++++++++ zsh/.oh-my-zsh/custom/man.zsh | 11 ++++++ zsh/.oh-my-zsh/custom/web-search.zsh | 59 ++++++++++++++++++++++++++++ zsh/.zshrc | 2 +- 4 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 zsh/.oh-my-zsh/custom/archlinux.zsh create mode 100644 zsh/.oh-my-zsh/custom/man.zsh create mode 100644 zsh/.oh-my-zsh/custom/web-search.zsh diff --git a/zsh/.oh-my-zsh/custom/archlinux.zsh b/zsh/.oh-my-zsh/custom/archlinux.zsh new file mode 100644 index 0000000..4736178 --- /dev/null +++ b/zsh/.oh-my-zsh/custom/archlinux.zsh @@ -0,0 +1,42 @@ +# pacaur aliases +if (( $+commands[pacaur] )); then + alias paupg='pacaur -Syua' + alias pasu='pacaur -Syua --noconfirm' + alias pain='pacaur -S' + alias pains='pacaur -U' + alias pare='pacaur -R' + alias parem='pacaur -Rns' + alias parep='pacaur -Si' + alias pareps='pacaur -Ss' + alias paloc='pacaur -Qi' + alias palocs='pacaur -Qs' + alias palst='pacaur -Qe' + alias paorph='pacaur -Qtd' + alias painsd='pacaur -S --asdeps' + alias pamir='pacaur -Syy' +fi + +# pacman aliases +# source: https://wiki.archlinux.org/index.php/Pacman_Tips +alias pacupg='sudo pacman -Syu' +alias pacin='sudo pacman -S' +alias pacins='sudo pacman -U' +alias pacre='sudo pacman -R' +alias pacrem='sudo pacman -Rns' +alias pacrep='pacman -Si' +alias pacreps='pacman -Ss' +alias pacloc='pacman -Qi' +alias paclocs='pacman -Qs' +alias pacinsd='sudo pacman -S --asdeps' +alias pacmir='sudo pacman -Syy' +alias paclsorphans='sudo pacman -Qdt' +alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)' +alias pacfileupg='sudo pacman -Fy' +alias pacfiles='pacman tFs' + +# list all explicitly installed packages +# source: https://bbs.archlinux.org/viewtopic.php?id=93683 +paclist() { + LC_ALL=C pacman -Qei $(pacman -Qu | cut -d " " -f 1) | \ + awk 'BEGIN {FS=":"} /^Name/{printf("\033[1;36m%s\033[1;37m", $2)} /^Description/{print $2}' +} diff --git a/zsh/.oh-my-zsh/custom/man.zsh b/zsh/.oh-my-zsh/custom/man.zsh new file mode 100644 index 0000000..bd222e1 --- /dev/null +++ b/zsh/.oh-my-zsh/custom/man.zsh @@ -0,0 +1,11 @@ +# colour output in man +# source: https://wiki.archlinux.org/index.php/Color_output_in_console#man +man() { + LESS_TERMCAP_md=$'\e[01;31m' \ + LESS_TERMCAP_me=$'\e[0m' \ + LESS_TERMCAP_se=$'\e[0m' \ + LESS_TERMCAP_so=$'\e[01;44;33m' \ + LESS_TERMCAP_ue=$'\e[0m' \ + LESS_TERMCAP_us=$'\e[01;32m' \ + command man "$@" +} diff --git a/zsh/.oh-my-zsh/custom/web-search.zsh b/zsh/.oh-my-zsh/custom/web-search.zsh new file mode 100644 index 0000000..cc970e5 --- /dev/null +++ b/zsh/.oh-my-zsh/custom/web-search.zsh @@ -0,0 +1,59 @@ +# web_search from terminal + +function web_search() { + emulate -L zsh + + # define search engine URLS + typeset -A urls + urls=( + google "https://www.google.com/search?q=" + bing "https://www.bing.com/search?q=" + yahoo "https://search.yahoo.com/search?p=" + duckduckgo "https://www.duckduckgo.com/?q=" + startpage "https://www.startpage.com/do/search?q=" + yandex "https://yandex.ru/yandsearch?text=" + github "https://github.com/search?q=" + baidu "https://www.baidu.com/s?wd=" + ecosia "https://www.ecosia.org/search?q=" + goodreads "https://www.goodreads.com/search?q=" + ) + + # check whether the search engine is supported + if [[ -z "$urls[$1]" ]]; then + echo "Search engine $1 not supported." + return 1 + fi + + # search or go to main page depending on number of arguments passed + if [[ $# -gt 1 ]]; then + # build search url: + # join arguments passed with '+', then append to search engine URL + url="${urls[$1]}${(j:+:)@[2,-1]}" + else + # build main page url: + # split by '/', then rejoin protocol (1) and domain (2) parts with '//' + url="${(j://:)${(s:/:)urls[$1]}[1,2]}" + fi + + open_command "$url" +} + + +alias bing='web_search bing' +alias google='web_search google' +alias yahoo='web_search yahoo' +alias ddg='web_search duckduckgo' +alias sp='web_search startpage' +alias yandex='web_search yandex' +alias github='web_search github' +alias baidu='web_search baidu' +alias ecosia='web_search ecosia' +alias goodreads='web_search goodreads' + +#add your own !bang searches here +alias wiki='web_search duckduckgo \!w' +alias news='web_search duckduckgo \!n' +alias youtube='web_search duckduckgo \!yt' +alias map='web_search duckduckgo \!m' +alias image='web_search duckduckgo \!i' +alias ducky='web_search duckduckgo \!' diff --git a/zsh/.zshrc b/zsh/.zshrc index a7fcec1..4b38fa6 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -9,7 +9,7 @@ DISABLE_UPDATE_PROMPT=true DISABLE_AUTO_UPDATE=true # plugins -plugins=(archlinux common-aliases git sudo ssh-agent rust colored-man-pages gpg-agent web-search) +plugins=(common-aliases git sudo ssh-agent gpg-agent) # zsh-completions autoload -U compinit && compinit