Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BASH=/bin/bash
- BASHOPTS=checkwinsize:cmdhist:complete_fullquote:expand_aliases:extglob:extquote:force_fignore:globasciiranges:histappend:interactive_comments:progcomp:promptvars:sourcepath
- BASH_ALIASES=()
- BASH_ARGC=([0]="0")
- BASH_ARGV=()
- BASH_CMDS=()
- BASH_COMPLETION_VERSINFO=([0]="2" [1]="8")
- BASH_LINENO=()
- BASH_SOURCE=()
- BASH_VERSINFO=([0]="5" [1]="0" [2]="3" [3]="1" [4]="release" [5]="arm-unknown-linux-gnueabihf")
- BASH_VERSION='5.0.3(1)-release'
- COLORTERM=truecolor
- COLUMNS=80
- DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
- DESKTOP_SESSION=LXDE-pi
- DIRSTACK=()
- DISPLAY=:0.0
- EUID=1000
- GDMSESSION=lightdm-xsession
- GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
- GROUPS=()
- HISTCONTROL=ignoreboth
- HISTFILE=/home/pi/.bash_history
- HISTFILESIZE=2000
- HISTSIZE=1000
- HOME=/home/pi
- HOSTNAME=raspberrypi
- HOSTTYPE=arm
- IFS=$' \t\n'
- LANG=hu_HU.UTF-8
- LANGUAGE=hu_HU.UTF-8
- LC_ALL=hu_HU.UTF-8
- LINES=24
- LOGNAME=pi
- LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:'
- MACHTYPE=arm-unknown-linux-gnueabihf
- MAILCHECK=60
- NO_AT_BRIDGE=1
- OPTERR=1
- OPTIND=1
- OSTYPE=linux-gnueabihf
- PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
- PIPESTATUS=([0]="0")
- PPID=3625
- PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \$\[\033[00m\] '
- PS2='> '
- PS4='+ '
- PWD=/home/pi
- QT_QPA_PLATFORMTHEME=qt5ct
- RC=0
- SAL_USE_VCLPLUGIN=gtk3
- SHELL=/bin/bash
- SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
- SHLVL=1
- SSH_AGENT_PID=666
- SSH_AUTH_SOCK=/tmp/ssh-eGvJdWEfuX9g/agent.583
- TERM=xterm-256color
- TEXTDOMAIN=Linux-PAM
- UID=1000
- USER=pi
- VIRTUALENVWRAPPER_ENV_BIN_DIR=bin
- VIRTUALENVWRAPPER_HOOK_DIR=/home/pi/.virtualenvs
- VIRTUALENVWRAPPER_PROJECT_FILENAME=.project
- VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
- VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
- VIRTUALENVWRAPPER_VIRTUALENV=virtualenv
- VIRTUALENVWRAPPER_VIRTUALENV_CLONE=virtualenv-clone
- VIRTUALENVWRAPPER_WORKON_CD=1
- VTE_VERSION=5402
- WORKON_HOME=/home/pi/.virtualenvs
- XAUTHORITY=/home/pi/.Xauthority
- XDG_CONFIG_DIRS=/etc/xdg
- XDG_CONFIG_HOME=/home/pi/.config
- XDG_CURRENT_DESKTOP=LXDE
- XDG_DATA_DIRS=/usr/share/fkms:/usr/local/share:/usr/share/raspi-ui-overrides:/usr/share:/usr/share/gdm:/var/lib/menu-xdg
- XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/pi
- XDG_MENU_PREFIX=lxde-pi-
- XDG_RUNTIME_DIR=/run/user/1000
- XDG_SEAT=seat0
- XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
- XDG_SESSION_CLASS=user
- XDG_SESSION_DESKTOP=lightdm-xsession
- XDG_SESSION_ID=c1
- XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
- XDG_SESSION_TYPE=x11
- XDG_VTNR=7
- _=./testing.sh
- _LXSESSION_PID=583
- __git_printf_supports_v=yes
- _backup_glob='@(#*#|*@(~|.@(bak|orig|rej|swp|dpkg*|rpm@(orig|new|save))))'
- _xspecs=([lokalize]="!*.po" [acroread]="!*.[pf]df" [lbzcat]="!*.?(t)bz?(2)" [mpg321]="!*.mp3" [bzcat]="!*.?(t)bz?(2)" [oocalc]="!*.@(sxc|stc|xls?([bmx])|xlw|xlt?([mx])|[ct]sv|?(f)ods|ots)" [tex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [unlzma]="!*.@(tlz|lzma)" [sxemacs]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [aviplay]="!*.@(avi|asf|wmv)" [lbunzip2]="!*.?(t)bz?(2)" [dragon]="!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmvx]|OG[AGMVX]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM|iso|ISO)|+([0-9]).@(vdr|VDR))?(.part)" [freeamp]="!*.@(mp3|og[ag]|pls|m3u)" [rgvim]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [ooimpress]="!*.@(sxi|sti|pps?(x)|ppt?([mx])|pot?([mx])|?(f)odp|otp)" [gqmpeg]="!*.@(mp3|og[ag]|pls|m3u)" [texi2html]="!*.texi*" [hbpp]="!*.@([Pp][Rr][Gg]|[Cc][Ll][Pp])" [lowriter]="!*.@(sxw|stw|sxg|sgl|doc?([mx])|dot?([mx])|rtf|txt|htm|html|?(f)odt|ott|odm|pdf)" [qiv]="!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|svg)" [xanim]="!*.@(mpg|mpeg|avi|mov|qt)" [ps2pdfwr]="!*.@(?(e)ps|pdf)" [harbour]="!*.@([Pp][Rr][Gg]|[Cc][Ll][Pp])" [jadetex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [lodraw]="!*.@(sxd|std|sda|sdd|?(f)odg|otg)" [dvitype]="!*.dvi" [lobase]="!*.odb" [rpm2cpio]="!*.[rs]pm" [xine]="!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmvx]|OG[AGMVX]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM)|+([0-9]).@(vdr|VDR))?(.part)" [lualatex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [localc]="!*.@(sxc|stc|xls?([bmx])|xlw|xlt?([mx])|[ct]sv|?(f)ods|ots)" [hbrun]="!*.[Hh][Rr][Bb]" [amaya]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [gv]="!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))" [unpigz]="!*.@(Z|[gGdz]z|t[ag]z)" [mozilla]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [epdfview]="!*.pdf" [dvips]="!*.dvi" [pdfunite]="!*.pdf" [ps2pdf14]="!*.@(?(e)ps|pdf)" [kid3]="!*.@(mp[234c]|og[ag]|@(fl|a)ac|m4[abp]|spx|tta|w?(a)v|wma|aif?(f)|asf|ape)" [vi]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [ps2pdf]="!*.@(?(e)ps|pdf)" [gpdf]="!*.[pf]df" [lilypond]="!*.ly" [texi2dvi]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [modplug123]="!*.@(669|abc|am[fs]|d[bs]m|dmf|far|it|mdl|m[eo]d|mid?(i)|mt[2m]|oct|okt?(a)|p[st]m|s[3t]m|ult|umx|wav|xm)" [znew]="*.Z" [ps2pdf13]="!*.@(?(e)ps|pdf)" [ps2pdf12]="!*.@(?(e)ps|pdf)" [kwrite]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [latex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [kate]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [pbzcat]="!*.?(t)bz?(2)" [poedit]="!*.po" [view]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [firefox]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL])|[pP][dD][fF])" [mozilla-firefox]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL])|[pP][dD][fF])" [kid3-qt]="!*.@(mp[234c]|og[ag]|@(fl|a)ac|m4[abp]|spx|tta|w?(a)v|wma|aif?(f)|asf|ape)" [luatex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [bunzip2]="!*.?(t)bz?(2)" [chromium-browser]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL])|[pP][dD][fF])" [dvipdfm]="!*.dvi" [kbabel]="!*.po" [ly2dvi]="!*.ly" [oodraw]="!*.@(sxd|std|sda|sdd|?(f)odg|otg)" [bzme]="!*.@(zip|z|gz|tgz)" [rgview]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [pdftex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [xemacs]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [zathura]="!*.@(cb[rz7t]|djv?(u)|?(e)ps|pdf)" [unxz]="!*.@(?(t)xz|tlz|lzma)" [rvim]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [madplay]="!*.mp3" [xetex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [gvim]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [kaffeine]="!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmvx]|OG[AGMVX]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM|iso|ISO)|+([0-9]).@(vdr|VDR))?(.part)" [dviselect]="!*.dvi" [kpdf]="!*.@(?(e)ps|pdf)" [bibtex]="!*.aux" [realplay]="!*.@(rm?(j)|ra?(m)|smi?(l))" [mpg123]="!*.mp3" [netscape]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [lzegrep]="!*.@(tlz|lzma)" [gview]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [kdvi]="!*.@(dvi|DVI)?(.@(gz|Z|bz2))" [xv]="!*.@(gif|jp?(e)g?(2)|j2[ck]|jp[2f]|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|?(e)ps)" [lzfgrep]="!*.@(tlz|lzma)" [playmidi]="!*.@(mid?(i)|cmf)" [lzless]="!*.@(tlz|lzma)" [elinks]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [timidity]="!*.@(mid?(i)|rmi|rcp|[gr]36|g18|mod|xm|it|x3m|s[3t]m|kar)" [xdvi]="!*.@(dvi|DVI)?(.@(gz|Z|bz2))" [xfig]="!*.fig" [xpdf]="!*.@(pdf|fdf)?(.@(gz|GZ|bz2|BZ2|Z))" [lomath]="!*.@(sxm|smf|mml|odf)" [lzcat]="!*.@(tlz|lzma)" [compress]="*.Z" [pdfjadetex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [kghostview]="!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))" [zcat]="!*.@(Z|[gGd]z|t[ag]z)" [pbunzip2]="!*.?(t)bz?(2)" [oobase]="!*.odb" [cdiff]="!*.@(dif?(f)|?(d)patch)?(.@([gx]z|bz2|lzma))" [iceweasel]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL])|[pP][dD][fF])" [gtranslator]="!*.po" [lynx]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [emacs]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [zipinfo]="!*.@(zip|[egjsw]ar|exe|pk3|wsz|zargo|xpi|s[tx][cdiw]|sx[gm]|o[dt][tspgfc]|od[bm]|oxt|epub|apk|ipa|do[ct][xm]|p[op]t[mx]|xl[st][xm]|pyz)" [google-chrome]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL])|[pP][dD][fF])" [xelatex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [uncompress]="!*.Z" [xzcat]="!*.@(?(t)xz|tlz|lzma)" [unzip]="!*.@(zip|[egjsw]ar|exe|pk3|wsz|zargo|xpi|s[tx][cdiw]|sx[gm]|o[dt][tspgfc]|od[bm]|oxt|epub|apk|ipa|do[ct][xm]|p[op]t[mx]|xl[st][xm]|pyz)" [rview]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [ogg123]="!*.@(og[ag]|m3u|flac|spx)" [lrunzip]="!*.lrz" [lzgrep]="!*.@(tlz|lzma)" [slitex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [vim]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [ggv]="!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))" [ee]="!*.@(gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx)" [oomath]="!*.@(sxm|smf|mml|odf)" [aaxine]="!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmvx]|OG[AGMVX]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM)|+([0-9]).@(vdr|VDR))?(.part)" [dvipdfmx]="!*.dvi" [advi]="!*.dvi" [gunzip]="!*.@(Z|[gGd]z|t[ag]z)" [makeinfo]="!*.texi*" [gharbour]="!*.@([Pp][Rr][Gg]|[Cc][Ll][Pp])" [okular]="!*.@(okular|@(?(e|x)ps|?(E|X)PS|[pf]df|[PF]DF|dvi|DVI|cb[rz]|CB[RZ]|djv?(u)|DJV?(U)|dvi|DVI|gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx|GIF|JP?(E)G|MIFF|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA|PCX|epub|EPUB|odt|ODT|fb?(2)|FB?(2)|mobi|MOBI|g3|G3|chm|CHM)?(.?(gz|GZ|bz2|BZ2)))" [galeon]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [pdflatex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [lzmore]="!*.@(tlz|lzma)" [portecle]="!@(*.@(ks|jks|jceks|p12|pfx|bks|ubr|gkr|cer|crt|cert|p7b|pkipath|pem|p10|csr|crl)|cacerts)" [oowriter]="!*.@(sxw|stw|sxg|sgl|doc?([mx])|dot?([mx])|rtf|txt|htm|html|?(f)odt|ott|odm|pdf)" [loimpress]="!*.@(sxi|sti|pps?(x)|ppt?([mx])|pot?([mx])|?(f)odp|otp)" [epiphany]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [modplugplay]="!*.@(669|abc|am[fs]|d[bs]m|dmf|far|it|mdl|m[eo]d|mid?(i)|mt[2m]|oct|okt?(a)|p[st]m|s[3t]m|ult|umx|wav|xm)" [dvipdf]="!*.dvi" [dillo]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [fbxine]="!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmvx]|OG[AGMVX]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM)|+([0-9]).@(vdr|VDR))?(.part)" )
- __expand_tilde_by_ref ()
- {
- if [[ ${!1} == \~* ]]; then
- eval $1=$(printf ~%q "${!1#\~}");
- fi
- }
- __get_cword_at_cursor_by_ref ()
- {
- local cword words=();
- __reassemble_comp_words_by_ref "$1" words cword;
- local i cur index=$COMP_POINT lead=${COMP_LINE:0:$COMP_POINT};
- if [[ $index -gt 0 && ( -n $lead && -n ${lead//[[:space:]]} ) ]]; then
- cur=$COMP_LINE;
- for ((i = 0; i <= cword; ++i ))
- do
- while [[ ${#cur} -ge ${#words[i]} && "${cur:0:${#words[i]}}" != "${words[i]}" ]]; do
- cur="${cur:1}";
- [[ $index -gt 0 ]] && ((index--));
- done;
- if [[ $i -lt $cword ]]; then
- local old_size=${#cur};
- cur="${cur#"${words[i]}"}";
- local new_size=${#cur};
- index=$(( index - old_size + new_size ));
- fi;
- done;
- [[ -n $cur && ! -n ${cur//[[:space:]]} ]] && cur=;
- [[ $index -lt 0 ]] && index=0;
- fi;
- local "$2" "$3" "$4" && _upvars -a${#words[@]} $2 "${words[@]}" -v $3 "$cword" -v $4 "${cur:0:$index}"
- }
- __git_eread ()
- {
- test -r "$1" && IFS='
- ' read "$2" < "$1"
- }
- __git_ps1 ()
- {
- local exit=$?;
- local pcmode=no;
- local detached=no;
- local ps1pc_start='\u@\h:\w ';
- local ps1pc_end='\$ ';
- local printf_format=' (%s)';
- case "$#" in
- 2 | 3)
- pcmode=yes;
- ps1pc_start="$1";
- ps1pc_end="$2";
- printf_format="${3:-$printf_format}";
- PS1="$ps1pc_start$ps1pc_end"
- ;;
- 0 | 1)
- printf_format="${1:-$printf_format}"
- ;;
- *)
- return $exit
- ;;
- esac;
- local ps1_expanded=yes;
- [ -z "${ZSH_VERSION-}" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no;
- [ -z "${BASH_VERSION-}" ] || shopt -q promptvars || ps1_expanded=no;
- local repo_info rev_parse_exit_code;
- repo_info="$(git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree --short HEAD 2>/dev/null)";
- rev_parse_exit_code="$?";
- if [ -z "$repo_info" ]; then
- return $exit;
- fi;
- local short_sha="";
- if [ "$rev_parse_exit_code" = "0" ]; then
- short_sha="${repo_info##*
- }";
- repo_info="${repo_info%
- *}";
- fi;
- local inside_worktree="${repo_info##*
- }";
- repo_info="${repo_info%
- *}";
- local bare_repo="${repo_info##*
- }";
- repo_info="${repo_info%
- *}";
- local inside_gitdir="${repo_info##*
- }";
- local g="${repo_info%
- *}";
- if [ "true" = "$inside_worktree" ] && [ -n "${GIT_PS1_HIDE_IF_PWD_IGNORED-}" ] && [ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] && git check-ignore -q .; then
- return $exit;
- fi;
- local r="";
- local b="";
- local step="";
- local total="";
- if [ -d "$g/rebase-merge" ]; then
- __git_eread "$g/rebase-merge/head-name" b;
- __git_eread "$g/rebase-merge/msgnum" step;
- __git_eread "$g/rebase-merge/end" total;
- if [ -f "$g/rebase-merge/interactive" ]; then
- r="|REBASE-i";
- else
- r="|REBASE-m";
- fi;
- else
- if [ -d "$g/rebase-apply" ]; then
- __git_eread "$g/rebase-apply/next" step;
- __git_eread "$g/rebase-apply/last" total;
- if [ -f "$g/rebase-apply/rebasing" ]; then
- __git_eread "$g/rebase-apply/head-name" b;
- r="|REBASE";
- else
- if [ -f "$g/rebase-apply/applying" ]; then
- r="|AM";
- else
- r="|AM/REBASE";
- fi;
- fi;
- else
- if [ -f "$g/MERGE_HEAD" ]; then
- r="|MERGING";
- else
- if [ -f "$g/CHERRY_PICK_HEAD" ]; then
- r="|CHERRY-PICKING";
- else
- if [ -f "$g/REVERT_HEAD" ]; then
- r="|REVERTING";
- else
- if [ -f "$g/BISECT_LOG" ]; then
- r="|BISECTING";
- fi;
- fi;
- fi;
- fi;
- fi;
- if [ -n "$b" ]; then
- :;
- else
- if [ -h "$g/HEAD" ]; then
- b="$(git symbolic-ref HEAD 2>/dev/null)";
- else
- local head="";
- if ! __git_eread "$g/HEAD" head; then
- return $exit;
- fi;
- b="${head#ref: }";
- if [ "$head" = "$b" ]; then
- detached=yes;
- b="$(
- case "${GIT_PS1_DESCRIBE_STYLE-}" in
- (contains)
- git describe --contains HEAD ;;
- (branch)
- git describe --contains --all HEAD ;;
- (tag)
- git describe --tags HEAD ;;
- (describe)
- git describe HEAD ;;
- (* | default)
- git describe --tags --exact-match HEAD ;;
- esac 2>/dev/null)" || b="$short_sha...";
- b="($b)";
- fi;
- fi;
- fi;
- fi;
- if [ -n "$step" ] && [ -n "$total" ]; then
- r="$r $step/$total";
- fi;
- local w="";
- local i="";
- local s="";
- local u="";
- local c="";
- local p="";
- if [ "true" = "$inside_gitdir" ]; then
- if [ "true" = "$bare_repo" ]; then
- c="BARE:";
- else
- b="GIT_DIR!";
- fi;
- else
- if [ "true" = "$inside_worktree" ]; then
- if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] && [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
- git diff --no-ext-diff --quiet || w="*";
- git diff --no-ext-diff --cached --quiet || i="+";
- if [ -z "$short_sha" ] && [ -z "$i" ]; then
- i="#";
- fi;
- fi;
- if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] && git rev-parse --verify --quiet refs/stash > /dev/null; then
- s="$";
- fi;
- if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] && [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] && git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- ':/*' > /dev/null 2> /dev/null; then
- u="%${ZSH_VERSION+%}";
- fi;
- if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
- __git_ps1_show_upstream;
- fi;
- fi;
- fi;
- local z="${GIT_PS1_STATESEPARATOR-" "}";
- if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
- __git_ps1_colorize_gitstring;
- fi;
- b=${b##refs/heads/};
- if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
- __git_ps1_branch_name=$b;
- b="\${__git_ps1_branch_name}";
- fi;
- local f="$w$i$s$u";
- local gitstring="$c$b${f:+$z$f}$r$p";
- if [ $pcmode = yes ]; then
- if [ "${__git_printf_supports_v-}" != yes ]; then
- gitstring=$(printf -- "$printf_format" "$gitstring");
- else
- printf -v gitstring -- "$printf_format" "$gitstring";
- fi;
- PS1="$ps1pc_start$gitstring$ps1pc_end";
- else
- printf -- "$printf_format" "$gitstring";
- fi;
- return $exit
- }
- __git_ps1_colorize_gitstring ()
- {
- if [[ -n ${ZSH_VERSION-} ]]; then
- local c_red='%F{red}';
- local c_green='%F{green}';
- local c_lblue='%F{blue}';
- local c_clear='%f';
- else
- local c_red='\[\e[31m\]';
- local c_green='\[\e[32m\]';
- local c_lblue='\[\e[1;34m\]';
- local c_clear='\[\e[0m\]';
- fi;
- local bad_color=$c_red;
- local ok_color=$c_green;
- local flags_color="$c_lblue";
- local branch_color="";
- if [ $detached = no ]; then
- branch_color="$ok_color";
- else
- branch_color="$bad_color";
- fi;
- c="$branch_color$c";
- z="$c_clear$z";
- if [ "$w" = "*" ]; then
- w="$bad_color$w";
- fi;
- if [ -n "$i" ]; then
- i="$ok_color$i";
- fi;
- if [ -n "$s" ]; then
- s="$flags_color$s";
- fi;
- if [ -n "$u" ]; then
- u="$bad_color$u";
- fi;
- r="$c_clear$r"
- }
- __git_ps1_show_upstream ()
- {
- local key value;
- local svn_remote svn_url_pattern count n;
- local upstream=git legacy="" verbose="" name="";
- svn_remote=();
- local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')";
- while read -r key value; do
- case "$key" in
- bash.showupstream)
- GIT_PS1_SHOWUPSTREAM="$value";
- if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
- p="";
- return;
- fi
- ;;
- svn-remote.*.url)
- svn_remote[$((${#svn_remote[@]} + 1))]="$value";
- svn_url_pattern="$svn_url_pattern\\|$value";
- upstream=svn+git
- ;;
- esac;
- done <<< "$output";
- for option in ${GIT_PS1_SHOWUPSTREAM};
- do
- case "$option" in
- git | svn)
- upstream="$option"
- ;;
- verbose)
- verbose=1
- ;;
- legacy)
- legacy=1
- ;;
- name)
- name=1
- ;;
- esac;
- done;
- case "$upstream" in
- git)
- upstream="@{upstream}"
- ;;
- svn*)
- local -a svn_upstream;
- svn_upstream=($(git log --first-parent -1 --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null));
- if [[ 0 -ne ${#svn_upstream[@]} ]]; then
- svn_upstream=${svn_upstream[${#svn_upstream[@]} - 2]};
- svn_upstream=${svn_upstream%@*};
- local n_stop="${#svn_remote[@]}";
- for ((n=1; n <= n_stop; n++))
- do
- svn_upstream=${svn_upstream#${svn_remote[$n]}};
- done;
- if [[ -z "$svn_upstream" ]]; then
- upstream=${GIT_SVN_ID:-git-svn};
- else
- upstream=${svn_upstream#/};
- fi;
- else
- if [[ "svn+git" = "$upstream" ]]; then
- upstream="@{upstream}";
- fi;
- fi
- ;;
- esac;
- if [[ -z "$legacy" ]]; then
- count="$(git rev-list --count --left-right "$upstream"...HEAD 2>/dev/null)";
- else
- local commits;
- if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)"; then
- local commit behind=0 ahead=0;
- for commit in $commits;
- do
- case "$commit" in
- "<"*)
- ((behind++))
- ;;
- *)
- ((ahead++))
- ;;
- esac;
- done;
- count="$behind $ahead";
- else
- count="";
- fi;
- fi;
- if [[ -z "$verbose" ]]; then
- case "$count" in
- "")
- p=""
- ;;
- "0 0")
- p="="
- ;;
- "0 "*)
- p=">"
- ;;
- *" 0")
- p="<"
- ;;
- *)
- p="<>"
- ;;
- esac;
- else
- case "$count" in
- "")
- p=""
- ;;
- "0 0")
- p=" u="
- ;;
- "0 "*)
- p=" u+${count#0 }"
- ;;
- *" 0")
- p=" u-${count% 0}"
- ;;
- *)
- p=" u+${count#* }-${count% *}"
- ;;
- esac;
- if [[ -n "$count" && -n "$name" ]]; then
- __git_ps1_upstream_name=$(git rev-parse --abbrev-ref "$upstream" 2>/dev/null);
- if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
- p="$p \${__git_ps1_upstream_name}";
- else
- p="$p ${__git_ps1_upstream_name}";
- unset __git_ps1_upstream_name;
- fi;
- fi;
- fi
- }
- __load_completion ()
- {
- local -a dirs=(${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions);
- local OIFS=$IFS IFS=: dir cmd="${1##*/}" compfile;
- [[ -n $cmd ]] || return 1;
- for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share};
- do
- dirs+=($dir/bash-completion/completions);
- done;
- IFS=$OIFS;
- if [[ $BASH_SOURCE == */* ]]; then
- dirs+=("${BASH_SOURCE%/*}/completions");
- else
- dirs+=(./completions);
- fi;
- for dir in "${dirs[@]}";
- do
- for compfile in "$cmd" "$cmd.bash" "_$cmd";
- do
- compfile="$dir/$compfile";
- [[ -f "$compfile" ]] && . "$compfile" &> /dev/null && return 0;
- done;
- done;
- [[ -n "${_xspecs[$cmd]}" ]] && complete -F _filedir_xspec "$cmd" && return 0;
- return 1
- }
- __ltrim_colon_completions ()
- {
- if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then
- local colon_word=${1%"${1##*:}"};
- local i=${#COMPREPLY[*]};
- while [[ $((--i)) -ge 0 ]]; do
- COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"};
- done;
- fi
- }
- __parse_options ()
- {
- local option option2 i IFS='
- ,/|';
- option=;
- local -a array;
- read -a array <<< "$1";
- for i in "${array[@]}";
- do
- case "$i" in
- ---*)
- break
- ;;
- --?*)
- option=$i;
- break
- ;;
- -?*)
- [[ -n $option ]] || option=$i
- ;;
- *)
- break
- ;;
- esac;
- done;
- [[ -n $option ]] || return;
- IFS='
- ';
- if [[ $option =~ (\[((no|dont)-?)\]). ]]; then
- option2=${option/"${BASH_REMATCH[1]}"/};
- option2=${option2%%[<{().[]*};
- printf '%s\n' "${option2/=*/=}";
- option=${option/"${BASH_REMATCH[1]}"/"${BASH_REMATCH[2]}"};
- fi;
- option=${option%%[<{().[]*};
- printf '%s\n' "${option/=*/=}"
- }
- __reassemble_comp_words_by_ref ()
- {
- local exclude i j line ref;
- if [[ -n $1 ]]; then
- exclude="${1//[^$COMP_WORDBREAKS]}";
- fi;
- printf -v "$3" %s "$COMP_CWORD";
- if [[ -n $exclude ]]; then
- line=$COMP_LINE;
- for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++))
- do
- while [[ $i -gt 0 && ${COMP_WORDS[$i]} == +([$exclude]) ]]; do
- [[ $line != [[:blank:]]* ]] && (( j >= 2 )) && ((j--));
- ref="$2[$j]";
- printf -v "$ref" %s "${!ref}${COMP_WORDS[i]}";
- [[ $i == $COMP_CWORD ]] && printf -v "$3" %s "$j";
- line=${line#*"${COMP_WORDS[$i]}"};
- [[ $line == [[:blank:]]* ]] && ((j++));
- (( $i < ${#COMP_WORDS[@]} - 1)) && ((i++)) || break 2;
- done;
- ref="$2[$j]";
- printf -v "$ref" %s "${!ref}${COMP_WORDS[i]}";
- line=${line#*"${COMP_WORDS[i]}"};
- [[ $i == $COMP_CWORD ]] && printf -v "$3" %s "$j";
- done;
- [[ $i == $COMP_CWORD ]] && printf -v "$3" %s "$j";
- else
- for i in ${!COMP_WORDS[@]};
- do
- printf -v "$2[i]" %s "${COMP_WORDS[i]}";
- done;
- fi
- }
- _allowed_groups ()
- {
- if _complete_as_root; then
- local IFS='
- ';
- COMPREPLY=($( compgen -g -- "$1" ));
- else
- local IFS='
- ';
- COMPREPLY=($( compgen -W "$( id -Gn 2>/dev/null || groups 2>/dev/null )" -- "$1" ));
- fi
- }
- _allowed_users ()
- {
- if _complete_as_root; then
- local IFS='
- ';
- COMPREPLY=($( compgen -u -- "${1:-$cur}" ));
- else
- local IFS='
- ';
- COMPREPLY=($( compgen -W "$( id -un 2>/dev/null || whoami 2>/dev/null )" -- "${1:-$cur}" ));
- fi
- }
- _available_interfaces ()
- {
- local PATH=$PATH:/sbin;
- COMPREPLY=($( {
- if [[ ${1:-} == -w ]]; then
- iwconfig
- elif [[ ${1:-} == -a ]]; then
- ifconfig || ip link show up
- else
- ifconfig -a || ip link show
- fi
- } 2>/dev/null | awk '/^[^ \t]/ { if ($1 ~ /^[0-9]+:/) { print $2 } else { print $1 } }' ));
- COMPREPLY=($( compgen -W '${COMPREPLY[@]/%[[:punct:]]/}' -- "$cur" ))
- }
- _cd ()
- {
- local cur prev words cword;
- _init_completion || return;
- local IFS='
- ' i j k;
- compopt -o filenames;
- if [[ -z "${CDPATH:-}" || "$cur" == ?(.)?(.)/* ]]; then
- _filedir -d;
- return;
- fi;
- local -r mark_dirs=$(_rl_enabled mark-directories && echo y);
- local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y);
- for i in ${CDPATH//:/'
- '};
- do
- k="${#COMPREPLY[@]}";
- for j in $( compgen -d -- $i/$cur );
- do
- if [[ ( -n $mark_symdirs && -h $j || -n $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then
- j+="/";
- fi;
- COMPREPLY[k++]=${j#$i/};
- done;
- done;
- _filedir -d;
- if [[ ${#COMPREPLY[@]} -eq 1 ]]; then
- i=${COMPREPLY[0]};
- if [[ "$i" == "$cur" && $i != "*/" ]]; then
- COMPREPLY[0]="${i}/";
- fi;
- fi;
- return
- }
- _cd_devices ()
- {
- COMPREPLY+=($( compgen -f -d -X "!*/?([amrs])cd*" -- "${cur:-/dev/}" ))
- }
- _cdsitepackages_complete ()
- {
- local cur="$2";
- COMPREPLY=($(cdsitepackages && compgen -d -- "${cur}" ))
- }
- _cdvirtualenv_complete ()
- {
- local cur="$2";
- COMPREPLY=($(cdvirtualenv && compgen -d -- "${cur}" ))
- }
- _command ()
- {
- local offset i;
- offset=1;
- for ((i=1; i <= COMP_CWORD; i++ ))
- do
- if [[ "${COMP_WORDS[i]}" != -* ]]; then
- offset=$i;
- break;
- fi;
- done;
- _command_offset $offset
- }
- _command_offset ()
- {
- local word_offset=$1 i j;
- for ((i=0; i < $word_offset; i++ ))
- do
- for ((j=0; j <= ${#COMP_LINE}; j++ ))
- do
- [[ "$COMP_LINE" == "${COMP_WORDS[i]}"* ]] && break;
- COMP_LINE=${COMP_LINE:1};
- ((COMP_POINT--));
- done;
- COMP_LINE=${COMP_LINE#"${COMP_WORDS[i]}"};
- ((COMP_POINT-=${#COMP_WORDS[i]}));
- done;
- for ((i=0; i <= COMP_CWORD - $word_offset; i++ ))
- do
- COMP_WORDS[i]=${COMP_WORDS[i+$word_offset]};
- done;
- for ((i; i <= COMP_CWORD; i++ ))
- do
- unset 'COMP_WORDS[i]';
- done;
- ((COMP_CWORD -= $word_offset));
- COMPREPLY=();
- local cur;
- _get_comp_words_by_ref cur;
- if [[ $COMP_CWORD -eq 0 ]]; then
- local IFS='
- ';
- compopt -o filenames;
- COMPREPLY=($( compgen -d -c -- "$cur" ));
- else
- local cmd=${COMP_WORDS[0]} compcmd=${COMP_WORDS[0]};
- local cspec=$( complete -p $cmd 2>/dev/null );
- if [[ ! -n $cspec && $cmd == */* ]]; then
- cspec=$( complete -p ${cmd##*/} 2>/dev/null );
- [[ -n $cspec ]] && compcmd=${cmd##*/};
- fi;
- if [[ ! -n $cspec ]]; then
- compcmd=${cmd##*/};
- _completion_loader $compcmd;
- cspec=$( complete -p $compcmd 2>/dev/null );
- fi;
- if [[ -n $cspec ]]; then
- if [[ ${cspec#* -F } != $cspec ]]; then
- local func=${cspec#*-F };
- func=${func%% *};
- if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then
- $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" "${COMP_WORDS[${#COMP_WORDS[@]}-2]}";
- else
- $func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}";
- fi;
- local opt;
- while [[ $cspec == *" -o "* ]]; do
- cspec=${cspec#*-o };
- opt=${cspec%% *};
- compopt -o $opt;
- cspec=${cspec#$opt};
- done;
- else
- cspec=${cspec#complete};
- cspec=${cspec%%$compcmd};
- COMPREPLY=($( eval compgen "$cspec" -- '$cur' ));
- fi;
- else
- if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
- _minimal;
- fi;
- fi;
- fi
- }
- _complete_as_root ()
- {
- [[ $EUID -eq 0 || -n ${root_command:-} ]]
- }
- _completion_loader ()
- {
- local cmd="${1:-_EmptycmD_}";
- __load_completion "$cmd" && return 124;
- complete -F _minimal -- "$cmd" && return 124
- }
- _configured_interfaces ()
- {
- if [[ -f /etc/debian_version ]]; then
- COMPREPLY=($( compgen -W "$( command sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p' /etc/network/interfaces /etc/network/interfaces.d/* 2>/dev/null )" -- "$cur" ));
- else
- if [[ -f /etc/SuSE-release ]]; then
- COMPREPLY=($( compgen -W "$( printf '%s\n' /etc/sysconfig/network/ifcfg-* | command sed -ne 's|.*ifcfg-\([^*].*\)$|\1|p' )" -- "$cur" ));
- else
- if [[ -f /etc/pld-release ]]; then
- COMPREPLY=($( compgen -W "$( command ls -B /etc/sysconfig/interfaces | command sed -ne 's|.*ifcfg-\([^*].*\)$|\1|p' )" -- "$cur" ));
- else
- COMPREPLY=($( compgen -W "$( printf '%s\n' /etc/sysconfig/network-scripts/ifcfg-* | command sed -ne 's|.*ifcfg-\([^*].*\)$|\1|p' )" -- "$cur" ));
- fi;
- fi;
- fi
- }
- _count_args ()
- {
- local i cword words;
- __reassemble_comp_words_by_ref "$1" words cword;
- args=1;
- for i in "${words[@]:1:cword-1}";
- do
- [[ "$i" != -* ]] && args=$(($args+1));
- done
- }
- _dvd_devices ()
- {
- COMPREPLY+=($( compgen -f -d -X "!*/?(r)dvd*" -- "${cur:-/dev/}" ))
- }
- _expand ()
- {
- if [[ "$cur" == \~*/* ]]; then
- __expand_tilde_by_ref cur;
- else
- if [[ "$cur" == \~* ]]; then
- _tilde "$cur" || eval COMPREPLY[0]=$(printf ~%q "${COMPREPLY[0]#\~}");
- return ${#COMPREPLY[@]};
- fi;
- fi
- }
- _filedir ()
- {
- local IFS='
- ';
- _tilde "$cur" || return;
- local -a toks;
- local x reset;
- reset=$(shopt -po noglob);
- set -o noglob;
- toks=($( compgen -d -- "$cur" ));
- eval $reset;
- if [[ "$1" != -d ]]; then
- local quoted;
- _quote_readline_by_ref "$cur" quoted;
- local xspec=${1:+"!*.@($1|${1^^})"};
- reset=$(shopt -po noglob);
- set -o noglob;
- toks+=($( compgen -f -X "$xspec" -- $quoted ));
- eval $reset;
- [[ -n ${COMP_FILEDIR_FALLBACK:-} && -n "$1" && ${#toks[@]} -lt 1 ]] && {
- reset=$(shopt -po noglob);
- set -o noglob;
- toks+=($( compgen -f -- $quoted ));
- eval $reset
- };
- fi;
- if [[ ${#toks[@]} -ne 0 ]]; then
- compopt -o filenames 2> /dev/null;
- COMPREPLY+=("${toks[@]}");
- fi
- }
- _filedir_xspec ()
- {
- local cur prev words cword;
- _init_completion || return;
- _tilde "$cur" || return;
- local IFS='
- ' xspec=${_xspecs[${1##*/}]} tmp;
- local -a toks;
- toks=($(
- compgen -d -- "$(quote_readline "$cur")" | {
- while read -r tmp; do
- printf '%s\n' $tmp
- done
- }
- ));
- eval xspec="${xspec}";
- local matchop=!;
- if [[ $xspec == !* ]]; then
- xspec=${xspec#!};
- matchop=@;
- fi;
- xspec="$matchop($xspec|${xspec^^})";
- toks+=($(
- eval compgen -f -X "'!$xspec'" -- "\$(quote_readline "\$cur")" | {
- while read -r tmp; do
- [[ -n $tmp ]] && printf '%s\n' $tmp
- done
- }
- ));
- [[ -n ${COMP_FILEDIR_FALLBACK:-} && ${#toks[@]} -lt 1 ]] && {
- local reset=$(shopt -po noglob);
- set -o noglob;
- toks+=($( compgen -f -- "$(quote_readline "$cur")" ));
- IFS=' ';
- $reset;
- IFS='
- '
- };
- if [[ ${#toks[@]} -ne 0 ]]; then
- compopt -o filenames;
- COMPREPLY=("${toks[@]}");
- fi
- }
- _fstypes ()
- {
- local fss;
- if [[ -e /proc/filesystems ]]; then
- fss="$( cut -d' ' -f2 /proc/filesystems )
- $( awk '! /\*/ { print $NF }' /etc/filesystems 2>/dev/null )";
- else
- fss="$( awk '/^[ \t]*[^#]/ { print $3 }' /etc/fstab 2>/dev/null )
- $( awk '/^[ \t]*[^#]/ { print $3 }' /etc/mnttab 2>/dev/null )
- $( awk '/^[ \t]*[^#]/ { print $4 }' /etc/vfstab 2>/dev/null )
- $( awk '{ print $1 }' /etc/dfs/fstypes 2>/dev/null )
- $( [[ -d /etc/fs ]] && command ls /etc/fs )";
- fi;
- [[ -n $fss ]] && COMPREPLY+=($( compgen -W "$fss" -- "$cur" ))
- }
- _get_comp_words_by_ref ()
- {
- local exclude flag i OPTIND=1;
- local cur cword words=();
- local upargs=() upvars=() vcur vcword vprev vwords;
- while getopts "c:i:n:p:w:" flag "$@"; do
- case $flag in
- c)
- vcur=$OPTARG
- ;;
- i)
- vcword=$OPTARG
- ;;
- n)
- exclude=$OPTARG
- ;;
- p)
- vprev=$OPTARG
- ;;
- w)
- vwords=$OPTARG
- ;;
- esac;
- done;
- while [[ $# -ge $OPTIND ]]; do
- case ${!OPTIND} in
- cur)
- vcur=cur
- ;;
- prev)
- vprev=prev
- ;;
- cword)
- vcword=cword
- ;;
- words)
- vwords=words
- ;;
- *)
- echo "bash: $FUNCNAME(): \`${!OPTIND}': unknown argument" 1>&2;
- return 1
- ;;
- esac;
- let "OPTIND += 1";
- done;
- __get_cword_at_cursor_by_ref "$exclude" words cword cur;
- [[ -n $vcur ]] && {
- upvars+=("$vcur");
- upargs+=(-v $vcur "$cur")
- };
- [[ -n $vcword ]] && {
- upvars+=("$vcword");
- upargs+=(-v $vcword "$cword")
- };
- [[ -n $vprev && $cword -ge 1 ]] && {
- upvars+=("$vprev");
- upargs+=(-v $vprev "${words[cword - 1]}")
- };
- [[ -n $vwords ]] && {
- upvars+=("$vwords");
- upargs+=(-a${#words[@]} $vwords "${words[@]}")
- };
- (( ${#upvars[@]} )) && local "${upvars[@]}" && _upvars "${upargs[@]}"
- }
- _get_cword ()
- {
- local LC_CTYPE=C;
- local cword words;
- __reassemble_comp_words_by_ref "$1" words cword;
- if [[ -n ${2//[^0-9]/} ]]; then
- printf "%s" "${words[cword-$2]}";
- else
- if [[ "${#words[cword]}" -eq 0 || "$COMP_POINT" == "${#COMP_LINE}" ]]; then
- printf "%s" "${words[cword]}";
- else
- local i;
- local cur="$COMP_LINE";
- local index="$COMP_POINT";
- for ((i = 0; i <= cword; ++i ))
- do
- while [[ "${#cur}" -ge ${#words[i]} && "${cur:0:${#words[i]}}" != "${words[i]}" ]]; do
- cur="${cur:1}";
- [[ $index -gt 0 ]] && ((index--));
- done;
- if [[ "$i" -lt "$cword" ]]; then
- local old_size="${#cur}";
- cur="${cur#${words[i]}}";
- local new_size="${#cur}";
- index=$(( index - old_size + new_size ));
- fi;
- done;
- if [[ "${words[cword]:0:${#cur}}" != "$cur" ]]; then
- printf "%s" "${words[cword]}";
- else
- printf "%s" "${cur:0:$index}";
- fi;
- fi;
- fi
- }
- _get_first_arg ()
- {
- local i;
- arg=;
- for ((i=1; i < COMP_CWORD; i++ ))
- do
- if [[ "${COMP_WORDS[i]}" != -* ]]; then
- arg=${COMP_WORDS[i]};
- break;
- fi;
- done
- }
- _get_pword ()
- {
- if [[ $COMP_CWORD -ge 1 ]]; then
- _get_cword "${@:-}" 1;
- fi
- }
- _gids ()
- {
- if type getent &> /dev/null; then
- COMPREPLY=($( compgen -W '$( getent group | cut -d: -f3 )' -- "$cur" ));
- else
- if type perl &> /dev/null; then
- COMPREPLY=($( compgen -W '$( perl -e '"'"'while (($gid) = (getgrent)[2]) { print $gid . "\n" }'"'"' )' -- "$cur" ));
- else
- COMPREPLY=($( compgen -W '$( cut -d: -f3 /etc/group )' -- "$cur" ));
- fi;
- fi
- }
- _have ()
- {
- PATH=$PATH:/usr/sbin:/sbin:/usr/local/sbin type $1 &> /dev/null
- }
- _included_ssh_config_files ()
- {
- [[ $# -lt 1 ]] && echo "error: $FUNCNAME: missing mandatory argument CONFIG";
- local configfile i f;
- configfile=$1;
- local included=$( command sed -ne 's/^[[:blank:]]*[Ii][Nn][Cc][Ll][Uu][Dd][Ee][[:blank:]]\{1,\}\([^#%]*\)\(#.*\)\{0,1\}$/\1/p' "${configfile}" );
- for i in ${included[@]};
- do
- if ! [[ "$i" =~ ^\~.*|^\/.* ]]; then
- if [[ "$configfile" =~ ^\/etc\/ssh.* ]]; then
- i="/etc/ssh/$i";
- else
- i="$HOME/.ssh/$i";
- fi;
- fi;
- __expand_tilde_by_ref i;
- for f in ${i};
- do
- if [ -r $f ]; then
- config+=("$f");
- _included_ssh_config_files $f;
- fi;
- done;
- done
- }
- _init_completion ()
- {
- local exclude= flag outx errx inx OPTIND=1;
- while getopts "n:e:o:i:s" flag "$@"; do
- case $flag in
- n)
- exclude+=$OPTARG
- ;;
- e)
- errx=$OPTARG
- ;;
- o)
- outx=$OPTARG
- ;;
- i)
- inx=$OPTARG
- ;;
- s)
- split=false;
- exclude+==
- ;;
- esac;
- done;
- COMPREPLY=();
- local redir="@(?([0-9])<|?([0-9&])>?(>)|>&)";
- _get_comp_words_by_ref -n "$exclude<>&" cur prev words cword;
- _variables && return 1;
- if [[ $cur == $redir* || $prev == $redir ]]; then
- local xspec;
- case $cur in
- 2'>'*)
- xspec=$errx
- ;;
- *'>'*)
- xspec=$outx
- ;;
- *'<'*)
- xspec=$inx
- ;;
- *)
- case $prev in
- 2'>'*)
- xspec=$errx
- ;;
- *'>'*)
- xspec=$outx
- ;;
- *'<'*)
- xspec=$inx
- ;;
- esac
- ;;
- esac;
- cur="${cur##$redir}";
- _filedir $xspec;
- return 1;
- fi;
- local i skip;
- for ((i=1; i < ${#words[@]}; 1))
- do
- if [[ ${words[i]} == $redir* ]]; then
- [[ ${words[i]} == $redir ]] && skip=2 || skip=1;
- words=("${words[@]:0:i}" "${words[@]:i+skip}");
- [[ $i -le $cword ]] && cword=$(( cword - skip ));
- else
- i=$(( ++i ));
- fi;
- done;
- [[ $cword -le 0 ]] && return 1;
- prev=${words[cword-1]};
- [[ -n ${split-} ]] && _split_longopt && split=true;
- return 0
- }
- _installed_modules ()
- {
- COMPREPLY=($( compgen -W "$( PATH="$PATH:/sbin" lsmod | awk '{if (NR != 1) print $1}' )" -- "$1" ))
- }
- _ip_addresses ()
- {
- local PATH=$PATH:/sbin;
- COMPREPLY+=($( compgen -W "$( { LC_ALL=C ifconfig -a || ip addr show; } 2>/dev/null | command sed -ne 's/.*addr:\([^[:space:]]*\).*/\1/p' -ne 's|.*inet[[:space:]]\{1,\}\([^[:space:]/]*\).*|\1|p' )" -- "$cur" ))
- }
- _kernel_versions ()
- {
- COMPREPLY=($( compgen -W '$( command ls /lib/modules )' -- "$cur" ))
- }
- _known_hosts ()
- {
- local cur prev words cword;
- _init_completion -n : || return;
- local options;
- [[ "$1" == -a || "$2" == -a ]] && options=-a;
- [[ "$1" == -c || "$2" == -c ]] && options+=" -c";
- _known_hosts_real $options -- "$cur"
- }
- _known_hosts_real ()
- {
- local configfile flag prefix OIFS=$IFS;
- local cur user suffix aliases i host ipv4 ipv6;
- local -a kh tmpkh khd config;
- local OPTIND=1;
- while getopts "ac46F:p:" flag "$@"; do
- case $flag in
- a)
- aliases='yes'
- ;;
- c)
- suffix=':'
- ;;
- F)
- configfile=$OPTARG
- ;;
- p)
- prefix=$OPTARG
- ;;
- 4)
- ipv4=1
- ;;
- 6)
- ipv6=1
- ;;
- esac;
- done;
- [[ $# -lt $OPTIND ]] && echo "error: $FUNCNAME: missing mandatory argument CWORD";
- cur=${!OPTIND};
- let "OPTIND += 1";
- [[ $# -ge $OPTIND ]] && echo "error: $FUNCNAME("$@"): unprocessed arguments:" $(while [[ $# -ge $OPTIND ]]; do printf '%s\n' ${!OPTIND}; shift; done);
- [[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@};
- kh=();
- if [[ -n $configfile ]]; then
- [[ -r $configfile ]] && config+=("$configfile");
- else
- for i in /etc/ssh/ssh_config ~/.ssh/config ~/.ssh2/config;
- do
- [[ -r $i ]] && config+=("$i");
- done;
- fi;
- for i in "${config[@]}";
- do
- _included_ssh_config_files "$i";
- done;
- if [[ ${#config[@]} -gt 0 ]]; then
- local IFS='
- ' j;
- tmpkh=($( awk 'sub("^[ \t]*([Gg][Ll][Oo][Bb][Aa][Ll]|[Uu][Ss][Ee][Rr])[Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][ \t]+", "") { print $0 }' "${config[@]}" | sort -u ));
- IFS=$OIFS;
- for i in "${tmpkh[@]}";
- do
- while [[ $i =~ ^([^\"]*)\"([^\"]*)\"(.*)$ ]]; do
- i=${BASH_REMATCH[1]}${BASH_REMATCH[3]};
- j=${BASH_REMATCH[2]};
- __expand_tilde_by_ref j;
- [[ -r $j ]] && kh+=("$j");
- done;
- for j in $i;
- do
- __expand_tilde_by_ref j;
- [[ -r $j ]] && kh+=("$j");
- done;
- done;
- fi;
- if [[ -z $configfile ]]; then
- for i in /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 /etc/known_hosts /etc/known_hosts2 ~/.ssh/known_hosts ~/.ssh/known_hosts2;
- do
- [[ -r $i ]] && kh+=("$i");
- done;
- for i in /etc/ssh2/knownhosts ~/.ssh2/hostkeys;
- do
- [[ -d $i ]] && khd+=("$i"/*pub);
- done;
- fi;
- if [[ ${#kh[@]} -gt 0 || ${#khd[@]} -gt 0 ]]; then
- if [[ ${#kh[@]} -gt 0 ]]; then
- for i in "${kh[@]}";
- do
- while read -ra tmpkh; do
- set -- "${tmpkh[@]}";
- [[ $1 == [\|\#]* ]] && continue;
- [[ $1 == @* ]] && shift;
- local IFS=,;
- for host in $1;
- do
- [[ $host == *[*?]* ]] && continue;
- host="${host#[}";
- host="${host%]?(:+([0-9]))}";
- COMPREPLY+=($host);
- done;
- IFS=$OIFS;
- done < "$i";
- done;
- COMPREPLY=($( compgen -W '${COMPREPLY[@]}' -- "$cur" ));
- fi;
- if [[ ${#khd[@]} -gt 0 ]]; then
- for i in "${khd[@]}";
- do
- if [[ "$i" == *key_22_$cur*.pub && -r "$i" ]]; then
- host=${i/#*key_22_/};
- host=${host/%.pub/};
- COMPREPLY+=($host);
- fi;
- done;
- fi;
- for ((i=0; i < ${#COMPREPLY[@]}; i++ ))
- do
- COMPREPLY[i]=$prefix$user${COMPREPLY[i]}$suffix;
- done;
- fi;
- if [[ ${#config[@]} -gt 0 && -n "$aliases" ]]; then
- local hosts=$( command sed -ne 's/^[[:blank:]]*[Hh][Oo][Ss][Tt][[:blank:]]\{1,\}\([^#*?%]*\)\(#.*\)\{0,1\}$/\1/p' "${config[@]}" );
- COMPREPLY+=($( compgen -P "$prefix$user" -S "$suffix" -W "$hosts" -- "$cur" ));
- fi;
- if [[ -n ${COMP_KNOWN_HOSTS_WITH_AVAHI:-} ]] && type avahi-browse &> /dev/null; then
- COMPREPLY+=($( compgen -P "$prefix$user" -S "$suffix" -W "$( avahi-browse -cpr _workstation._tcp 2>/dev/null | awk -F';' '/^=/ { print $7 }' | sort -u )" -- "$cur" ));
- fi;
- COMPREPLY+=($( compgen -W "$( ruptime 2>/dev/null | awk '!/^ruptime:/ { print $1 }' )" -- "$cur" ));
- if [[ -n ${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1} ]]; then
- COMPREPLY+=($( compgen -A hostname -P "$prefix$user" -S "$suffix" -- "$cur" ));
- fi;
- if [[ -n $ipv4 ]]; then
- COMPREPLY=("${COMPREPLY[@]/*:*$suffix/}");
- fi;
- if [[ -n $ipv6 ]]; then
- COMPREPLY=("${COMPREPLY[@]/+([0-9]).+([0-9]).+([0-9]).+([0-9])$suffix/}");
- fi;
- if [[ -n $ipv4 || -n $ipv6 ]]; then
- for i in ${!COMPREPLY[@]};
- do
- [[ -n ${COMPREPLY[i]} ]] || unset -v COMPREPLY[i];
- done;
- fi;
- __ltrim_colon_completions "$prefix$user$cur"
- }
- _longopt ()
- {
- local cur prev words cword split;
- _init_completion -s || return;
- case "${prev,,}" in
- --help | --usage | --version)
- return
- ;;
- --*dir*)
- _filedir -d;
- return
- ;;
- --*file* | --*path*)
- _filedir;
- return
- ;;
- --+([-a-z0-9_]))
- local argtype=$( LC_ALL=C $1 --help 2>&1 | command sed -ne "s|.*$prev\[\{0,1\}=[<[]\{0,1\}\([-A-Za-z0-9_]\{1,\}\).*|\1|p" );
- case ${argtype,,} in
- *dir*)
- _filedir -d;
- return
- ;;
- *file* | *path*)
- _filedir;
- return
- ;;
- esac
- ;;
- esac;
- $split && return;
- if [[ "$cur" == -* ]]; then
- COMPREPLY=($( compgen -W "$( LC_ALL=C $1 --help 2>&1 | command sed -ne 's/.*\(--[-A-Za-z0-9]\{1,\}=\{0,1\}\).*/\1/p' | sort -u )" -- "$cur" ));
- [[ $COMPREPLY == *= ]] && compopt -o nospace;
- else
- if [[ "$1" == @(rmdir|chroot) ]]; then
- _filedir -d;
- else
- [[ "$1" == mkdir ]] && compopt -o nospace;
- _filedir;
- fi;
- fi
- }
- _lsvirtualenv_usage ()
- {
- echo "lsvirtualenv [-blh]";
- echo " -b -- brief mode";
- echo " -l -- long mode";
- echo " -h -- this help message"
- }
- _mac_addresses ()
- {
- local re='\([A-Fa-f0-9]\{2\}:\)\{5\}[A-Fa-f0-9]\{2\}';
- local PATH="$PATH:/sbin:/usr/sbin";
- COMPREPLY+=($( { LC_ALL=C ifconfig -a || ip link show; } 2>/dev/null | command sed -ne "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]].*/\1/p" -ne "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]]*$/\1/p" -ne "s|.*[[:space:]]\(link/\)\{0,1\}ether[[:space:]]\{1,\}\($re\)[[:space:]].*|\2|p" -ne "s|.*[[:space:]]\(link/\)\{0,1\}ether[[:space:]]\{1,\}\($re\)[[:space:]]*$|\2|p"
- ));
- COMPREPLY+=($( { arp -an || ip neigh show; } 2>/dev/null | command sed -ne "s/.*[[:space:]]\($re\)[[:space:]].*/\1/p" -ne "s/.*[[:space:]]\($re\)[[:space:]]*$/\1/p" ));
- COMPREPLY+=($( command sed -ne "s/^[[:space:]]*\($re\)[[:space:]].*/\1/p" /etc/ethers 2>/dev/null ));
- COMPREPLY=($( compgen -W '${COMPREPLY[@]}' -- "$cur" ));
- __ltrim_colon_completions "$cur"
- }
- _minimal ()
- {
- local cur prev words cword split;
- _init_completion -s || return;
- $split && return;
- _filedir
- }
- _modules ()
- {
- local modpath;
- modpath=/lib/modules/$1;
- COMPREPLY=($( compgen -W "$( command ls -RL $modpath 2>/dev/null | command sed -ne 's/^\(.*\)\.k\{0,1\}o\(\.[gx]z\)\{0,1\}$/\1/p' )" -- "$cur" ))
- }
- _ncpus ()
- {
- local var=NPROCESSORS_ONLN;
- [[ $OSTYPE == *linux* ]] && var=_$var;
- local n=$( getconf $var 2>/dev/null );
- printf %s ${n:-1}
- }
- _parse_help ()
- {
- eval local cmd=$( quote "$1" );
- local line;
- {
- case $cmd in
- -)
- cat
- ;;
- *)
- LC_ALL=C "$( dequote "$cmd" )" ${2:---help} 2>&1
- ;;
- esac
- } | while read -r line; do
- [[ $line == *([[:blank:]])-* ]] || continue;
- while [[ $line =~ ((^|[^-])-[A-Za-z0-9?][[:space:]]+)\[?[A-Z0-9]+\]? ]]; do
- line=${line/"${BASH_REMATCH[0]}"/"${BASH_REMATCH[1]}"};
- done;
- __parse_options "${line// or /, }";
- done
- }
- _parse_usage ()
- {
- eval local cmd=$( quote "$1" );
- local line match option i char;
- {
- case $cmd in
- -)
- cat
- ;;
- *)
- LC_ALL=C "$( dequote "$cmd" )" ${2:---usage} 2>&1
- ;;
- esac
- } | while read -r line; do
- while [[ $line =~ \[[[:space:]]*(-[^]]+)[[:space:]]*\] ]]; do
- match=${BASH_REMATCH[0]};
- option=${BASH_REMATCH[1]};
- case $option in
- -?(\[)+([a-zA-Z0-9?]))
- for ((i=1; i < ${#option}; i++ ))
- do
- char=${option:i:1};
- [[ $char != '[' ]] && printf '%s\n' -$char;
- done
- ;;
- *)
- __parse_options "$option"
- ;;
- esac;
- line=${line#*"$match"};
- done;
- done
- }
- _pci_ids ()
- {
- COMPREPLY+=($( compgen -W "$( PATH="$PATH:/sbin" lspci -n | awk '{print $3}')" -- "$cur" ))
- }
- _pgids ()
- {
- COMPREPLY=($( compgen -W '$( command ps axo pgid= )' -- "$cur" ))
- }
- _pids ()
- {
- COMPREPLY=($( compgen -W '$( command ps axo pid= )' -- "$cur" ))
- }
- _pnames ()
- {
- if [[ "$1" == -s ]]; then
- COMPREPLY=($( compgen -X '<defunct>' -W '$( command ps axo comm | command sed -e 1d )' -- "$cur" ));
- else
- COMPREPLY=($( compgen -X '<defunct>' -W '$( command ps axo command= | command sed -e \
- "s/ .*//" -e \
- "s:.*/::" -e \
- "s/:$//" -e \
- "s/^[[(-]//" -e \
- "s/[])]$//" | sort -u )' -- "$cur" ));
- fi
- }
- _quote_readline_by_ref ()
- {
- if [ -z "$1" ]; then
- printf -v $2 %s "$1";
- else
- if [[ $1 == \'* ]]; then
- printf -v $2 %s "${1:1}";
- else
- if [[ $1 == ~* ]]; then
- printf -v $2 ~%q "${1:1}";
- else
- printf -v $2 %q "$1";
- fi;
- fi;
- fi;
- [[ ${!2} == \$* ]] && eval $2=${!2}
- }
- _realcommand ()
- {
- type -P "$1" > /dev/null && {
- if type -p realpath > /dev/null; then
- realpath "$(type -P "$1")";
- else
- if type -p greadlink > /dev/null; then
- greadlink -f "$(type -P "$1")";
- else
- if type -p readlink > /dev/null; then
- readlink -f "$(type -P "$1")";
- else
- type -P "$1";
- fi;
- fi;
- fi
- }
- }
- _rl_enabled ()
- {
- [[ "$( bind -v )" == *$1+([[:space:]])on* ]]
- }
- _root_command ()
- {
- local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin;
- local root_command=$1;
- _command
- }
- _service ()
- {
- local cur prev words cword;
- _init_completion || return;
- [[ $cword -gt 2 ]] && return;
- if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then
- _services;
- [[ -e /etc/mandrake-release ]] && _xinetd_services;
- else
- local sysvdirs;
- _sysvdirs;
- COMPREPLY=($( compgen -W '`command sed -e "y/|/ /" \
- -ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \
- ${sysvdirs[0]}/${prev##*/} 2>/dev/null` start stop' -- "$cur" ));
- fi
- }
- _services ()
- {
- local sysvdirs;
- _sysvdirs;
- local IFS='
- ' reset=$(shopt -p nullglob);
- shopt -s nullglob;
- COMPREPLY=($( printf '%s\n' ${sysvdirs[0]}/!($_backup_glob|functions|README) ));
- $reset;
- COMPREPLY+=($( systemctl list-units --full --all 2>/dev/null | awk '$1 ~ /\.service$/ { sub("\\.service$", "", $1); print $1 }' ));
- if [[ -x /sbin/upstart-udev-bridge ]]; then
- COMPREPLY+=($( initctl list 2>/dev/null | cut -d' ' -f1 ));
- fi;
- COMPREPLY=($( compgen -W '${COMPREPLY[@]#${sysvdirs[0]}/}' -- "$cur" ))
- }
- _shells ()
- {
- local shell rest;
- while read -r shell rest; do
- [[ $shell == /* && $shell == "$cur"* ]] && COMPREPLY+=($shell);
- done 2> /dev/null < /etc/shells
- }
- _signals ()
- {
- local -a sigs=($( compgen -P "$1" -A signal "SIG${cur#$1}" ));
- COMPREPLY+=("${sigs[@]/#${1}SIG/${1}}")
- }
- _split_longopt ()
- {
- if [[ "$cur" == --?*=* ]]; then
- prev="${cur%%?(\\)=*}";
- cur="${cur#*=}";
- return 0;
- fi;
- return 1
- }
- _sysvdirs ()
- {
- sysvdirs=();
- [[ -d /etc/rc.d/init.d ]] && sysvdirs+=(/etc/rc.d/init.d);
- [[ -d /etc/init.d ]] && sysvdirs+=(/etc/init.d);
- [[ -f /etc/slackware-version ]] && sysvdirs=(/etc/rc.d)
- }
- _terms ()
- {
- COMPREPLY+=($( compgen -W "$( command sed -ne 's/^\([^[:space:]#|]\{2,\}\)|.*/\1/p' /etc/termcap 2>/dev/null )" -- "$cur" ));
- COMPREPLY+=($( compgen -W "$( { toe -a 2>/dev/null || toe 2>/dev/null; } | awk '{ print $1 }' | sort -u )" -- "$cur" ))
- }
- _tilde ()
- {
- local result=0;
- if [[ $1 == \~* && $1 != */* ]]; then
- COMPREPLY=($( compgen -P '~' -u -- "${1#\~}" ));
- result=${#COMPREPLY[@]};
- [[ $result -gt 0 ]] && compopt -o filenames 2> /dev/null;
- fi;
- return $result
- }
- _uids ()
- {
- if type getent &> /dev/null; then
- COMPREPLY=($( compgen -W '$( getent passwd | cut -d: -f3 )' -- "$cur" ));
- else
- if type perl &> /dev/null; then
- COMPREPLY=($( compgen -W '$( perl -e '"'"'while (($uid) = (getpwent)[2]) { print $uid . "\n" }'"'"' )' -- "$cur" ));
- else
- COMPREPLY=($( compgen -W '$( cut -d: -f3 /etc/passwd )' -- "$cur" ));
- fi;
- fi
- }
- _upvar ()
- {
- if unset -v "$1"; then
- if (( $# == 2 )); then
- eval $1=\"\$2\";
- else
- eval $1=\(\"\${@:2}\"\);
- fi;
- fi
- }
- _upvars ()
- {
- if ! (( $# )); then
- echo "${FUNCNAME[0]}: usage: ${FUNCNAME[0]} [-v varname" "value] | [-aN varname [value ...]] ..." 1>&2;
- return 2;
- fi;
- while (( $# )); do
- case $1 in
- -a*)
- [[ -n ${1#-a} ]] || {
- echo "bash: ${FUNCNAME[0]}: \`$1': missing" "number specifier" 1>&2;
- return 1
- };
- printf %d "${1#-a}" &> /dev/null || {
- echo "bash:" "${FUNCNAME[0]}: \`$1': invalid number specifier" 1>&2;
- return 1
- };
- [[ -n "$2" ]] && unset -v "$2" && eval $2=\(\"\${@:3:${1#-a}}\"\) && shift $((${1#-a} + 2)) || {
- echo "bash: ${FUNCNAME[0]}:" "\`$1${2+ }$2': missing argument(s)" 1>&2;
- return 1
- }
- ;;
- -v)
- [[ -n "$2" ]] && unset -v "$2" && eval $2=\"\$3\" && shift 3 || {
- echo "bash: ${FUNCNAME[0]}: $1: missing" "argument(s)" 1>&2;
- return 1
- }
- ;;
- *)
- echo "bash: ${FUNCNAME[0]}: $1: invalid option" 1>&2;
- return 1
- ;;
- esac;
- done
- }
- _usb_ids ()
- {
- COMPREPLY+=($( compgen -W "$( PATH="$PATH:/sbin" lsusb | awk '{print $6}' )" -- "$cur" ))
- }
- _user_at_host ()
- {
- local cur prev words cword;
- _init_completion -n : || return;
- if [[ $cur == *@* ]]; then
- _known_hosts_real "$cur";
- else
- COMPREPLY=($( compgen -u -S @ -- "$cur" ));
- compopt -o nospace;
- fi
- }
- _usergroup ()
- {
- if [[ $cur == *\\\\* || $cur == *:*:* ]]; then
- return;
- else
- if [[ $cur == *\\:* ]]; then
- local prefix;
- prefix=${cur%%*([^:])};
- prefix=${prefix//\\};
- local mycur="${cur#*[:]}";
- if [[ $1 == -u ]]; then
- _allowed_groups "$mycur";
- else
- local IFS='
- ';
- COMPREPLY=($( compgen -g -- "$mycur" ));
- fi;
- COMPREPLY=($( compgen -P "$prefix" -W "${COMPREPLY[@]}" ));
- else
- if [[ $cur == *:* ]]; then
- local mycur="${cur#*:}";
- if [[ $1 == -u ]]; then
- _allowed_groups "$mycur";
- else
- local IFS='
- ';
- COMPREPLY=($( compgen -g -- "$mycur" ));
- fi;
- else
- if [[ $1 == -u ]]; then
- _allowed_users "$cur";
- else
- local IFS='
- ';
- COMPREPLY=($( compgen -u -- "$cur" ));
- fi;
- fi;
- fi;
- fi
- }
- _userland ()
- {
- local userland=$( uname -s );
- [[ $userland == @(Linux|GNU/*) ]] && userland=GNU;
- [[ $userland == $1 ]]
- }
- _variables ()
- {
- if [[ $cur =~ ^(\$(\{[!#]?)?)([A-Za-z0-9_]*)$ ]]; then
- if [[ $cur == \${* ]]; then
- local arrs vars;
- vars=($( compgen -A variable -P ${BASH_REMATCH[1]} -S '}' -- ${BASH_REMATCH[3]} )) && arrs=($( compgen -A arrayvar -P ${BASH_REMATCH[1]} -S '[' -- ${BASH_REMATCH[3]} ));
- if [[ ${#vars[@]} -eq 1 && -n $arrs ]]; then
- compopt -o nospace;
- COMPREPLY+=(${arrs[*]});
- else
- COMPREPLY+=(${vars[*]});
- fi;
- else
- COMPREPLY+=($( compgen -A variable -P '$' -- "${BASH_REMATCH[3]}" ));
- fi;
- return 0;
- else
- if [[ $cur =~ ^(\$\{[#!]?)([A-Za-z0-9_]*)\[([^]]*)$ ]]; then
- local IFS='
- ';
- COMPREPLY+=($( compgen -W '$(printf %s\\n "${!'${BASH_REMATCH[2]}'[@]}")' -P "${BASH_REMATCH[1]}${BASH_REMATCH[2]}[" -S ']}' -- "${BASH_REMATCH[3]}" ));
- if [[ ${BASH_REMATCH[3]} == [@*] ]]; then
- COMPREPLY+=("${BASH_REMATCH[1]}${BASH_REMATCH[2]}[${BASH_REMATCH[3]}]}");
- fi;
- __ltrim_colon_completions "$cur";
- return 0;
- else
- if [[ $cur =~ ^\$\{[#!]?[A-Za-z0-9_]*\[.*\]$ ]]; then
- COMPREPLY+=("$cur}");
- __ltrim_colon_completions "$cur";
- return 0;
- else
- case $prev in
- TZ)
- cur=/usr/share/zoneinfo/$cur;
- _filedir;
- for i in ${!COMPREPLY[@]};
- do
- if [[ ${COMPREPLY[i]} == *.tab ]]; then
- unset 'COMPREPLY[i]';
- continue;
- else
- if [[ -d ${COMPREPLY[i]} ]]; then
- COMPREPLY[i]+=/;
- compopt -o nospace;
- fi;
- fi;
- COMPREPLY[i]=${COMPREPLY[i]#/usr/share/zoneinfo/};
- done;
- return 0
- ;;
- esac;
- fi;
- fi;
- fi;
- return 1
- }
- _virtualenvs ()
- {
- local cur="${COMP_WORDS[COMP_CWORD]}";
- COMPREPLY=($(compgen -W "`virtualenvwrapper_show_workon_options`" -- ${cur}))
- }
- _xfunc ()
- {
- set -- "$@";
- local srcfile=$1;
- shift;
- declare -F $1 &> /dev/null || {
- __load_completion "$srcfile"
- };
- "$@"
- }
- _xinetd_services ()
- {
- local xinetddir=/etc/xinetd.d;
- if [[ -d $xinetddir ]]; then
- local IFS='
- ' reset=$(shopt -p nullglob);
- shopt -s nullglob;
- local -a svcs=($( printf '%s\n' $xinetddir/!($_backup_glob) ));
- $reset;
- COMPREPLY+=($( compgen -W '${svcs[@]#$xinetddir/}' -- "$cur" ));
- fi
- }
- add2virtualenv ()
- {
- virtualenvwrapper_verify_workon_home || return 1;
- virtualenvwrapper_verify_active_environment || return 1;
- site_packages="`virtualenvwrapper_get_site_packages_dir`";
- if [ ! -d "${site_packages}" ]; then
- echo "ERROR: currently-active virtualenv does not appear to have a site-packages directory" 1>&2;
- return 1;
- fi;
- path_file="$site_packages/_virtualenv_path_extensions.pth";
- if [ "$*" = "" ]; then
- echo "Usage: add2virtualenv dir [dir ...]";
- if [ -f "$path_file" ]; then
- echo;
- echo "Existing paths:";
- cat "$path_file" | grep --color=auto -v "^import";
- fi;
- return 1;
- fi;
- remove=0;
- if [ "$1" = "-d" ]; then
- remove=1;
- shift;
- fi;
- if [ ! -f "$path_file" ]; then
- echo "import sys; sys.__plen = len(sys.path)" > "$path_file" || return 1;
- echo "import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)" >> "$path_file" || return 1;
- fi;
- for pydir in "$@";
- do
- absolute_path="$(virtualenvwrapper_absolutepath "$pydir")";
- if [ "$absolute_path" != "$pydir" ]; then
- echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2;
- fi;
- if [ $remove -eq 1 ]; then
- sed -i.tmp "\:^$absolute_path$: d" "$path_file";
- else
- sed -i.tmp '1 a\
- '"$absolute_path"'
- ' "$path_file";
- fi;
- rm -f "${path_file}.tmp";
- done;
- return 0
- }
- allvirtualenv ()
- {
- virtualenvwrapper_verify_workon_home || return 1;
- typeset d;
- IFS='%';
- virtualenvwrapper_show_workon_options | while read d; do
- [ ! -d "$WORKON_HOME/$d" ] && continue;
- echo "$d";
- echo "$d" | sed 's/./=/g';
- ( source "$WORKON_HOME/$d/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate";
- virtualenvwrapper_cd "$VIRTUAL_ENV";
- "$@" );
- echo;
- done;
- unset IFS
- }
- cdproject ()
- {
- virtualenvwrapper_verify_workon_home || return 1;
- virtualenvwrapper_verify_active_environment || return 1;
- if [ -f "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" ]; then
- typeset project_dir="$(cat "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME")";
- if [ ! -z "$project_dir" ]; then
- virtualenvwrapper_cd "$project_dir";
- else
- echo "Project directory $project_dir does not exist" 1>&2;
- return 1;
- fi;
- else
- echo "No project set in $VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME" 1>&2;
- return 1;
- fi;
- return 0
- }
- cdsitepackages ()
- {
- virtualenvwrapper_verify_workon_home || return 1;
- virtualenvwrapper_verify_active_environment || return 1;
- typeset site_packages="`virtualenvwrapper_get_site_packages_dir`";
- virtualenvwrapper_cd "$site_packages/$1"
- }
- cdvirtualenv ()
- {
- virtualenvwrapper_verify_workon_home || return 1;
- virtualenvwrapper_verify_active_environment || return 1;
- virtualenvwrapper_cd "$VIRTUAL_ENV/$1"
- }
- cpvirtualenv ()
- {
- virtualenvwrapper_verify_workon_home || return 1;
- virtualenvwrapper_verify_virtualenv_clone || return 1;
- typeset src_name="$1";
- typeset trg_name="$2";
- typeset src;
- typeset trg;
- if [ "$src_name" = "" ]; then
- echo "Please provide a valid virtualenv to copy.";
- return 1;
- else
- if [ ! -e "$WORKON_HOME/$src_name" ]; then
- src="$(virtualenvwrapper_expandpath "$src_name")";
- if [ ! -e "$src" ]; then
- echo "Please provide a valid virtualenv to copy.";
- return 1;
- fi;
- src_name="$(basename "$src")";
- else
- src="$WORKON_HOME/$src_name";
- fi;
- fi;
- if [ "$trg_name" = "" ]; then
- trg="$WORKON_HOME/$src_name";
- trg_name="$src_name";
- else
- trg="$WORKON_HOME/$trg_name";
- fi;
- trg="$(virtualenvwrapper_expandpath "$trg")";
- if [ -e "$trg" ]; then
- echo "$trg_name virtualenv already exists.";
- return 1;
- fi;
- echo "Copying $src_name as $trg_name...";
- ( [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT;
- virtualenvwrapper_cd "$WORKON_HOME" && "$VIRTUALENVWRAPPER_VIRTUALENV_CLONE" "$src" "$trg";
- [ -d "$trg" ] && virtualenvwrapper_run_hook "pre_cpvirtualenv" "$src" "$trg_name" && virtualenvwrapper_run_hook "pre_mkvirtualenv" "$trg_name" );
- typeset RC=$?;
- [ $RC -ne 0 ] && return $RC;
- [ ! -d "$WORKON_HOME/$trg_name" ] && return 1;
- workon "$trg_name";
- virtualenvwrapper_run_hook "post_mkvirtualenv";
- virtualenvwrapper_run_hook "post_cpvirtualenv"
- }
- dequote ()
- {
- eval printf %s "$1" 2> /dev/null
- }
- lssitepackages ()
- {
- virtualenvwrapper_verify_workon_home || return 1;
- virtualenvwrapper_verify_active_environment || return 1;
- typeset site_packages="`virtualenvwrapper_get_site_packages_dir`";
- ls --color=auto $@ "$site_packages";
- path_file="$site_packages/_virtualenv_path_extensions.pth";
- if [ -f "$path_file" ]; then
- echo;
- echo "_virtualenv_path_extensions.pth:";
- cat "$path_file";
- fi
- }
- lsvirtualenv ()
- {
- typeset long_mode=true;
- if command -v "getopts" > /dev/null 2>&1; then
- OPTIND=1;
- while getopts ":blh" opt "$@"; do
- case "$opt" in
- l)
- long_mode=true
- ;;
- b)
- long_mode=false
- ;;
- h)
- _lsvirtualenv_usage;
- return 1
- ;;
- ?)
- echo "Invalid option: -$OPTARG" 1>&2;
- _lsvirtualenv_usage;
- return 1
- ;;
- esac;
- done;
- else
- typeset -a args;
- args=($(getopt blh "$@"));
- if [ $? != 0 ]; then
- _lsvirtualenv_usage;
- return 1;
- fi;
- for opt in $args;
- do
- case "$opt" in
- -l)
- long_mode=true
- ;;
- -b)
- long_mode=false
- ;;
- -h)
- _lsvirtualenv_usage;
- return 1
- ;;
- esac;
- done;
- fi;
- if $long_mode; then
- allvirtualenv showvirtualenv "$env_name";
- else
- virtualenvwrapper_show_workon_options;
- fi
- }
- mkproject ()
- {
- typeset -a in_args;
- typeset -a out_args;
- typeset -i i;
- typeset tst;
- typeset a;
- typeset t;
- typeset force;
- typeset templates;
- in_args=("$@");
- force=0;
- if [ -n "$ZSH_VERSION" ]; then
- i=1;
- tst="-le";
- else
- i=0;
- tst="-lt";
- fi;
- while [ $i $tst $# ]; do
- a="${in_args[$i]}";
- case "$a" in
- -h | --help)
- virtualenvwrapper_mkproject_help;
- return
- ;;
- -f | --force)
- force=1
- ;;
- -t)
- i=$(( $i + 1 ));
- templates="$templates ${in_args[$i]}"
- ;;
- *)
- if [ ${#out_args} -gt 0 ]; then
- out_args=("${out_args[@]-}" "$a");
- else
- out_args=("$a");
- fi
- ;;
- esac;
- i=$(( $i + 1 ));
- done;
- set -- "${out_args[@]}";
- eval "typeset envname=\$$#";
- virtualenvwrapper_verify_project_home || return 1;
- if [ -d "$PROJECT_HOME/$envname" -a $force -eq 0 ]; then
- echo "Project $envname already exists." 1>&2;
- return 1;
- fi;
- mkvirtualenv "$@" || return 1;
- virtualenvwrapper_cd "$PROJECT_HOME";
- virtualenvwrapper_run_hook "project.pre_mkproject" $envname;
- echo "Creating $PROJECT_HOME/$envname";
- mkdir -p "$PROJECT_HOME/$envname";
- setvirtualenvproject "$VIRTUAL_ENV" "$PROJECT_HOME/$envname";
- virtualenvwrapper_cd "$PROJECT_HOME/$envname";
- for t in $templates;
- do
- echo;
- echo "Applying template $t";
- virtualenvwrapper_run_hook --name $(echo $t | sed 's/^ //') "project.template" "$envname" "$PROJECT_HOME/$envname";
- done;
- virtualenvwrapper_run_hook "project.post_mkproject"
- }
- mktmpenv ()
- {
- typeset tmpenvname;
- typeset RC;
- typeset -a in_args;
- typeset -a out_args;
- in_args=("$@");
- if [ -n "$ZSH_VERSION" ]; then
- i=1;
- tst="-le";
- else
- i=0;
- tst="-lt";
- fi;
- typeset cd_after_activate=$VIRTUALENVWRAPPER_WORKON_CD;
- while [ $i $tst $# ]; do
- a="${in_args[$i]}";
- case "$a" in
- -n | --no-cd)
- cd_after_activate=0
- ;;
- -c | --cd)
- cd_after_activate=1
- ;;
- *)
- if [ ${#out_args} -gt 0 ]; then
- out_args=("${out_args[@]-}" "$a");
- else
- out_args=("$a");
- fi
- ;;
- esac;
- i=$(( $i + 1 ));
- done;
- set -- "${out_args[@]}";
- tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import uuid,sys; sys.stdout.write(uuid.uuid4()+"\n")' 2>/dev/null);
- if [ -z "$tmpenvname" ]; then
- tmpenvname=$("$VIRTUALENVWRAPPER_PYTHON" -c 'import random,sys; sys.stdout.write(hex(random.getrandbits(64))[2:-1]+"\n")' 2>/dev/null);
- fi;
- tmpenvname="tmp-$tmpenvname";
- mkvirtualenv "$@" "$tmpenvname";
- RC=$?;
- if [ $RC -ne 0 ]; then
- return $RC;
- fi;
- [ "$cd_after_activate" = "1" ] && cdvirtualenv;
- echo "This is a temporary environment. It will be deleted when you run 'deactivate'." | tee "$VIRTUAL_ENV/README.tmpenv";
- cat - >> "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postdeactivate" <<EOF
- if [ -f "$VIRTUAL_ENV/README.tmpenv" ]
- then
- echo "Removing temporary environment:" $(basename "$VIRTUAL_ENV")
- rmvirtualenv $(basename "$VIRTUAL_ENV")
- fi
- EOF
- }
- mkvirtualenv ()
- {
- typeset -a in_args;
- typeset -a out_args;
- typeset -i i;
- typeset tst;
- typeset a;
- typeset envname;
- typeset requirements;
- typeset packages;
- typeset interpreter;
- typeset project;
- in_args=("$@");
- if [ -n "$ZSH_VERSION" ]; then
- i=1;
- tst="-le";
- else
- i=0;
- tst="-lt";
- fi;
- while [ $i $tst $# ]; do
- a="${in_args[$i]}";
- case "$a" in
- -a)
- i=$(( $i + 1 ));
- project="${in_args[$i]}";
- if [ ! -d "$project" ]; then
- echo "Cannot associate project with $project, it is not a directory" 1>&2;
- return 1;
- fi;
- project="$(virtualenvwrapper_absolutepath ${project})"
- ;;
- -h | --help)
- virtualenvwrapper_mkvirtualenv_help $a;
- return
- ;;
- -i)
- i=$(( $i + 1 ));
- packages="$packages ${in_args[$i]}"
- ;;
- -p | --python*)
- if echo "$a" | grep --color=auto -q "="; then
- interpreter="$(echo "$a" | cut -f2 -d=)";
- else
- i=$(( $i + 1 ));
- interpreter="${in_args[$i]}";
- fi
- ;;
- -r)
- i=$(( $i + 1 ));
- requirements="${in_args[$i]}";
- requirements="$(virtualenvwrapper_expandpath "$requirements")"
- ;;
- *)
- if [ ${#out_args} -gt 0 ]; then
- out_args=("${out_args[@]-}" "$a");
- else
- out_args=("$a");
- fi
- ;;
- esac;
- i=$(( $i + 1 ));
- done;
- if [ ! -z $interpreter ]; then
- out_args=("--python=$interpreter" ${out_args[@]});
- fi;
- set -- "${out_args[@]}";
- eval "envname=\$$#";
- virtualenvwrapper_verify_workon_home || return 1;
- virtualenvwrapper_verify_virtualenv || return 1;
- ( [ -n "$ZSH_VERSION" ] && setopt SH_WORD_SPLIT;
- virtualenvwrapper_cd "$WORKON_HOME" && "$VIRTUALENVWRAPPER_VIRTUALENV" $VIRTUALENVWRAPPER_VIRTUALENV_ARGS "$@" && [ -d "$WORKON_HOME/$envname" ] && virtualenvwrapper_run_hook "pre_mkvirtualenv" "$envname" );
- typeset RC=$?;
- [ $RC -ne 0 ] && return $RC;
- [ ! -d "$WORKON_HOME/$envname" ] && return 0;
- if [ ! -z "$project" ]; then
- setvirtualenvproject "$WORKON_HOME/$envname" "$project";
- RC=$?;
- [ $RC -ne 0 ] && return $RC;
- fi;
- workon "$envname";
- if [ ! -z "$requirements" ]; then
- pip install -r "$requirements";
- fi;
- for a in $packages;
- do
- pip install $a;
- done;
- virtualenvwrapper_run_hook "post_mkvirtualenv"
- }
- quote ()
- {
- local quoted=${1//\'/\'\\\'\'};
- printf "'%s'" "$quoted"
- }
- quote_readline ()
- {
- local quoted;
- _quote_readline_by_ref "$1" ret;
- printf %s "$ret"
- }
- rmvirtualenv ()
- {
- virtualenvwrapper_verify_workon_home || return 1;
- if [ ${#@} = 0 ]; then
- echo "Please specify an environment." 1>&2;
- return 1;
- fi;
- typeset env_name;
- for env_name in "$@";
- do
- echo "Removing $env_name...";
- typeset env_dir="$WORKON_HOME/$env_name";
- if [ "$VIRTUAL_ENV" = "$env_dir" ]; then
- echo "ERROR: You cannot remove the active environment ('$env_name')." 1>&2;
- echo "Either switch to another environment, or run 'deactivate'." 1>&2;
- return 1;
- fi;
- if [ ! -d "$env_dir" ]; then
- echo "Did not find environment $env_dir to remove." 1>&2;
- fi;
- typeset prior_dir="$(pwd)";
- virtualenvwrapper_cd "$WORKON_HOME";
- virtualenvwrapper_run_hook "pre_rmvirtualenv" "$env_name";
- command \rm -rf "$env_dir";
- virtualenvwrapper_run_hook "post_rmvirtualenv" "$env_name";
- if [ -d "$prior_dir" ]; then
- virtualenvwrapper_cd "$prior_dir";
- fi;
- done
- }
- setvirtualenvproject ()
- {
- typeset venv="$1";
- typeset prj="$2";
- if [ -z "$venv" ]; then
- venv="$VIRTUAL_ENV";
- fi;
- if [ -z "$prj" ]; then
- prj="$(pwd)";
- else
- prj=$(virtualenvwrapper_absolutepath "${prj}");
- fi;
- if [ ! -d "$venv" ]; then
- venv="$WORKON_HOME/$venv";
- fi;
- if [ ! -d "$venv" ]; then
- echo "No virtualenv $(basename $venv)" 1>&2;
- return 1;
- fi;
- if [ ! -d "$prj" ]; then
- echo "Cannot associate virtualenv with \"$prj\", it is not a directory" 1>&2;
- return 1;
- fi;
- echo "Setting project for $(basename $venv) to $prj";
- echo "$prj" > "$venv/$VIRTUALENVWRAPPER_PROJECT_FILENAME"
- }
- showvirtualenv ()
- {
- typeset env_name="$1";
- if [ -z "$env_name" ]; then
- if [ -z "$VIRTUAL_ENV" ]; then
- echo "showvirtualenv [env]";
- return 1;
- fi;
- env_name=$(basename "$VIRTUAL_ENV");
- fi;
- virtualenvwrapper_run_hook "get_env_details" "$env_name";
- echo
- }
- toggleglobalsitepackages ()
- {
- virtualenvwrapper_verify_workon_home || return 1;
- virtualenvwrapper_verify_active_environment || return 1;
- typeset no_global_site_packages_file="`virtualenvwrapper_get_site_packages_dir`/../no-global-site-packages.txt";
- if [ -f $no_global_site_packages_file ]; then
- rm $no_global_site_packages_file;
- [ "$1" = "-q" ] || echo "Enabled global site-packages";
- else
- touch $no_global_site_packages_file;
- [ "$1" = "-q" ] || echo "Disabled global site-packages";
- fi
- }
- virtualenvwrapper ()
- {
- cat <<EOF
- virtualenvwrapper is a set of extensions to Ian Bicking's virtualenv
- tool. The extensions include wrappers for creating and deleting
- virtual environments and otherwise managing your development workflow,
- making it easier to work on more than one project at a time without
- introducing conflicts in their dependencies.
- For more information please refer to the documentation:
- http://virtualenvwrapper.readthedocs.org/en/latest/command_ref.html
- Commands available:
- EOF
- typeset helpmarker="#:help:"
- cat "$VIRTUALENVWRAPPER_SCRIPT" | grep --color=auto "^$helpmarker" | sed -e "s/^$helpmarker/ /g" | sort | sed -e 's/$/\''
- /g'
- }
- virtualenvwrapper_absolutepath ()
- {
- if [ "$1" = "" ]; then
- return 1;
- else
- "$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.abspath(\"$1\")+'\n')";
- return 0;
- fi
- }
- virtualenvwrapper_cd ()
- {
- if [ -n "${BASH:-}" ]; then
- builtin \cd "$@";
- else
- if [ -n "${ZSH_VERSION:-}" ]; then
- builtin \cd -q "$@";
- else
- command \cd "$@";
- fi;
- fi
- }
- virtualenvwrapper_derive_workon_home ()
- {
- typeset workon_home_dir="$WORKON_HOME";
- if [ "$workon_home_dir" = "" ]; then
- workon_home_dir="$HOME/.virtualenvs";
- fi;
- if echo "$workon_home_dir" | ( unset GREP_OPTIONS;
- command \grep '^[^/~]' > /dev/null ); then
- workon_home_dir="$HOME/$WORKON_HOME";
- fi;
- if echo "$workon_home_dir" | ( unset GREP_OPTIONS;
- command \egrep '([\$~]|//)' > /dev/null ); then
- workon_home_dir="$(virtualenvwrapper_expandpath "$workon_home_dir")";
- fi;
- echo "$workon_home_dir";
- return 0
- }
- virtualenvwrapper_expandpath ()
- {
- if [ "$1" = "" ]; then
- return 1;
- else
- "$VIRTUALENVWRAPPER_PYTHON" -c "import os,sys; sys.stdout.write(os.path.normpath(os.path.expanduser(os.path.expandvars(\"$1\")))+'\n')";
- return 0;
- fi
- }
- virtualenvwrapper_get_python_version ()
- {
- "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/python" -V 2>&1 | cut -f2 -d' ' | cut -f-2 -d.
- }
- virtualenvwrapper_get_site_packages_dir ()
- {
- "$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/python" -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib())"
- }
- virtualenvwrapper_initialize ()
- {
- export WORKON_HOME="$(virtualenvwrapper_derive_workon_home)";
- virtualenvwrapper_verify_workon_home -q || return 1;
- if [ "$VIRTUALENVWRAPPER_HOOK_DIR" = "" ]; then
- VIRTUALENVWRAPPER_HOOK_DIR="$WORKON_HOME";
- fi;
- export VIRTUALENVWRAPPER_HOOK_DIR;
- mkdir -p "$VIRTUALENVWRAPPER_HOOK_DIR";
- virtualenvwrapper_run_hook "initialize";
- virtualenvwrapper_setup_tab_completion;
- return 0
- }
- virtualenvwrapper_mkproject_help ()
- {
- echo "Usage: mkproject [-f|--force] [-t template] [virtualenv options] project_name";
- echo;
- echo "-f, --force Create the virtualenv even if the project directory";
- echo " already exists";
- echo;
- echo "Multiple templates may be selected. They are applied in the order";
- echo "specified on the command line.";
- echo;
- echo "mkvirtualenv help:";
- echo;
- mkvirtualenv -h;
- echo;
- echo "Available project templates:";
- echo;
- "$VIRTUALENVWRAPPER_PYTHON" -c 'from virtualenvwrapper.hook_loader import main; main()' -l project.template
- }
- virtualenvwrapper_mktemp ()
- {
- command \mktemp "$@"
- }
- virtualenvwrapper_mkvirtualenv_help ()
- {
- echo "Usage: mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [virtualenv options] env_name";
- echo;
- echo " -a project_path";
- echo;
- echo " Provide a full path to a project directory to associate with";
- echo " the new environment.";
- echo;
- echo " -i package";
- echo;
- echo " Install a package after the environment is created.";
- echo " This option may be repeated.";
- echo;
- echo " -r requirements_file";
- echo;
- echo " Provide a pip requirements file to install a base set of packages";
- echo " into the new environment.";
- echo;
- echo 'virtualenv help:';
- echo;
- "$VIRTUALENVWRAPPER_VIRTUALENV" $@
- }
- virtualenvwrapper_run_hook ()
- {
- typeset hook_script;
- typeset result;
- hook_script="$(virtualenvwrapper_tempfile ${1}-hook)" || return 1;
- ( virtualenvwrapper_cd "$WORKON_HOME" && "$VIRTUALENVWRAPPER_PYTHON" -m 'virtualenvwrapper.hook_loader' ${HOOK_VERBOSE_OPTION:-} --script "$hook_script" "$@" );
- result=$?;
- if [ $result -eq 0 ]; then
- if [ ! -f "$hook_script" ]; then
- echo "ERROR: virtualenvwrapper_run_hook could not find temporary file $hook_script" 1>&2;
- command \rm -f "$hook_script";
- return 2;
- fi;
- source "$hook_script";
- else
- if [ "${1}" = "initialize" ]; then
- cat - 1>&2 <<EOF
- virtualenvwrapper.sh: There was a problem running the initialization hooks.
- If Python could not import the module virtualenvwrapper.hook_loader,
- check that virtualenvwrapper has been installed for
- VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON and that PATH is
- set properly.
- EOF
- fi;
- fi
- command \rm -f "$hook_script";
- return $result
- }
- virtualenvwrapper_setup_tab_completion ()
- {
- if [ -n "${BASH:-}" ]; then
- function _virtualenvs ()
- {
- local cur="${COMP_WORDS[COMP_CWORD]}";
- COMPREPLY=($(compgen -W "`virtualenvwrapper_show_workon_options`" -- ${cur}))
- };
- function _cdvirtualenv_complete ()
- {
- local cur="$2";
- COMPREPLY=($(cdvirtualenv && compgen -d -- "${cur}" ))
- };
- function _cdsitepackages_complete ()
- {
- local cur="$2";
- COMPREPLY=($(cdsitepackages && compgen -d -- "${cur}" ))
- };
- complete -o nospace -F _cdvirtualenv_complete -S/ cdvirtualenv;
- complete -o nospace -F _cdsitepackages_complete -S/ cdsitepackages;
- complete -o default -o nospace -F _virtualenvs workon;
- complete -o default -o nospace -F _virtualenvs rmvirtualenv;
- complete -o default -o nospace -F _virtualenvs cpvirtualenv;
- complete -o default -o nospace -F _virtualenvs showvirtualenv;
- else
- if [ -n "$ZSH_VERSION" ]; then
- function _virtualenvs ()
- {
- reply=($(virtualenvwrapper_show_workon_options))
- };
- function _cdvirtualenv_complete ()
- {
- reply=($(cdvirtualenv && ls -d ${1}*))
- };
- function _cdsitepackages_complete ()
- {
- reply=($(cdsitepackages && ls -d ${1}*))
- };
- compctl -K _virtualenvs workon rmvirtualenv cpvirtualenv showvirtualenv;
- compctl -K _cdvirtualenv_complete cdvirtualenv;
- compctl -K _cdsitepackages_complete cdsitepackages;
- fi;
- fi
- }
- virtualenvwrapper_show_workon_options ()
- {
- virtualenvwrapper_verify_workon_home || return 1;
- ( virtualenvwrapper_cd "$WORKON_HOME" && echo */$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate ) 2> /dev/null | command \tr "\n" " " | command \sed "s|/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate |/|g" | command \tr "/" "\n" | command \sed "/^\s*$/d" | ( unset GREP_OPTIONS;
- command \egrep -v '^\*$' ) 2> /dev/null
- }
- virtualenvwrapper_tempfile ()
- {
- typeset suffix=${1:-hook};
- typeset file;
- file="$(virtualenvwrapper_mktemp -t virtualenvwrapper-$suffix-XXXXXXXXXX)";
- touch "$file";
- if [ $? -ne 0 ] || [ -z "$file" ] || [ ! -f "$file" ]; then
- echo "ERROR: virtualenvwrapper could not create a temporary file name." 1>&2;
- return 1;
- fi;
- echo $file;
- return 0
- }
- virtualenvwrapper_verify_active_environment ()
- {
- if [ ! -n "${VIRTUAL_ENV}" ] || [ ! -d "${VIRTUAL_ENV}" ]; then
- echo "ERROR: no virtualenv active, or active virtualenv is missing" 1>&2;
- return 1;
- fi;
- return 0
- }
- virtualenvwrapper_verify_project_home ()
- {
- if [ -z "$PROJECT_HOME" ]; then
- echo "ERROR: Set the PROJECT_HOME shell variable to the name of the directory where projects should be created." 1>&2;
- return 1;
- fi;
- if [ ! -d "$PROJECT_HOME" ]; then
- [ "$1" != "-q" ] && echo "ERROR: Project directory '$PROJECT_HOME' does not exist. Create it or set PROJECT_HOME to an existing directory." 1>&2;
- return 1;
- fi;
- return 0
- }
- virtualenvwrapper_verify_resource ()
- {
- typeset exe_path="$(command \which "$1" | (unset GREP_OPTIONS; command \grep -v "not found"))";
- if [ "$exe_path" = "" ]; then
- echo "ERROR: virtualenvwrapper could not find $1 in your path" 1>&2;
- return 1;
- fi;
- if [ ! -e "$exe_path" ]; then
- echo "ERROR: Found $1 in path as \"$exe_path\" but that does not exist" 1>&2;
- return 1;
- fi;
- return 0
- }
- virtualenvwrapper_verify_virtualenv ()
- {
- virtualenvwrapper_verify_resource $VIRTUALENVWRAPPER_VIRTUALENV
- }
- virtualenvwrapper_verify_virtualenv_clone ()
- {
- virtualenvwrapper_verify_resource $VIRTUALENVWRAPPER_VIRTUALENV_CLONE
- }
- virtualenvwrapper_verify_workon_environment ()
- {
- typeset env_name="$1";
- if [ ! -d "$WORKON_HOME/$env_name" ]; then
- echo "ERROR: Environment '$env_name' does not exist. Create it with 'mkvirtualenv $env_name'." 1>&2;
- return 1;
- fi;
- return 0
- }
- virtualenvwrapper_verify_workon_home ()
- {
- RC=0;
- if [ ! -d "$WORKON_HOME/" ]; then
- if [ "$1" != "-q" ]; then
- echo "NOTE: Virtual environments directory $WORKON_HOME does not exist. Creating..." 1>&2;
- fi;
- mkdir -p "$WORKON_HOME";
- RC=$?;
- fi;
- return $RC
- }
- virtualenvwrapper_workon_help ()
- {
- echo "Usage: workon env_name";
- echo "";
- echo " Deactivate any currently activated virtualenv";
- echo " and activate the named environment, triggering";
- echo " any hooks in the process.";
- echo "";
- echo " workon";
- echo "";
- echo " Print a list of available environments.";
- echo " (See also lsvirtualenv -b)";
- echo "";
- echo " workon (-h|--help)";
- echo "";
- echo " Show this help message.";
- echo "";
- echo " workon (-c|--cd) envname";
- echo "";
- echo " After activating the environment, cd to the associated";
- echo " project directory if it is set.";
- echo "";
- echo " workon (-n|--no-cd) envname";
- echo "";
- echo " After activating the environment, do not cd to the";
- echo " associated project directory.";
- echo ""
- }
- wipeenv ()
- {
- virtualenvwrapper_verify_workon_home || return 1;
- virtualenvwrapper_verify_active_environment || return 1;
- typeset req_file="$(virtualenvwrapper_tempfile "requirements.txt")";
- pip freeze | egrep --color=auto -v '(distribute|wsgiref|appdirs|packaging|pyparsing|six)' > "$req_file";
- if [ -n "$(cat "$req_file")" ]; then
- echo "Uninstalling packages:";
- cat "$req_file";
- echo;
- pip uninstall -y $(cat "$req_file" | grep -v '^-f' | sed 's/>/=/g' | cut -f1 -d=);
- else
- echo "Nothing to remove.";
- fi;
- rm -f "$req_file"
- }
- workon ()
- {
- typeset -a in_args;
- typeset -a out_args;
- in_args=("$@");
- if [ -n "$ZSH_VERSION" ]; then
- i=1;
- tst="-le";
- else
- i=0;
- tst="-lt";
- fi;
- typeset cd_after_activate=$VIRTUALENVWRAPPER_WORKON_CD;
- while [ $i $tst $# ]; do
- a="${in_args[$i]}";
- case "$a" in
- -h | --help)
- virtualenvwrapper_workon_help;
- return 0
- ;;
- -n | --no-cd)
- cd_after_activate=0
- ;;
- -c | --cd)
- cd_after_activate=1
- ;;
- *)
- if [ ${#out_args} -gt 0 ]; then
- out_args=("${out_args[@]-}" "$a");
- else
- out_args=("$a");
- fi
- ;;
- esac;
- i=$(( $i + 1 ));
- done;
- set -- "${out_args[@]}";
- typeset env_name="$1";
- if [ "$env_name" = "" ]; then
- lsvirtualenv -b;
- return 1;
- else
- if [ "$env_name" = "." ]; then
- IFS='%';
- env_name="$(basename $(pwd))";
- unset IFS;
- fi;
- fi;
- virtualenvwrapper_verify_workon_home || return 1;
- virtualenvwrapper_verify_workon_environment "$env_name" || return 1;
- activate="$WORKON_HOME/$env_name/$VIRTUALENVWRAPPER_ENV_BIN_DIR/activate";
- if [ ! -f "$activate" ]; then
- echo "ERROR: Environment '$WORKON_HOME/$env_name' does not contain an activate script." 1>&2;
- return 1;
- fi;
- type deactivate > /dev/null 2>&1;
- if [ $? -eq 0 ]; then
- typeset -f deactivate | grep --color=auto 'typeset env_postdeactivate_hook' > /dev/null 2>&1;
- if [ $? -eq 0 ]; then
- deactivate;
- unset -f deactivate > /dev/null 2>&1;
- fi;
- fi;
- virtualenvwrapper_run_hook "pre_activate" "$env_name";
- source "$activate";
- virtualenvwrapper_original_deactivate=`typeset -f deactivate | sed 's/deactivate/virtualenv_deactivate/g'`;
- eval "$virtualenvwrapper_original_deactivate";
- unset -f deactivate > /dev/null 2>&1;
- eval 'deactivate () {
- typeset env_postdeactivate_hook
- typeset old_env
- # Call the local hook before the global so we can undo
- # any settings made by the local postactivate first.
- virtualenvwrapper_run_hook "pre_deactivate"
- env_postdeactivate_hook="$VIRTUAL_ENV/$VIRTUALENVWRAPPER_ENV_BIN_DIR/postdeactivate"
- old_env=$(basename "$VIRTUAL_ENV")
- # Call the original function.
- virtualenv_deactivate $1
- virtualenvwrapper_run_hook "post_deactivate" "$old_env"
- if [ ! "$1" = "nondestructive" ]
- then
- # Remove this function
- unset -f virtualenv_deactivate >/dev/null 2>&1
- unset -f deactivate >/dev/null 2>&1
- fi
- }';
- VIRTUALENVWRAPPER_PROJECT_CD=$cd_after_activate virtualenvwrapper_run_hook "post_activate";
- return 0
- }
Advertisement
Add Comment
Please, Sign In to add comment