1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 | clear
if [ -f ~/.memo.org ]
then
tail -50 ~/.memo.org;
fi
autoload -U zmv
autoload -Uz compinit && compinit
#EXPORTS
#editor
export VISUAL="emacsclient -nc"
#cdpath
export CDPATH=.:~:~/Courses
#setopts
setopt AUTO_CD
# Path to your oh-my-zsh installation.
export ZSH=~/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="powerlevel9k/powerlevel9k"
export TERM="xterm-256color"
# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(wd sudo zsh-completions z h zsh-autosuggestions colored-man-pages colorize catimg copydir copyfile cp archlinux thefuck web-search extract history fast-syntax-highlighting)
#PLUGINS INCLUDES
#source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source ~/.oh-my-zsh/custom/plugins/zce.zsh/zce.zsh
source ~/.oh-my-zsh/custom/plugins/zsh-autopair/autopair.zsh
source ~/.oh-my-zsh/custom/plugins/calc.plugin.zsh/calc.plugin.zsh
#binkey for "ace jump mode" like plugin in zsh
bindkey "^Xa" zce
source $ZSH/oh-my-zsh.sh
#ALISASES :
alias l=" exa"
alias la=" ls --almost-all"
alias ll=" ls++ --psf"
alias lla=" exa -la"
alias vi="vim"
alias ip=" ip -c address show"
alias duhs=" du -sh * | sort -rh"
alias vtop=" vtop --theme wizard"
#alias emacs="emacsclient -nc"
alias emacsS="emacs"
alias promptreload="source ~/.zshrc"
#alias ls=' ls' #dont put ls in history
alias help="at ~/.memo.org"
alias cat="highlight -lO ansi --force"
alias chmox="chmod +x"
alias meteo=" curl wttr.in/Clermont-Ferrand"
alias javar="java -jar"
alias ping=" ping -c 5"
alias pacman="sudo pacman"
alias lsi="~/.oh-my-zsh/custom/plugins/better-ls/lsicons.py"
alias view="viewnior"
#GIT
alias gcm="git commit -m"
alias ga="git add"
alias gp="git push origin master"
#SCRIPTS
alias todoADD='~/Scripts/todoAdd.sh'
#PIPES ALIASES :
alias -g H='| head'
alias -g T='| tail'
alias -g G='| grep'
alias -g L="| less"
alias -g M="| most"
alias -g B="&|"
alias -g HL="--help"
alias -g LL="2>&1 | less"
alias -g CA="2>&1 | cat -A"
alias -g NE="2> /dev/null"
alias -g NUL="> /dev/null 2>&1"
alias -g LC="| wc -l"
#FILES :
alias -s png="viewnior &"
alias -s PNG="viewnior &"
alias -s jpg="viewnior &"
alias -s JPG="viewnior &"
alias -s jpeg="viewnior &"
alias -s JPEG="viewnior &"
alias -s pdf="qpdfview &"
#CODE :
#alias comp="clear && gcc *.c -o COMP && clear && ./COMP"
#alias comp-ne="clear && gcc *.c -o COMP"
alias comp="clear && clang *.c -o COMP && clear && ./COMP"
alias comp-ne="clear && clang *.c -c COMP"
#PROMPT CONFIG : (for POWERLEVEL9K)
POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR=
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_DISABLE_RPROMPT=true
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time ssh root_indicator dir vcs custom_sep status )
POWERLEVEL9K_ROOT_INDICATOR_FOREGROUND='white'
POWERLEVEL9K_ROOT_INDICATOR_BACKGROUND='160'
POWERLEVEL9K_CONTEXT_DEFAULT_FOREGROUND='white'
POWERLEVEL9K_CONTEXT_DEFAULT_BACKGROUND='088'
POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND='white'
POWERLEVEL9K_CONTEXT_ROOT_BACKGROUND='088'
POWERLEVEL9K_DIR_HOME_FOREGROUND='white'
POWERLEVEL9K_DIR_HOME_BACKGROUND='234'
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND='white'
POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND='235'
POWERLEVEL9K_DIR_DEFAULT_FOREGROUND='white'
POWERLEVEL9K_DIR_DEFAULT_BACKGROUND='234'
POWERLEVEL9K_STATUS_OK_FOREGROUND='070'
POWERLEVEL9K_STATUS_OK_BACKGROUND='237'
POWERLEVEL9K_STATUS_ERROR_FOREGROUND='196'
POWERLEVEL9K_STATUS_ERROR_BACKGROUND='237'
POWERLEVEL9K_VCS_CLEAN_FOREGROUND='white'
POWERLEVEL9K_VCS_CLEAN_BACKGROUND='236'
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX=
POWERLEVEL9K_MULTILINE_SECOND_PROMPT_PREFIX=" ❯ "
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=11
POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=1
POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND='088'
POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND='white'
POWERLEVEL9K_CUSTOM_SEP="echo "
POWERLEVEL9K_CUSTOM_SEP_BACKGROUND='232'
POWERLEVEL9K_CUSTOM_SEP_FOREGROUND='232'
#FUNCTIONS
zman() {
PAGER="less -g -s '+/^ "$1"'" man zshall
}
###### convert seconds to minutes, hours, days, and etc.
# inputs a number of seconds, outputs a string like "2 minutes, 1 second"
# $1: number of seconds
#
function displaytime {
local T=$1
local D=$((T/60/60/24))
local H=$((T/60/60%24))
local M=$((T/60%60))
local S=$((T%60))
[[ $D > 0 ]] && printf '%d days ' $D
[[ $H > 0 ]] && printf '%d hours ' $H
[[ $M > 0 ]] && printf '%d minutes ' $M
[[ $D > 0 || $H > 0 || $M > 0 ]] && printf 'and '
printf '%d seconds\n' $S
}
#Petit hack pour avoir une notification lorsqu'une longue commande
#est terminée, un peu comme avec undistract-me
#http://www.ihashacks.com/blog/2013/01/19/zsh-ified-undistract-me/
# commands to ignore
#
cmdignore=(htop tmux top vim v gst vis ranger mc fish vtop weechat)
# end and compare timer, notify-send if needed
function notifyosd-precmd() {
retval=$?
if [[ ${cmdignore[(r)$cmd_basename]} == $cmd_basename ]]; then
return
else
if [ ! -z "$cmd" ]; then
cmd_end=`date +%s`
((cmd_time=$cmd_end - $cmd_start))
fi
if [ $retval -gt 0 ]; then
cmdstat="with warning"
sndstat="/usr/share/sounds/gnome/default/alerts/sonar.ogg"
else
cmdstat="successfully"
sndstat="/usr/share/sounds/gnome/default/alerts/glass.ogg"
fi
if [ ! -z "$cmd" -a $cmd_time -gt 10 ]; then
if [ -e ~/Scripts/msiNotify.sh ]
then
if [ $retval -gt 0 ]; then
#espeak "fail";
~/Scripts/msiNotify.sh 1;
else
#espeak "success"
~/Scripts/msiNotify.sh 0;
fi
fi
if [ ! -z $SSH_TTY ]
then
#notify-send -i utilities-terminal -u low "$cmd_basename on `hostname` completed $cmdstat" "\"$cmd\" took $cmd_time seconds"; play -q $sndstat
notify-send -i utilities-terminal -u normal "$cmd_basename on `hostname` completed $cmdstat" "\"$cmd\" took `displaytime $cmd_time` return $retval" -t 3000
else
#notify-send -i utilities-terminal -u low "$cmd_basename completed $cmdstat" "\"$cmd\" took $cmd_time seconds"; play -q $sndstat
notify-send -i utilities-terminal -u normal "$cmd_basename completed $cmdstat" "\"$cmd\" took `displaytime $cmd_time` return $retval" -t 3000
fi
fi
unset cmd
fi
}
# make sure this plays nicely with any existing precmd
precmd_functions+=( notifyosd-precmd )
# get command name and start the timer
function notifyosd-preexec() {
cmd=$1
cmd_basename=${${cmd:s/sudo //}[(ws: :)1]}
cmd_start=`date +%s`
}
# make sure this plays nicely with any existing preexec
preexec_functions+=( notifyosd-preexec )
function bak(){
for arg in $*
do
mv $arg $arg.bak;
done
}
function copy(){
#check if buffer exist and create if not
if [ -e /tmp/buffer ]
then
rm /tmp/buffer;
fi
touch /tmp/buffer;
#copy absolute paths in buffer
echo $# > /tmp/buffer;
for arg in $*
do
echo $(pwd)"/"$arg >> /tmp/buffer;
done
}
function glue(){
#init counter
i=0;
#check if buffer exist
if [ ! -f /tmp/buffer ]
then
echo "Nothing to paste...";
exit 1;
fi
#get paths in buffer file and paste in the current repertory
while [ $i -lt $(head -1 /tmp/buffer) ]
do
echo Copying $(sed -n "$(($i+2))"p /tmp/buffer) in $(pwd);
cp -r $(sed -n "$(($i+2))"p /tmp/buffer) .;
let i++;
done
#delete the now useless buffer file
rm /tmp/buffer;
}
# List files in zsh with <TAB>
#
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
# Usage:
# In the middle of the command line:
# (command being typed)<TAB>(resume typing)
#
# At the beginning of the command line:
# <SPACE><TAB>
# <SPACE><SPACE><TAB>
#
# Notes:
# This does not affect other completions
# If you want 'cd ' or './' to be prepended, write in your .zshrc 'export TAB_LIST_FILES_PREFIX'
# I recommend to complement this with push-line-or edit (bindkey '^q' push-line-or-edit)
function tab_list_files
{
if [[ $#BUFFER == 0 ]]; then
BUFFER="ls "
CURSOR=3
zle list-choices
zle backward-kill-word
elif [[ $BUFFER =~ ^[[:space:]][[:space:]].*$ ]]; then
BUFFER="./"
CURSOR=2
zle list-choices
[ -z ${TAB_LIST_FILES_PREFIX+x} ] && BUFFER=" " CURSOR=2
elif [[ $BUFFER =~ ^[[:space:]]*$ ]]; then
BUFFER="cd "
CURSOR=3
zle list-choices
[ -z ${TAB_LIST_FILES_PREFIX+x} ] && BUFFER=" " CURSOR=1
else
BUFFER_=$BUFFER
CURSOR_=$CURSOR
zle expand-or-complete || zle expand-or-complete || {
BUFFER="ls "
CURSOR=3
zle list-choices
BUFFER=$BUFFER_
CURSOR=$CURSOR_
}
fi
}
zle -N tab_list_files
bindkey '^I' tab_list_files
# uncomment the following line to prefix 'cd ' and './'
# when listing dirs and executables respectively
#export TAB_LIST_FILES_PREFIX
# these two lines are usually included by oh-my-zsh, but just in case
#autoload -Uz compinit
#compinit
# uncomment the following line to complement tab_list_files with ^q
#bindkey '^q' push-line-or-edit
# License
#
# This script is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this script; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307 USA
function goHome(){
cd
}
zle -N goHome
bindkey "^H" goHome
command_not_found_handler(){
r=$(shuf -i0-9 -n1);
case $r in
0 )
echo -e '\033[1;31m WTF?! mount /dev/brain ! \033[0m';
;;
1 )
echo -e '\033[1;31m Error 404 ! \033[0m';
;;
2 )
echo -e '\033[1;31m Dude ! Stop try to execute this command... She does NOT exist ! \033[0m';
;;
3 )
echo -e '\033[1;31m No, I dont feel like it. \033[0m';
;;
4 )
echo -e '\033[1;31m You cant force me. \033[0m';
;;
5 )
echo -e '\033[1;31m Command not found ! \033[0m';
;;
6 )
echo -e '\033[1;31m I cant do that... Sorry. \033[0m';
;;
7 )
echo -e '\033[1;31m Nope. \033[0m';
;;
* )
echo -e '\033[1;31m Erm... NO. \033[0m';
;;
esac
return 127;
}
#make a directory and go on it
function mkcd(){
mkdir -p "$@" && eval cd "\"\$$#\"";
}
#transfer files to transfer.sh website
function transfer(){
if [ ! -f ~/.transferShLog ]
then
touch ~/.transferShLog;
fi
if [ $# -eq 0 ]
then
echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md";
return 1;
fi
tmpfile=$( mktemp -t transferXXX );
if tty -s
then
basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g');
curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile;
else
curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ;
fi;
cat $tmpfile >> ~/.transferShLog;
echo -e "\n" >> ~/.transferShLog;
cat $tmpfile; rm -f $tmpfile;
}
#execute "ls" after each "cd"
cdl() {
if [ -n "$1" ]; then
builtin cd "$@" && ls --group-directories-first --color=auto
else
builtin cd ~ && ls --group-directories-first --color=auto
fi
}
#search on youtube
videos() {
search=""
for term in $*; do
search="$search%20$term"
done
xdg-open "http://www.youtube.com/results?search_query=$search"
}
#change randomly wallpaper
wallChange(){
feh --bg-scale ~/Pictures/Wallpapers/$(((RANDOM % $(ls ~/Pictures/Wallpapers/ | wc -l) +1))).jpg;
}
#timer
timer(){
#convert time
m=$(echo $1 | cut -d ":" -f 1);
s=$(echo $1 | cut -d ":" -f 2);
time=$(($m*60 + $s));
echo "Waiting " $time "seconds..." ;
sleep $time | spin;
echo "... end !";
#use msi keyboard led
if [ -f ~/Scripts/msiNotify.sh ]
then
~/Scripts/msiNotify.sh -1;
fi
}
#chrono
chrono(){
#init counter
i=0;
while true
do
echo $i;
let i++;
sleep 1;
clear;
done
}
#better cp command
bcp(){
#get owner of parent dir
parentDirOwner=$(stat -c %U .);
#get current user
user=$(whoami);
if [ $parentDirOwner != $user ]
then
echo -e '\033[1;31m Using sudo ? (y/n) \033[0m';
read yn;
case $yn in
[Yy]*)
if [ -d $1 ]
then
if [ $# = 1 ]
then
sudo cp -r $* .;
else
sudo cp -r $*;
fi
else
if [ $# = 1 ]
then
sudo cp $* .;
else
sudo cp $*;
fi
fi
;;
[Nn]*) echo -e '\033[1;31m Aborted ! \033[0m'; exit 1; ;;
* ) echo -e '\033[1;31m Error, exit. \033[0m'; exit 1; ;;
esac
else
if [ -d $1 ]
then
if [ $# = 1 ]
then
cp -r $* .;
else
cp -r $*;
fi
else
if [ $# = 1 ]
then
cp $* .;
else
cp $*;
fi
fi
fi
}
#better mv command
bmv(){
#get owner of current dir
dirOwner=$(stat -c %U .);
#get current user
user=$(whoami);
if [ $dirOwner != $user ]
then
echo -e '\033[1;31m Using sudo ? (y/n) \033[0m';
read yn;
case $yn in
[Yy]*) sudo mv $*; ;;
[Nn]*) echo -e '\033[1;31m Aborted ! \033[0m'; exit 1; ;;
* ) echo -e '\033[1;31m Error, exit. \033[0m'; exit 1; ;;
esac
else
mv $*;
fi
}
#better rm command
brm(){
#get owner of parent dir
parentDirOwner=$(stat -c %U .);
#get current user
user=$(whoami);
if [ $parentDirOwner != $user ]
then
echo -e '\033[1;31m Using sudo ? (y/n) \033[0m';
read yn;
case $yn in
[Yy]*)
if [ -d $1 ]
then
sudo rm -rf $*;
else
sudo rm $*;
fi
;;
[Nn]*) echo -e '\033[1;31m Aborted ! \033[0m'; exit 1; ;;
* ) echo -e '\033[1;31m Error, exit. \033[0m'; exit 1; ;;
esac
else
if [ -d $1 ]
then
rm -rf $*;
else
rm $*;
fi
fi
}
|
x
Notes
Here is my zshrc
There is some useful zsh plugins:
- wd
- sudo
- zsh-completions
- z
- h
- zsh-autosuggestions
- colored-man-pages
- colorize
- catimg
- copydir
- copyfile
- cp
- archlinux
- thefuck
- web-search
- extract
- history
- fast-syntax-highlighting
Get my dotfiles here
penguin said about 7 years ago
I guess I have to install the whole powerlevel9k just to get the prompt? ‘over 600 lines for a 1%6 of a line
And he has so manplugins so to sopy ecaxt this will take days -