commit 35923dd1cc3be50f94077e28569db29a9f6b50d2 Author: Alex Manning Date: Mon Dec 6 10:57:57 2021 +0000 A presentable version of dotfiles which can be made public. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2248efa --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +/mp/* +!**/.gitinclude +**/__pycache__/* + +**/.DS_Store +private diff --git a/home/.bash_logout b/home/.bash_logout new file mode 100644 index 0000000..e69de29 diff --git a/home/.bash_profile b/home/.bash_profile new file mode 100644 index 0000000..57ddc1f --- /dev/null +++ b/home/.bash_profile @@ -0,0 +1,75 @@ +#~/.bash_profile gets ~/.bashrc!! +export AE_ROOT="$HOME/.alex-environ" +export AE_HOME="$AE_ROOT/home" + +#Add user bin directory to $PATH +PATH=$HOME/.cargo/bin:$PATH +PATH=$HOME/.local/bin:$PATH +PATH=$HOME/.config/composer/vendor/bin/:$PATH +PATH=$HOME/scripts:$PATH +PATH=$AE_HOME/.local/bin:$PATH +PATH=$AE_HOME/scripts:$PATH +PATH=/opt/bin:$PATH +export PATH + +PYTHONPATH=$HOME/.python-modules:$PYTHONPATH +export PYTHONPATH + +# If not running interactively, don't do anything else +[[ $- != *i* ]] && return + +#Start an agent upon login, or reconnect to a started agent +if [ -f ~/.alex-environ/home/scripts/ssh_agent_setup ]; then + . ~/.alex-environ/home/scripts/ssh_agent_setup +fi + +# Variable overrides +vimpath="\vim" +export EDITOR="$vimpath" +export VISUAL="$vimpath" +export SYSTEMD_EDITOR="$vimpath" +export SUDO_EDITOR="$vimpath" + +# Fix GPG Bug on WSL. +export GPG_TTY=$(tty) + +# Allow DNSSEC Resolving. +export RES_OPTIONS=edns0 + +#Setup less +export LESS="--ignore-case --status-column -M -R -W --tabs=4 --window=-4" +LESSOPEN="|lesspipe.sh %s"; export LESSOPEN +if type pygmentize >/dev/null 2>&1; then + export LESSCOLORIZER='pygmentize' +fi + +export LESS_TERMCAP_mb=$(tput bold; tput setaf 2) # green +export LESS_TERMCAP_md=$(tput bold; tput setaf 6) # cyan +export LESS_TERMCAP_me=$(tput sgr0) +export LESS_TERMCAP_so=$(tput bold; tput setaf 3; tput setab 4) # yellow on blue +export LESS_TERMCAP_se=$(tput rmso; tput sgr0) +export LESS_TERMCAP_us=$(tput smul; tput bold; tput setaf 7) # white +export LESS_TERMCAP_ue=$(tput rmul; tput sgr0) +export LESS_TERMCAP_mr=$(tput rev) +export LESS_TERMCAP_mh=$(tput dim) +export LESS_TERMCAP_ZN=$(tput ssubm) +export LESS_TERMCAP_ZV=$(tput rsubm) +export LESS_TERMCAP_ZO=$(tput ssupm) +export LESS_TERMCAP_ZW=$(tput rsupm) +export GROFF_NO_SGR=1 # For Konsole and Gnome-terminal + +# Pretty LS Colors +export LS_COLORS="no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=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:*.mng=01;35:*.pcx=01;35:*.yuv=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=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:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.pdf=00;32:*.ps=00;32:*.txt=00;32:*.patch=00;32:*.diff=00;32:*.log=00;32:*.tex=00;32:*.doc=00;32:*.flac=01;35:*.mp3=01;35:*.mpc=00;36:*.ogg=00;36:*.wav=00;36:*.mid=00;36:*.midi=00;36:*.au=00;36:*.flac=00;36:*.aac=00;36:*.ra=01;36:*.mka=01;36:" + +# 1password sudo stuff. +if [ -n "${sudo_pass_uuid}" ] +then + export SUDO_ASKPASS=$AE_HOME/scripts/askpass.sh +fi + +source $AE_HOME/.bashrc.d/functions.sh + +for f in $AE_HOME/.bash_completions/* +do + source $f +done diff --git a/home/.bash_profile.d/prompt b/home/.bash_profile.d/prompt new file mode 100644 index 0000000..9ca457a --- /dev/null +++ b/home/.bash_profile.d/prompt @@ -0,0 +1,7 @@ +# If not running interactively, don't do anything else +[[ $- != *i* ]] && return + +# add a fancy colored prompt. may be best to copy and alter colors for machine Identification + +export PS1='\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \$\[\033[00m\] ' + diff --git a/home/.bash_profile.d/root_prompt b/home/.bash_profile.d/root_prompt new file mode 100644 index 0000000..6ed03e1 --- /dev/null +++ b/home/.bash_profile.d/root_prompt @@ -0,0 +1,5 @@ +# If not running interactively, don't do anything else +[[ $- != *i* ]] && return + +export PS1='\[\033[01;31m\]\u@\h\[\033[00m\] \[\033[01;32m\]\w #\[\033[00m\] ' + diff --git a/home/.bashrc b/home/.bashrc new file mode 100644 index 0000000..f061f7e --- /dev/null +++ b/home/.bashrc @@ -0,0 +1,33 @@ +#Alex's global .bashrc + +# If not running interactively, don't do anything else +[[ $- != *i* ]] && return + +#SET PATH IN .BASH_PROFILE + +#don't put duplicate lines or lines beginning with a space into history +HISTCONTROL=ignoreboth + +#append to the history file, don't overwrite it +shopt -s histappend + +#set some max sizes for the history +HISTSIZE=1000 +HISTFILESIZE=2000 + +#resize window each command +shopt -s checkwinsize + +#set pretty colors for LS +alias ls='ls --color=auto' +alias grep='grep --color=auto' +alias jprint='python3 -m json.tool' +alias sl='ls --color=auto' +alias vim='vim -p' + +# Onepassword sudo stuff. +if [ -n "${sudo_pass_uuid}" ] +then + alias sudo='sudo -A' +fi + diff --git a/home/.bashrc.d/functions.sh b/home/.bashrc.d/functions.sh new file mode 100644 index 0000000..4696ed1 --- /dev/null +++ b/home/.bashrc.d/functions.sh @@ -0,0 +1,23 @@ +opin() { + export PERSIST_OP=1 + opon +} + +opout() { + unset PERSIST_OP + opoff +} + +opon() { + op list vaults 2>&1 > /dev/null || unset OP_SESSION_my + if [[ -z $OP_SESSION_my ]]; then + eval $(op signin my) + fi +} + +opoff() { + if [[ -z $PERSIST_OP ]] + then + op signout + fi +} diff --git a/home/.bashrc.d/prompt b/home/.bashrc.d/prompt new file mode 120000 index 0000000..da7cd16 --- /dev/null +++ b/home/.bashrc.d/prompt @@ -0,0 +1 @@ +../.bash_profile.d/prompt \ No newline at end of file diff --git a/home/.bashrc.d/root_prompt b/home/.bashrc.d/root_prompt new file mode 120000 index 0000000..d0e2e3d --- /dev/null +++ b/home/.bashrc.d/root_prompt @@ -0,0 +1 @@ +../.bash_profile.d/root_prompt \ No newline at end of file diff --git a/home/.bashrc.d/work b/home/.bashrc.d/work new file mode 100644 index 0000000..13ec4fe --- /dev/null +++ b/home/.bashrc.d/work @@ -0,0 +1,6 @@ +# If not running interactively, don't do anything else +[[ $- != *i* ]] && return + +#things for uni/work machines + +alias sudo='echo "You will probably get told off if you do that"' diff --git a/home/.config/flake8 b/home/.config/flake8 new file mode 100644 index 0000000..aa37975 --- /dev/null +++ b/home/.config/flake8 @@ -0,0 +1,7 @@ +[flake8] +ignore = E203, E266, E501, W503, B950 +# line length is intentionally set to 80 here because black uses Bugbear +# See https://github.com/psf/black/blob/master/README.md#line-length for more details +max-line-length = 80 +max-complexity = 18 +select = B,C,E,F,W,T4,B9 diff --git a/home/.config/matplotlib/matplotlibrc b/home/.config/matplotlib/matplotlibrc new file mode 100644 index 0000000..f98228c --- /dev/null +++ b/home/.config/matplotlib/matplotlibrc @@ -0,0 +1,630 @@ +### MATPLOTLIBRC FORMAT + +# This is a sample matplotlib configuration file - you can find a copy +# of it on your system in +# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it +# there, please note that it will be overwritten in your next install. +# If you want to keep a permanent local copy that will not be +# overwritten, place it in the following location: +# unix/linux: +# $HOME/.config/matplotlib/matplotlibrc or +# $XDG_CONFIG_HOME/matplotlib/matplotlibrc (if $XDG_CONFIG_HOME is set) +# other platforms: +# $HOME/.matplotlib/matplotlibrc +# +# See http://matplotlib.org/users/customizing.html#the-matplotlibrc-file for +# more details on the paths which are checked for the configuration file. +# +# This file is best viewed in a editor which supports python mode +# syntax highlighting. Blank lines, or lines starting with a comment +# symbol, are ignored, as are trailing comments. Other lines must +# have the format +# key : val # optional comment +# +# Colors: for the color values below, you can either use - a +# matplotlib color string, such as r, k, or b - an rgb tuple, such as +# (1.0, 0.5, 0.0) - a hex string, such as ff00ff - a scalar +# grayscale intensity such as 0.75 - a legal html color name, e.g., red, +# blue, darkslategray + +#### CONFIGURATION BEGINS HERE + +# The default backend; one of GTK GTKAgg GTKCairo GTK3Agg GTK3Cairo +# MacOSX Qt4Agg Qt5Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG +# Template. +# You can also deploy your own backend outside of matplotlib by +# referring to the module name (which must be in the PYTHONPATH) as +# 'module://my_backend'. +backend : TkAgg + +# If you are using the Qt4Agg backend, you can choose here +# to use the PyQt4 bindings or the newer PySide bindings to +# the underlying Qt4 toolkit. +#backend.qt4 : PyQt4 # PyQt4 | PySide + +# Note that this can be overridden by the environment variable +# QT_API used by Enthought Tool Suite (ETS); valid values are +# "pyqt" and "pyside". The "pyqt" setting has the side effect of +# forcing the use of Version 2 API for QString and QVariant. + +# The port to use for the web server in the WebAgg backend. +# webagg.port : 8888 + +# If webagg.port is unavailable, a number of other random ports will +# be tried until one that is available is found. +# webagg.port_retries : 50 + +# When True, open the webbrowser to the plot that is shown +# webagg.open_in_browser : True + +# When True, the figures rendered in the nbagg backend are created with +# a transparent background. +# nbagg.transparent : False + +# if you are running pyplot inside a GUI and your backend choice +# conflicts, we will automatically try to find a compatible one for +# you if backend_fallback is True +backend_fallback: True + +#interactive : False +#toolbar : toolbar2 # None | toolbar2 ("classic" is deprecated) +#timezone : UTC # a pytz timezone string, e.g., US/Central or Europe/Paris + +# Where your matplotlib data lives if you installed to a non-default +# location. This is where the matplotlib fonts, bitmaps, etc reside +#datapath : /home/jdhunter/mpldata + + +### LINES +# See http://matplotlib.org/api/artist_api.html#module-matplotlib.lines for more +# information on line properties. +lines.linewidth : 0.5 # line width in points +#lines.linestyle : - # solid line +#lines.color : C0 # has no affect on plot(); see axes.prop_cycle +#lines.marker : None # the default marker +#lines.markeredgewidth : 1.0 # the line width around the marker symbol +#lines.markersize : 6 # markersize, in points +#lines.dash_joinstyle : miter # miter|round|bevel +#lines.dash_capstyle : butt # butt|round|projecting +#lines.solid_joinstyle : miter # miter|round|bevel +#lines.solid_capstyle : projecting # butt|round|projecting +#lines.antialiased : True # render lines in antialiased (no jaggies) + +# The three standard dash patterns. These are scaled by the linewidth. +#lines.dashed_pattern : 2.8, 1.2 +#lines.dashdot_pattern : 4.8, 1.2, 0.8, 1.2 +#lines.dotted_pattern : 1.1, 1.1 +#lines.scale_dashes : True + +#markers.fillstyle: full # full|left|right|bottom|top|none + +### PATCHES +# Patches are graphical objects that fill 2D space, like polygons or +# circles. See +# http://matplotlib.org/api/artist_api.html#module-matplotlib.patches +# information on patch properties +#patch.linewidth : 1 # edge width in points. +#patch.facecolor : C0 +#patch.edgecolor : black # if forced, or patch is not filled +#patch.force_edgecolor : False # True to always use edgecolor +#patch.antialiased : True # render patches in antialiased (no jaggies) + +### HATCHES +#hatch.color : k +#hatch.linewidth : 1.0 + +### Boxplot +#boxplot.notch : False +#boxplot.vertical : True +#boxplot.whiskers : 1.5 +#boxplot.bootstrap : None +#boxplot.patchartist : False +#boxplot.showmeans : False +#boxplot.showcaps : True +#boxplot.showbox : True +#boxplot.showfliers : True +#boxplot.meanline : False + +#boxplot.flierprops.color : 'k' +#boxplot.flierprops.marker : 'o' +#boxplot.flierprops.markerfacecolor : 'none' +#boxplot.flierprops.markeredgecolor : 'k' +#boxplot.flierprops.markersize : 6 +#boxplot.flierprops.linestyle : 'none' +#boxplot.flierprops.linewidth : 1.0 + +#boxplot.boxprops.color : 'k' +#boxplot.boxprops.linewidth : 1.0 +#boxplot.boxprops.linestyle : '-' + +#boxplot.whiskerprops.color : 'k' +#boxplot.whiskerprops.linewidth : 1.0 +#boxplot.whiskerprops.linestyle : '-' + +#boxplot.capprops.color : 'k' +#boxplot.capprops.linewidth : 1.0 +#boxplot.capprops.linestyle : '-' + +#boxplot.medianprops.color : 'C1' +#boxplot.medianprops.linewidth : 1.0 +#boxplot.medianprops.linestyle : '-' + +#boxplot.meanprops.color : 'C2' +#boxplot.meanprops.marker : '^' +#boxplot.meanprops.markerfacecolor : 'C2' +#boxplot.meanprops.markeredgecolor : 'C2' +#boxplot.meanprops.markersize : 6 +#boxplot.meanprops.linestyle : 'none' +#boxplot.meanprops.linewidth : 1.0 + +### FONT +# +# font properties used by text.Text. See +# http://matplotlib.org/api/font_manager_api.html for more +# information on font properties. The 6 font properties used for font +# matching are given below with their default values. +# +# The font.family property has five values: 'serif' (e.g., Times), +# 'sans-serif' (e.g., Helvetica), 'cursive' (e.g., Zapf-Chancery), +# 'fantasy' (e.g., Western), and 'monospace' (e.g., Courier). Each of +# these font families has a default list of font names in decreasing +# order of priority associated with them. When text.usetex is False, +# font.family may also be one or more concrete font names. +# +# The font.style property has three values: normal (or roman), italic +# or oblique. The oblique style will be used for italic, if it is not +# present. +# +# The font.variant property has two values: normal or small-caps. For +# TrueType fonts, which are scalable fonts, small-caps is equivalent +# to using a font size of 'smaller', or about 83%% of the current font +# size. +# +# The font.weight property has effectively 13 values: normal, bold, +# bolder, lighter, 100, 200, 300, ..., 900. Normal is the same as +# 400, and bold is 700. bolder and lighter are relative values with +# respect to the current weight. +# +# The font.stretch property has 11 values: ultra-condensed, +# extra-condensed, condensed, semi-condensed, normal, semi-expanded, +# expanded, extra-expanded, ultra-expanded, wider, and narrower. This +# property is not currently implemented. +# +# The font.size property is the default font size for text, given in pts. +# 10 pt is the standard value. +# +font.family : sans-serif +font.style : normal +font.variant : normal +font.weight : medium +font.stretch : normal +# note that font.size controls default text sizes. To configure +# special text sizes tick labels, axes, labels, title, etc, see the rc +# settings for axes and ticks. Special text sizes can be defined +# relative to font.size, using the following values: xx-small, x-small, +# small, medium, large, x-large, xx-large, larger, or smaller +#font.size : 10.0 +#font.serif : DejaVu Serif, Bitstream Vera Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif +font.sans-serif : CMU Sans Serif, Helvetica, DejaVu Sans, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Avant Garde, sans-serif +#font.cursive : Apple Chancery, Textile, Zapf Chancery, Sand, Script MT, Felipa, cursive +#font.fantasy : Comic Sans MS, Chicago, Charcoal, Impact, Western, Humor Sans, xkcd, fantasy +#font.monospace : DejaVu Sans Mono, Bitstream Vera Sans Mono, Andale Mono, Nimbus Mono L, Courier New, Courier, Fixed, Terminal, monospace + +### TEXT +# text properties used by text.Text. See +# http://matplotlib.org/api/artist_api.html#module-matplotlib.text for more +# information on text properties + +#text.color : black + +### LaTeX customizations. See http://wiki.scipy.org/Cookbook/Matplotlib/UsingTex +text.usetex : False # use latex for all text handling. The following fonts + # are supported through the usual rc parameter settings: + # new century schoolbook, bookman, times, palatino, + # zapf chancery, charter, serif, sans-serif, helvetica, + # avant garde, courier, monospace, computer modern roman, + # computer modern sans serif, computer modern typewriter + # If another font is desired which can loaded using the + # LaTeX \usepackage command, please inquire at the + # matplotlib mailing list +#text.latex.unicode : True # use "ucs" and "inputenc" LaTeX packages for handling + # unicode strings. +#text.latex.preamble : # IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURES + # AND IS THEREFORE UNSUPPORTED. PLEASE DO NOT ASK FOR HELP + # IF THIS FEATURE DOES NOT DO WHAT YOU EXPECT IT TO. + # preamble is a comma separated list of LaTeX statements + # that are included in the LaTeX document preamble. + # An example: + # text.latex.preamble : \usepackage{bm},\usepackage{euler} + # The following packages are always loaded with usetex, so + # beware of package collisions: color, geometry, graphicx, + # type1cm, textcomp. Adobe Postscript (PSSNFS) font packages + # may also be loaded, depending on your font settings + +#text.dvipnghack : None # some versions of dvipng don't handle alpha + # channel properly. Use True to correct + # and flush ~/.matplotlib/tex.cache + # before testing and False to force + # correction off. None will try and + # guess based on your dvipng version + +#text.hinting : auto # May be one of the following: + # 'none': Perform no hinting + # 'auto': Use FreeType's autohinter + # 'native': Use the hinting information in the + # font file, if available, and if your + # FreeType library supports it + # 'either': Use the native hinting information, + # or the autohinter if none is available. + # For backward compatibility, this value may also be + # True === 'auto' or False === 'none'. +#text.hinting_factor : 8 # Specifies the amount of softness for hinting in the + # horizontal direction. A value of 1 will hint to full + # pixels. A value of 2 will hint to half pixels etc. + +#text.antialiased : True # If True (default), the text will be antialiased. + # This only affects the Agg backend. + +# The following settings allow you to select the fonts in math mode. +# They map from a TeX font name to a fontconfig font pattern. +# These settings are only used if mathtext.fontset is 'custom'. +# Note that this "custom" mode is unsupported and may go away in the +# future. +mathtext.cal : CMU Sans Serif:oblique +mathtext.rm : CMU Sans Serif +mathtext.tt : CMU Sans Serif +mathtext.it : CMU Sans Serif:oblique +mathtext.bf : CMU Sans Serif:bold +mathtext.sf : CMU Sans Serif +mathtext.fontset : custom # Should be 'dejavusans' (default), + # 'dejavuserif', 'cm' (Computer Modern), 'stix', + # 'stixsans' or 'custom' +#mathtext.fallback_to_cm : True # When True, use symbols from the Computer Modern +mathtext.fallback : cm + # fonts when a symbol can not be found in one of + # the custom math fonts. + +mathtext.default : regular #regular # The default font to use for math. + # Can be any of the LaTeX font names, including + # the special name "regular" for the same font + # used in regular text. + +### AXES +# default face and edge color, default tick sizes, +# default fontsizes for ticklabels, and so on. See +# http://matplotlib.org/api/axes_api.html#module-matplotlib.axes +#axes.facecolor : white # axes background color +#axes.edgecolor : black # axes edge color +#axes.linewidth : 0.8 # edge linewidth +#axes.grid : False # display grid or not +axes.titlesize : 10 # fontsize of the axes title +#axes.titlepad : 6.0 # pad between axes and title in points +axes.labelsize : 8 # fontsize of the x any y labels +#axes.labelpad : 4.0 # space between label and axis +#axes.labelweight : normal # weight of the x and y labels +#axes.labelcolor : black +#axes.axisbelow : 'line' # draw axis gridlines and ticks below + # patches (True); above patches but below + # lines ('line'); or above all (False) + +#axes.formatter.limits : -7, 7 # use scientific notation if log10 + # of the axis range is smaller than the + # first or larger than the second +#axes.formatter.use_locale : False # When True, format tick labels + # according to the user's locale. + # For example, use ',' as a decimal + # separator in the fr_FR locale. +#axes.formatter.use_mathtext : False # When True, use mathtext for scientific + # notation. +#axes.formatter.useoffset : True # If True, the tick label formatter + # will default to labeling ticks relative + # to an offset when the data range is + # small compared to the minimum absolute + # value of the data. +#axes.formatter.offset_threshold : 4 # When useoffset is True, the offset + # will be used when it can remove + # at least this number of significant + # digits from tick labels. + +# axes.spines.left : True # display axis spines +# axes.spines.bottom : True +# axes.spines.top : True +# axes.spines.right : True + + +#axes.unicode_minus : True # use unicode for the minus symbol + # rather than hyphen. See + # http://en.wikipedia.org/wiki/Plus_and_minus_signs#Character_codes +#axes.prop_cycle : cycler('color', +# ['1f77b4', 'ff7f0e', '2ca02c', 'd62728', +# '9467bd', '8c564b', 'e377c2', '7f7f7f', +# 'bcbd22', '17becf']) + # color cycle for plot lines + # as list of string colorspecs: + # single letter, long name, or + # web-style hex +#axes.autolimit_mode : data # How to scale axes limits to the data. + # Use "data" to use data limits, plus some margin + # Use "round_number" move to the nearest "round" number +#axes.xmargin : .05 # x margin. See `axes.Axes.margins` +#axes.ymargin : .05 # y margin See `axes.Axes.margins` + +#polaraxes.grid : True # display grid on polar axes +#axes3d.grid : True # display grid on 3d axes + +### DATES +# These control the default format strings used in AutoDateFormatter. +# Any valid format datetime format string can be used (see the python +# `datetime` for details). For example using '%%x' will use the locale date representation +# '%%X' will use the locale time representation and '%%c' will use the full locale datetime +# representation. +# These values map to the scales: +# {'year': 365, 'month': 30, 'day': 1, 'hour': 1/24, 'minute': 1 / (24 * 60)} + + date.autoformatter.year : %Y + date.autoformatter.month : %m/%Y + date.autoformatter.day : %d/%m/%Y + date.autoformatter.hour : %d/%m %H + date.autoformatter.minute : %d %H:%M + date.autoformatter.second : %H:%M:%S + date.autoformatter.microsecond : %M:%S.%f + +### TICKS +# see http://matplotlib.org/api/axis_api.html#matplotlib.axis.Tick +#xtick.top : False # draw ticks on the top side +#xtick.bottom : True # draw ticks on the bottom side +#xtick.major.size : 3.5 # major tick size in points +#xtick.minor.size : 2 # minor tick size in points +#xtick.major.width : 0.8 # major tick width in points +#xtick.minor.width : 0.6 # minor tick width in points +#xtick.major.pad : 3.5 # distance to major tick label in points +#xtick.minor.pad : 3.4 # distance to the minor tick label in points +#xtick.color : k # color of the tick labels +xtick.labelsize : 6 # fontsize of the tick labels +#xtick.direction : out # direction: in, out, or inout +#xtick.minor.visible : False # visibility of minor ticks on x-axis +#xtick.major.top : True # draw x axis top major ticks +#xtick.major.bottom : True # draw x axis bottom major ticks +#xtick.minor.top : True # draw x axis top minor ticks +#xtick.minor.bottom : True # draw x axis bottom minor ticks + +#ytick.left : True # draw ticks on the left side +#ytick.right : False # draw ticks on the right side +#ytick.major.size : 3.5 # major tick size in points +#ytick.minor.size : 2 # minor tick size in points +#ytick.major.width : 0.8 # major tick width in points +#ytick.minor.width : 0.6 # minor tick width in points +#ytick.major.pad : 3.5 # distance to major tick label in points +#ytick.minor.pad : 3.4 # distance to the minor tick label in points +#ytick.color : k # color of the tick labels +ytick.labelsize : 6 # fontsize of the tick labels +#ytick.direction : out # direction: in, out, or inout +#ytick.minor.visible : False # visibility of minor ticks on y-axis +#ytick.major.left : True # draw y axis left major ticks +#ytick.major.right : True # draw y axis right major ticks +#ytick.minor.left : True # draw y axis left minor ticks +#ytick.minor.right : True # draw y axis right minor ticks + + +### GRIDS +#grid.color : b0b0b0 # grid color +#grid.linestyle : - # solid +#grid.linewidth : 0.8 # in points +#grid.alpha : 1.0 # transparency, between 0.0 and 1.0 + +### Legend +#legend.loc : best +#legend.frameon : True # if True, draw the legend on a background patch +#legend.framealpha : 0.8 # legend patch transparency +#legend.facecolor : inherit # inherit from axes.facecolor; or color spec +#legend.edgecolor : 0.8 # background patch boundary color +#legend.fancybox : True # if True, use a rounded box for the + # legend background, else a rectangle +#legend.shadow : False # if True, give background a shadow effect +#legend.numpoints : 1 # the number of marker points in the legend line +#legend.scatterpoints : 1 # number of scatter points +#legend.markerscale : 1.0 # the relative size of legend markers vs. original +legend.fontsize : 8 +# Dimensions as fraction of fontsize: +#legend.borderpad : 0.4 # border whitespace +#legend.labelspacing : 0.5 # the vertical space between the legend entries +#legend.handlelength : 2.0 # the length of the legend lines +#legend.handleheight : 0.7 # the height of the legend handle +#legend.handletextpad : 0.8 # the space between the legend line and legend text +#legend.borderaxespad : 0.5 # the border between the axes and legend edge +#legend.columnspacing : 2.0 # column separation + +### FIGURE +# See http://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure +figure.titlesize : 14 # size of the figure title (Figure.suptitle()) +#figure.titleweight : normal # weight of the figure title +#figure.figsize : 8, 6 # figure size in inches 6.4, 4.8 +figure.dpi : 150 # figure dots per inch +#figure.facecolor : white # figure facecolor; 0.75 is scalar gray +#figure.edgecolor : white # figure edgecolor +#figure.autolayout : True # When True, automatically adjust subplot + # parameters to make the plot fit the figure +figure.max_open_warning : 50 # The maximum number of figures to open through + # the pyplot interface before emitting a warning. + # If less than one this feature is disabled. + +# The figure subplot parameters. All dimensions are a fraction of the +#figure.subplot.left : 0.125 # the left side of the subplots of the figure +#figure.subplot.right : 0.9 # the right side of the subplots of the figure +#figure.subplot.bottom : 0.11 # the bottom of the subplots of the figure +#figure.subplot.top : 0.88 # the top of the subplots of the figure +#figure.subplot.wspace : 0.2 # the amount of width reserved for blank space between subplots, + # expressed as a fraction of the average axis width +#figure.subplot.hspace : 0.2 # the amount of height reserved for white space between subplots, + # expressed as a fraction of the average axis height + + +### IMAGES +#image.aspect : equal # equal | auto | a number +#image.interpolation : nearest # see help(imshow) for options +#image.cmap : viridis # A colormap name, gray etc... +#image.lut : 256 # the size of the colormap lookup table +#image.origin : upper # lower | upper +#image.resample : True +#image.composite_image : True # When True, all the images on a set of axes are + # combined into a single composite image before + # saving a figure as a vector graphics file, + # such as a PDF. + +### CONTOUR PLOTS +#contour.negative_linestyle : dashed # dashed | solid +#contour.corner_mask : True # True | False | legacy + +### ERRORBAR PLOTS +#errorbar.capsize : 0 # length of end cap on error bars in pixels + +### HISTOGRAM PLOTS +#hist.bins : 10 # The default number of histogram bins. + # If Numpy 1.11 or later is + # installed, may also be `auto` + +### SCATTER PLOTS +#scatter.marker : o # The default marker type for scatter plots. + +### Agg rendering +### Warning: experimental, 2008/10/10 +#agg.path.chunksize : 0 # 0 to disable; values in the range + # 10000 to 100000 can improve speed slightly + # and prevent an Agg rendering failure + # when plotting very large data sets, + # especially if they are very gappy. + # It may cause minor artifacts, though. + # A value of 20000 is probably a good + # starting point. +### SAVING FIGURES +#path.simplify : True # When True, simplify paths by removing "invisible" + # points to reduce file size and increase rendering + # speed +#path.simplify_threshold : 0.1 # The threshold of similarity below which + # vertices will be removed in the simplification + # process +#path.snap : True # When True, rectilinear axis-aligned paths will be snapped to + # the nearest pixel when certain criteria are met. When False, + # paths will never be snapped. +#path.sketch : None # May be none, or a 3-tuple of the form (scale, length, + # randomness). + # *scale* is the amplitude of the wiggle + # perpendicular to the line (in pixels). *length* + # is the length of the wiggle along the line (in + # pixels). *randomness* is the factor by which + # the length is randomly scaled. + +# the default savefig params can be different from the display params +# e.g., you may want a higher resolution, or to make the figure +# background white +savefig.dpi : 300 # figure dots per inch or 'figure' +#savefig.facecolor : white # figure facecolor when saving +#savefig.edgecolor : white # figure edgecolor when saving +#savefig.format : png # png, ps, pdf, svg +savefig.bbox : tight # 'tight' or 'standard'. + # 'tight' is incompatible with pipe-based animation + # backends but will workd with temporary file based ones: + # e.g. setting animation.writer to ffmpeg will not work, + # use ffmpeg_file instead +#savefig.pad_inches : 0.1 # Padding to be used when bbox is set to 'tight' +#savefig.jpeg_quality: 95 # when a jpeg is saved, the default quality parameter. +#savefig.directory : ~ # default directory in savefig dialog box, + # leave empty to always use current working directory +#savefig.transparent : False # setting that controls whether figures are saved with a + # transparent background by default + +# tk backend params +#tk.window_focus : False # Maintain shell focus for TkAgg + +# ps backend params +#ps.papersize : letter # auto, letter, legal, ledger, A0-A10, B0-B10 +#ps.useafm : False # use of afm fonts, results in small files +#ps.usedistiller : False # can be: None, ghostscript or xpdf + # Experimental: may produce smaller files. + # xpdf intended for production of publication quality files, + # but requires ghostscript, xpdf and ps2eps +#ps.distiller.res : 6000 # dpi +#ps.fonttype : 3 # Output Type 3 (Type3) or Type 42 (TrueType) + +# pdf backend params +#pdf.compression : 6 # integer from 0 to 9 + # 0 disables compression (good for debugging) +#pdf.fonttype : 3 # Output Type 3 (Type3) or Type 42 (TrueType) + +# svg backend params +#svg.image_inline : True # write raster image data directly into the svg file +#svg.fonttype : 'path' # How to handle SVG fonts: +# 'none': Assume fonts are installed on the machine where the SVG will be viewed. +# 'path': Embed characters as paths -- supported by most SVG renderers +# 'svgfont': Embed characters as SVG fonts -- supported only by Chrome, +# Opera and Safari +#svg.hashsalt : None # if not None, use this string as hash salt + # instead of uuid4 + +# docstring params +#docstring.hardcopy = False # set this when you want to generate hardcopy docstring + +# Set the verbose flags. This controls how much information +# matplotlib gives you at runtime and where it goes. The verbosity +# levels are: silent, helpful, debug, debug-annoying. Any level is +# inclusive of all the levels below it. If your setting is "debug", +# you'll get all the debug and helpful messages. When submitting +# problems to the mailing-list, please set verbose to "helpful" or "debug" +# and paste the output into your report. +# +# The "fileo" gives the destination for any calls to verbose.report. +# These objects can a filename, or a filehandle like sys.stdout. +# +# You can override the rc default verbosity from the command line by +# giving the flags --verbose-LEVEL where LEVEL is one of the legal +# levels, e.g., --verbose-helpful. +# +# You can access the verbose instance in your code +# from matplotlib import verbose. +#verbose.level : silent # helpful # one of silent, helpful, debug, debug-annoying +#verbose.fileo : sys.stderr # a log filename, sys.stdout or sys.stderr + +# Event keys to interact with figures/plots via keyboard. +# Customize these settings according to your needs. +# Leave the field(s) empty if you don't need a key-map. (i.e., fullscreen : '') + +#keymap.fullscreen : f, ctrl+f # toggling +#keymap.home : h, r, home # home or reset mnemonic +#keymap.back : left, c, backspace # forward / backward keys to enable +#keymap.forward : right, v # left handed quick navigation +#keymap.pan : p # pan mnemonic +#keymap.zoom : o # zoom mnemonic +#keymap.save : s # saving current figure +#keymap.quit : ctrl+w, cmd+w # close the current figure +#keymap.grid : g # switching on/off a grid in current axes +#keymap.yscale : l # toggle scaling of y-axes ('log'/'linear') +#keymap.xscale : L, k # toggle scaling of x-axes ('log'/'linear') +#keymap.all_axes : a # enable all axes + +# Control location of examples data files +#examples.directory : '' # directory to look in for custom installation + +###ANIMATION settings +#animation.html : 'none' # How to display the animation as HTML in + # the IPython notebook. 'html5' uses + # HTML5 video tag. +#animation.writer : ffmpeg # MovieWriter 'backend' to use +#animation.codec : h264 # Codec to use for writing movie +#animation.bitrate: -1 # Controls size/quality tradeoff for movie. + # -1 implies let utility auto-determine +#animation.frame_format: 'png' # Controls frame format used by temp files +#animation.ffmpeg_path: 'ffmpeg' # Path to ffmpeg binary. Without full path + # $PATH is searched +#animation.ffmpeg_args: '' # Additional arguments to pass to ffmpeg +#animation.avconv_path: 'avconv' # Path to avconv binary. Without full path + # $PATH is searched +#animation.avconv_args: '' # Additional arguments to pass to avconv +#animation.mencoder_path: 'mencoder' + # Path to mencoder binary. Without full path + # $PATH is searched +#animation.mencoder_args: '' # Additional arguments to pass to mencoder +#animation.convert_path: 'convert' # Path to ImageMagick's convert binary. + # On Windows use the full path since convert + # is also the name of a system tool. + # +mpl_toolkits.legacy_colorbar: False diff --git a/home/.config/mypy/config b/home/.config/mypy/config new file mode 100644 index 0000000..976ba02 --- /dev/null +++ b/home/.config/mypy/config @@ -0,0 +1,2 @@ +[mypy] +ignore_missing_imports = True diff --git a/home/.config/pylintrc b/home/.config/pylintrc new file mode 100644 index 0000000..8968fa3 --- /dev/null +++ b/home/.config/pylintrc @@ -0,0 +1,576 @@ +[MASTER] + +# A comma-separated list of package or module names from where C extensions may +# be loaded. Extensions are loading into the active Python interpreter and may +# run arbitrary code. +extension-pkg-whitelist= + +# Add files or directories to the blacklist. They should be base names, not +# paths. +ignore=CVS + +# Add files or directories matching the regex patterns to the blacklist. The +# regex matches against base names, not paths. +ignore-patterns= + +# Python code to execute, usually for sys.path manipulation such as +# pygtk.require(). +#init-hook= + +# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the +# number of processors available to use. +jobs=0 + +# Control the amount of potential inferred values when inferring a single +# object. This can help the performance when dealing with large functions or +# complex, nested conditions. +limit-inference-results=100 + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +load-plugins= + +# Pickle collected data for later comparisons. +persistent=yes + +# Specify a configuration file. +#rcfile= + +# When enabled, pylint would attempt to guess common misconfiguration and emit +# user-friendly hints instead of false-positive error messages. +suggestion-mode=yes + +# Allow loading of arbitrary C extensions. Extensions are imported into the +# active Python interpreter and may run arbitrary code. +unsafe-load-any-extension=no + + +[MESSAGES CONTROL] + +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED. +confidence= + +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once). You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use "--disable=all --enable=classes +# --disable=W". +#disable=print-statement, +# parameter-unpacking, +# unpacking-in-except, +# old-raise-syntax, +# backtick, +# long-suffix, +# old-ne-operator, +# old-octal-literal, +# import-star-module-level, +# non-ascii-bytes-literal, +# raw-checker-failed, +# bad-inline-option, +# locally-disabled, +# file-ignored, +# suppressed-message, +# useless-suppression, +# deprecated-pragma, +# use-symbolic-message-instead, +# apply-builtin, +# basestring-builtin, +# buffer-builtin, +# cmp-builtin, +# coerce-builtin, +# execfile-builtin, +# file-builtin, +# long-builtin, +# raw_input-builtin, +# reduce-builtin, +# standarderror-builtin, +# unicode-builtin, +# xrange-builtin, +# coerce-method, +# delslice-method, +# getslice-method, +# setslice-method, +# no-absolute-import, +# old-division, +# dict-iter-method, +# dict-view-method, +# next-method-called, +# metaclass-assignment, +# indexing-exception, +# raising-string, +# reload-builtin, +# oct-method, +# hex-method, +# nonzero-method, +# cmp-method, +# input-builtin, +# round-builtin, +# intern-builtin, +# unichr-builtin, +# map-builtin-not-iterating, +# zip-builtin-not-iterating, +# range-builtin-not-iterating, +# filter-builtin-not-iterating, +# using-cmp-argument, +# eq-without-hash, +# div-method, +# idiv-method, +# rdiv-method, +# exception-message-attribute, +# invalid-str-codec, +# sys-max-int, +# bad-python3-import, +# deprecated-string-function, +# deprecated-str-translate-call, +# deprecated-itertools-function, +# deprecated-types-field, +# next-method-defined, +# dict-items-not-iterating, +# dict-keys-not-iterating, +# dict-values-not-iterating, +# deprecated-operator-function, +# deprecated-urllib-function, +# xreadlines-attribute, +# deprecated-sys-function, +# exception-escape, +# comprehension-escape + +disable=bad-continuation,unused-variable,line-too-long + +# Enable the message, report, category or checker with the given id(s). You can +# either give multiple identifier separated by comma (,) or put this option +# multiple time (only on the command line, not in the configuration file where +# it should appear only once). See also the "--disable" option for examples. +#enable=c-extension-no-member + + +[REPORTS] + +# Python expression which should return a note less than 10 (10 is the highest +# note). You have access to the variables errors warning, statement which +# respectively contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (RP0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +# Template used to display messages. This is a python new-style format string +# used to format the message information. See doc for all details. +#msg-template= + +# Set the output format. Available formats are text, parseable, colorized, json +# and msvs (visual studio). You can also give a reporter class, e.g. +# mypackage.mymodule.MyReporterClass. +output-format=text + +# Tells whether to display a full report or only the messages. +reports=no + +# Activate the evaluation score. +score=yes + + +[REFACTORING] + +# Maximum number of nested blocks for function / method body +max-nested-blocks=5 + +# Complete name of functions that never returns. When checking for +# inconsistent-return-statements if a never returning function is called then +# it will be considered as an explicit return statement and no message will be +# printed. +never-returning-functions=sys.exit + + +[FORMAT] + +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format= + +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )??$ + +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + +# Maximum number of characters on a single line. +max-line-length=88 + +# Maximum number of lines in a module. +max-module-lines=1000 + +# List of optional constructs for which whitespace checking is disabled. `dict- +# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. +# `trailing-comma` allows a space between comma and closing bracket: (a, ). +# `empty-line` allows space-only lines. +no-space-check=trailing-comma, + dict-separator + +# Allow the body of a class to be on the same line as the declaration if body +# contains single statement. +single-line-class-stmt=no + +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no + + +[VARIABLES] + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid defining new builtins when possible. +additional-builtins= + +# Tells whether unused global variables should be treated as a violation. +allow-global-unused-variables=yes + +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_, + _cb + +# A regular expression matching the name of dummy variables (i.e. expected to +# not be used). +dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore. +ignored-argument-names=_.*|^ignored_|^unused_ + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# List of qualified module names which can have objects that can redefine +# builtins. +redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io + + +[LOGGING] + +# Format style used to check logging format string. `old` means using % +# formatting, while `new` is for `{}` formatting. +logging-format-style=old + +# Logging modules to check that the string format arguments are in logging +# function parameter format. +logging-modules=logging + + +[TYPECHECK] + +# List of decorators that produce context managers, such as +# contextlib.contextmanager. Add to this list to register other decorators that +# produce valid context managers. +contextmanager-decorators=contextlib.contextmanager + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E1101 when accessed. Python regular +# expressions are accepted. +generated-members= + +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# Tells whether to warn about missing members when the owner of the attribute +# is inferred to be None. +ignore-none=yes + +# This flag controls whether pylint should warn about no-member and similar +# checks whenever an opaque object is returned when inferring. The inference +# can return multiple potential results while evaluating a Python object, but +# some branches might not be evaluated, which results in partial inference. In +# that case, it might be useful to still emit no-member and other checks for +# the rest of the inferred objects. +ignore-on-opaque-inference=yes + +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=optparse.Values,thread._local,_thread._local + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis. It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules= + +# Show a hint with possible names when a member name was not found. The aspect +# of finding the hint is based on edit distance. +missing-member-hint=yes + +# The minimum edit distance a name should have in order to be considered a +# similar match for a missing member name. +missing-member-hint-distance=1 + +# The total number of similar names that should be taken in consideration when +# showing a hint for a missing member. +missing-member-max-choices=1 + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME, + XXX, + TODO + + +[BASIC] + +# Naming style matching correct argument names. +argument-naming-style=snake_case + +# Regular expression matching correct argument names. Overrides argument- +# naming-style. +#argument-rgx= + +# Naming style matching correct attribute names. +attr-naming-style=snake_case + +# Regular expression matching correct attribute names. Overrides attr-naming- +# style. +#attr-rgx= + +# Bad variable names which should always be refused, separated by a comma. +bad-names=foo, + bar, + baz, + toto, + tutu, + tata + +# Naming style matching correct class attribute names. +class-attribute-naming-style=any + +# Regular expression matching correct class attribute names. Overrides class- +# attribute-naming-style. +#class-attribute-rgx= + +# Naming style matching correct class names. +class-naming-style=PascalCase + +# Regular expression matching correct class names. Overrides class-naming- +# style. +#class-rgx= + +# Naming style matching correct constant names. +const-naming-style=UPPER_CASE + +# Regular expression matching correct constant names. Overrides const-naming- +# style. +#const-rgx= + +# Minimum line length for functions/classes that require docstrings, shorter +# ones are exempt. +docstring-min-length=-1 + +# Naming style matching correct function names. +function-naming-style=snake_case + +# Regular expression matching correct function names. Overrides function- +# naming-style. +#function-rgx= + +# Good variable names which should always be accepted, separated by a comma. +good-names=i, + j, + k, + ex, + ax, + f, + Run, + _, + x, + y + +# Include a hint for the correct naming format with invalid-name. +include-naming-hint=yes + +# Naming style matching correct inline iteration names. +inlinevar-naming-style=any + +# Regular expression matching correct inline iteration names. Overrides +# inlinevar-naming-style. +#inlinevar-rgx= + +# Naming style matching correct method names. +method-naming-style=snake_case + +# Regular expression matching correct method names. Overrides method-naming- +# style. +#method-rgx= + +# Naming style matching correct module names. +module-naming-style=snake_case + +# Regular expression matching correct module names. Overrides module-naming- +# style. +#module-rgx= + +# Colon-delimited sets of names that determine each other's naming style when +# the name regexes allow several styles. +name-group= + +# Regular expression which should only match function or class names that do +# not require a docstring. +no-docstring-rgx=^_ + +# List of decorators that produce properties, such as abc.abstractproperty. Add +# to this list to register other decorators that produce valid properties. +# These decorators are taken in consideration only for invalid-name. +property-classes=abc.abstractproperty + +# Naming style matching correct variable names. +variable-naming-style=snake_case + +# Regular expression matching correct variable names. Overrides variable- +# naming-style. +#variable-rgx= + + +[SPELLING] + +# Limits count of emitted suggestions for spelling mistakes. +max-spelling-suggestions=4 + +# Spelling dictionary name. Available dictionaries: none. To make it working +# install python-enchant package.. +spelling-dict= + +# List of comma separated words that should not be checked. +spelling-ignore-words= + +# A path to a file that contains private dictionary; one word per line. +spelling-private-dict-file= + +# Tells whether to store unknown words to indicated private dictionary in +# --spelling-private-dict-file option instead of raising a message. +spelling-store-unknown-words=no + + +[STRING] + +# This flag controls whether the implicit-str-concat-in-sequence should +# generate a warning on implicit string concatenation in sequences defined over +# several lines. +check-str-concat-over-line-jumps=no + + +[SIMILARITIES] + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + +# Ignore imports when computing similarities. +ignore-imports=no + +# Minimum lines number of a similarity. +min-similarity-lines=4 + + +[IMPORTS] + +# Allow wildcard imports from modules that define __all__. +allow-wildcard-with-all=no + +# Analyse import fallback blocks. This can be used to support both Python 2 and +# 3 compatible code, which means that the block might have code that exists +# only in one or another interpreter, leading to false positives when analysed. +analyse-fallback-blocks=no + +# Deprecated modules which should not be used, separated by a comma. +deprecated-modules=optparse,tkinter.tix + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled). +ext-import-graph= + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled). +import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled). +int-import-graph= + +# Force import order to recognize a module as part of the standard +# compatibility libraries. +known-standard-library= + +# Force import order to recognize a module as part of a third party library. +known-third-party=enchant + + +[CLASSES] + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__, + __new__, + setUp + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict, + _fields, + _replace, + _source, + _make + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=cls + + +[DESIGN] + +# Maximum number of arguments for function / method. +max-args=5 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Maximum number of boolean expressions in an if statement. +max-bool-expr=5 + +# Maximum number of branch for function / method body. +max-branches=12 + +# Maximum number of locals for function / method body. +max-locals=15 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + +# Maximum number of return / yield for function / method body. +max-returns=6 + +# Maximum number of statements in function / method body. +max-statements=50 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when being caught. Defaults to +# "BaseException, Exception". +overgeneral-exceptions=BaseException, + Exception diff --git a/home/.config/yamllint/config b/home/.config/yamllint/config new file mode 100644 index 0000000..a8440e0 --- /dev/null +++ b/home/.config/yamllint/config @@ -0,0 +1,36 @@ +--- + +extends: default + +rules: + braces: enable + brackets: enable + colons: enable + commas: enable + comments: + require-starting-space: true + ignore-shebangs: true + min-spaces-from-content: 1 + comments-indentation: {} + document-end: disable + document-start: + present: true + empty-lines: enable + empty-values: enable + hyphens: enable + indentation: enable + key-duplicates: enable + key-ordering: {} + line-length: enable + new-line-at-end-of-file: enable + new-lines: enable + octal-values: enable + quoted-strings: + quote-type: double + trailing-spaces: enable + truthy: + allowed-values: + - 'true' + - 'false' + - 'on' + - 'off' diff --git a/home/.fonts b/home/.fonts new file mode 120000 index 0000000..84f4310 --- /dev/null +++ b/home/.fonts @@ -0,0 +1 @@ +../private/home/.fonts \ No newline at end of file diff --git a/home/.gitconfig b/home/.gitconfig new file mode 100644 index 0000000..ece139f --- /dev/null +++ b/home/.gitconfig @@ -0,0 +1,21 @@ +[core] + editor = vim + preloadindex = true + fscache = true +[push] + default = simple +[init] + defaultBranch = main +[pull] + rebase = false +[diff] + tool = vimdiff +[merge] + tool = vimdiff +[difftool] + prompt = false +[filter "lfs"] + process = git-lfs filter-process + required = true + clean = git-lfs clean -- %f + smudge = git-lfs smudge -- %f diff --git a/home/.local/bin/code2color b/home/.local/bin/code2color new file mode 100755 index 0000000..aa3aa48 --- /dev/null +++ b/home/.local/bin/code2color @@ -0,0 +1,3393 @@ +#!/usr/bin/env perl + +#use strict; +use Getopt::Long; +use File::Basename; +use POSIX; + +my $VERSION = "0.3"; +my $vernr = "0.9.1"; # this is the underlying version of Peter Palfraders script +########################################################################## +# allow only a limited set of known (external) colorizers +my @colorizers = qw(code2color pygmentize); +########################################################################## +# +# very early check whether this routine is called from less -R or less -r +# or if the variable LESS contains -R or -r +# return if not (escape sequences would not be interpreted as colors) +# on systems with process info in /proc this could be coded in lesspipe.sh +# +########################################################################## +if ( $ARGV[0] =~ /^\d+$/ and $ARGV[1] ) { + # we were called from lesspipe.sh with first arg = PPID + my $PPID = shift; + # if env variable LESS contains -r or -R we are sure that colors get displayed + if ( $ENV{LESS} !~ /-\w*r\w*\b/i ) { + # check if less is called with -r or -R (highly OS dependent) + # tested only for Linux, Solaris, IRIX, True64, MacOS X, FreeBSD and AIX !!! + my $psargs = '-oppid= -oargs='; + if ( $^O eq 'darwin' || $^O =~ /bsd$/ ) { + $psargs = '-oppid -ocommand'; + } elsif ( $^O eq 'hpux' ) { + $procvers = "0.36"; + $psargs = '-f'; + } + eval "use Proc::ProcessTable $procvers"; + if ( $@ ) { + my $p = `ps -p $PPID $psargs`; + exit 1 if $p =~ /\bless\s+/ and $p !~ /less\s+-\w*r\w*\b/is; + if ( $p !~ /\bless\s+/ ) { + if ($p =~ /\d+\s+(\d+)/) { + $PPID = $1; + } else { + $PPID = $1 if $p =~ /(\d+)/; + } + my $p2 = `ps -p $PPID $psargs`; + exit 1 if $p2 !~ /less\s+-\w*r\w*\b/is; + } + } else { + my $pt = new Proc::ProcessTable; + for (@{$pt->table}) { + next unless $_->pid eq $PPID; + $p = $_->cmndline; + exit 1 if $p =~ /\bless\s+/ and $p !~ /less\s+-\w*r\w*\b/i; + if ( $p !~ /\bless\s+/ ) { + $PPID = $_->ppid; + for (@{$pt->table}) { + next unless $_->pid eq $PPID; + $p = $_->cmndline; + exit 1 if $p !~ /less\s+-\w*r\w*\b/i; + } + } + } + } + } +} + +######################################################################## +# # +# Code2HTML # +# --------- # +# # +# Code2Html, peter AT palfrader.org # +# # +# $Date: 2002/01/12 21:17:02 $ +# $Revision: 1.13 $ +# $Id: code2html,v 1.13 2002/01/12 21:17:02 weaselp Exp $ +# # +# AUTHOR # +# Peter Palfrader. Written in 1999, 2000, 2001, 2002. # +# A lot of other people. See CREDITS file. # +# # +# DESCRIPTION # +# code2html is a perlscript which converts a program # +# source code to syntax highlighted HTML by applying a set # +# of regular expressions depending on the language # +# the source code is written. # +# # +# see the man-page for details, # +# # +######################################################################## + +#added 2/2001 bdk +my $LINE_NUMBER_DEFAULT = "none"; # 'none', 'normal', 'linked' +my $REPLACE_TAB_DEFAULT = "8"; + +my $LANG_TEST_LENGTH = 1024; + +my $DEFAULT_OUTPUTFORMAT='xterm'; +my $ENTITIES; +my %ENTITIES; +my $STYLE_AND_LANGUAGE_FLAG; +my %STYLESHEET; +my %LANGUAGE; +Usage() unless @ARGV; +# ======================================================================= +# == subroutines ======================================================== +# ======================================================================= + +sub Usage { + (my $prog = $0) =~ s!.*/!!; + my $time = strftime("%F", localtime( (stat($0))[9])); + print < with spaces +-L, --language-file=LANGUAGE-FILE + specify an alternate file for definitions +-m, --modes print all available modes +-h, --help print this message +-V, --version print version +-c, --content-type prints a Content-Type header +-o, --output-format selects the output-format +-H, --no-header don't use the template + --template=FILE override template +-T, --title set title + +-w, --linewidth max characters per line +-b, --linebreakprefix prefix of the new lines + +see the man-page code2html for further help +EOF + exit; +} + +#### +#### main +#### + +sub main { + my %params = %{shift()}; + my $html; # end result + + # undefine the input record separator so everything gets loaded in one turn + local $/ = undef; # don't propogate this change outside this package. + + # Only set %STYLESHEET and %LANGUAGE if they haven't been + # already set in a previous call ( if, say, we're running + # in a persistent environment under mod_perl) + # or if the langfile is passed in explicitly. + if ( $params{'langfile'} or ! $STYLE_AND_LANGUAGE_FLAG ) { + $STYLE_AND_LANGUAGE_FLAG = 1; # now they will be defined. + + print STDERR "getting patterns...\n" if ($params{'verbose'}); + # building up the database + # newer entries overwrite old ones + my @CONFIG_FILES; + push @CONFIG_FILES, "/etc/code2html.config"; + push @CONFIG_FILES, + $ENV{'HOME'}."/.code2html.config" if $ENV{'HOME'}; + push @CONFIG_FILES, + split(/:/,$ENV{'CODE2HTML_CONFIG'}) if $ENV{'CODE2HTML_CONFIG'}; + push @CONFIG_FILES, + split(/:/,$params{'langfile'}) if $params{'langfile'}; + + %STYLESHEET = %{ &get_default_stylesheet } ; + %LANGUAGE = %{ &get_default_database } ; + + for (@CONFIG_FILES) { + if ( -r $_){ + # if I use `do $_` instead of scalar eval... + # %LANGUAGE is not exported and imported correctly + # (read: at all) (PP) + unless (scalar eval `cat $_`) { + warn "couldn't parse $_: $@" if $@; + }; + }; + }; + } + + # set outputformat + # When called as a package, "die" is impolite. Changed to "return". + # die "Outputformat $params{'outputformat'} not defined" + # unless defined $STYLESHEET{$params{'outputformat'}}; + return "Outputformat $params{'outputformat'} not defined" + unless defined $STYLESHEET{$params{'outputformat'}}; + + my %STYLE = % { $STYLESHEET{$params{'outputformat'}} }; + + # load alternate template if given + if (($params{'template'} ne "") && ( ! $params{'noheader'} )) { +# open (FILE, $params{'template'}) || +# die ("Could not open template file $params{'template'}: $!"); + open (FILE, $params{'template'}) || + return ("Could not open template file $params{'template'}: $!"); + $STYLE{'template'} = ; + close (FILE); + }; + + # set up the global ENTITIES variables ( the scalar and the hash ) + # from the STYLE definition + $ENTITIES = $ { $STYLE{'entities'} }{'listofchars'}; + %ENTITIES = % { $ { $STYLE{'entities'} }{'replace_by' } }; + + # modify the header and footer so that the template variables + # are set correcly + + unless ($STYLE{'template'} =~ /^(.*)%%code%%(.*)$/s) { + return "template does not contain a %%code%% variable"; + }; + + $STYLE{'header'} = $1; + $STYLE{'footer'} = $2; + $STYLE{'header'} =~ s/%%title%%/$params{'title'}/g; + $STYLE{'footer'} =~ s/%%title%%/$params{'title'}/g; + $STYLE{'header'} =~ s/%%version%%/$vernr/g; + $STYLE{'footer'} =~ s/%%version%%/$vernr/g; + + # load the input file and set params{'langmode'} + # if it is not already. this is done by probing a + # set of rules defined in %LANGUAGE + my $code_ref; + print STDERR "loading input file...\n" if ($params{'verbose'}); + $code_ref = &get_input_file(\%params, + \%LANGUAGE, + $params{'langmode'}, + $params{'alt_langmode'}); + + return 0 if ! ref $code_ref; + # select the rules for out language. + my $language_rules_ref = + $LANGUAGE{ lc($params{'langmode'}) }->{'patterns'}; + + print STDERR "applying stylesheet...\n" if ($params{'verbose'}); + # Apply the Stylesheets + # set 'starttag' and 'endtag' for every rule according to + # its 'style' value the tags are defined in the stylesheet + &apply_stylesheets_to_rules( $language_rules_ref, \%STYLE ); + + print STDERR "getting headers ...\n" if ($params{'verbose'}); + $html = &put_headers(\%params, \%STYLE); + + my $snippetlist_ref = [] ; + print STDERR "creating snippet-list...\n" if $params{'verbose'}; + &create_snippetlist( $language_rules_ref, + $$code_ref, $snippetlist_ref, \%STYLE); + + print STDERR "getting html converted code ...\n" if $params{'verbose'}; + $html .= &put_output(\%params, $snippetlist_ref, \%STYLE); + + # --- debug + # print " - debug : \n"; + # foreach my $key (keys %params) { + # print " $key => " . $params{key} . "\n"; + # } + # return " - debug: done"; + # --------- + + $html =~ s/\e\[0m(\e\[\d\d?m)/$1/g; + $ii++ while $html =~ s/(\e\[0m[^\e]+)\e\[0m/$1/g; + + # Output $html code. + if ( $params{outfile} ) { + if ( $params{outfile} eq '-') { + print $html; + } + else { + open(FILEHANDLE, '>'.$params{outfile}) or + return( " Couldn't open output file " . $params{outfile} . "$!"); + + print FILEHANDLE $html; + close FILEHANDLE; + } + } + else { + return $html; + } + + } + + +#### +#### parse_passed_params +#### replaces parse_params for package version of program, +#### constructing %RESULT hash from options passed by calling routine. +sub parse_passed_params { + if ( @_ == 1 ) { + @_ = ( input => $_[0] ); + }; + + my %RESULT = ( + + input => '', # text to convert + + infile => '', # filename to get text from + outfile => '', # file to write html to + + langmode => '', # language (perl,java,html,...) + alt_langmode => 'html', # language to use if can't tell + langfile => '', # more definitions of languages + + line_number_prefix => '', + linenumbers => $LINE_NUMBER_DEFAULT, + outputformat => $DEFAULT_OUTPUTFORMAT, + replacetabs => $REPLACE_TAB_DEFAULT, + + title => '', + noheader => '', # 1 => don't print template + content_type => '', + content_encoding => '', + template => '', # more template definitions + + verbose => '', + what_to_do => 'normal', + + @_ , # any input key=>value pairs + # will override the defaults + # given above. + ); + $RESULT{title} = $RESULT{infile} if $RESULT{infile} && !$RESULT{title}; + $RESULT{title} = 'Code2HTML' unless $RESULT{title}; + if ( $RESULT{linenumbers} and + $RESULT{linenumbers} !~ m/^none|normal|linked$/ ) { + $RESULT{linenumbers} = 'normal'; + }; + return \%RESULT; +} + + +########################################################################### +######################## checkTabulator ################################### +########################################################################## +sub checkTabulator +{ + my ($line, $TABSTOP) = @_; + + while ((my $at = index($line, "\t")) != -1) + { + my $cnt = ($TABSTOP - ($at % $TABSTOP)); + my $replace_with = ' ' x $cnt if ($cnt); + $line =~ s/\t/$replace_with/; + }; + + return $line; +} + +########################################################################## +####################### get_input_file ################################### +########################################################################## +sub get_input_file + { + + # in : \%params + # in : \%LANGUAGE; + # in/out : $langmode; + # in/out : $alt_langmode; + # returns: input file + + my %PARAMS = %{$_[0]}; + my %LANGUAGE = %{$_[1]}; + my $langmode = $_[2]; + my $alt_langmode = $_[3]; + my $code; + + if ( $PARAMS{'input'} ) + { + $code = $PARAMS{'input'}; + $code =~ s/\r//g; + } + else + { + if ($PARAMS{'infile'} eq '-') { + *FILEHANDLE = *STDIN; + } else { + open(FILEHANDLE, $PARAMS{'infile'}) + || return("While opening '$PARAMS{'infile'}' for input: ".$!."\n"); + } + local $/=undef; + $code = ; + close(FILEHANDLE); + $PARAMS{'infile'} = $opt_i || $PARAMS{'infile'}; + }; + + if ($PARAMS{'replacetabs'} != 0) + { + $code = join ( + "\n", + map{ + &checkTabulator($_, $PARAMS{'replacetabs'}) + } + my @dummy = split(/\n/, $code) + ); + }; + + + + if ( not $langmode ) + { + my $test_code = substr($code, 0, $LANG_TEST_LENGTH); + # warn("language mode not given. guessing...\n"); + + $langmode = ''; + + for (keys %LANGUAGE) + { + if ( (($LANGUAGE{$_}->{'filename'} ne '') + && ($PARAMS{'infile'} + =~ m/$LANGUAGE{$_}->{filename}/)) || + (($LANGUAGE{$_}->{'regex'} ne '') + && ($test_code =~ m/$LANGUAGE{$_}->{regex}/ )) + ) + { + $langmode = $_; + last; + }; + }; + + if ($langmode eq '') + { + if ( not $alt_langmode ) + { + warn("Guessing language mode failed. " . + "Using fallback mode: '$alt_langmode'\n"); + $langmode = $alt_langmode; + $alt_langmode = ''; + } + else + { + print $code unless $str; + return("Guessing language mode failed.\n") + }; + } + else + { + # warn("using '$langmode'\n"); + }; + }; + + $_[2] = $langmode; + $_[3] = $alt_langmode; + print "==> append : to filename to switch off syntax highlighting\n" + if ! $ENV{LESSQUIET}; + return \$code; + }; + + +########################################################################### +####################### put_headers ####################################### +########################################################################### +sub put_headers +{ + my $html; + my %PARAMS = %{shift()}; + my $STYLE_REF = shift(); + + if ( $PARAMS{'content_type'}) { + $html .= "Content-Type: $$STYLE_REF{'content-type'}\n"; + if ($PARAMS{'content_encoding'}) { + $html .= "Content-Encoding: $PARAMS{'encoding'}\n"; + } + $html .= "\n"; + } + $html .= $$STYLE_REF{'header'} unless $PARAMS{'noheader'}; + + return $html; +}; + +############################################################################ +####################### apply_stylesheets_to_rules ######################### +############################################################################ +sub apply_stylesheets_to_rules + { + my ( $regexps_ref, $style_ref ) = @_; + + for ( @$regexps_ref ) { + warn ("Style '".$_->{style}."' not defined in stylesheet.\n") unless defined $ { $$style_ref{'tags'} } { $_->{style} }; + $_->{'starttag'} = $ { $ { $$style_ref{'tags'} } { $_->{style} } } { 'start' }; + $_->{'endtag'} = $ { $ { $$style_ref{'tags'} } { $_->{style} } } { 'stop' }; + apply_stylesheets_to_rules( $_->{childregex}, $style_ref ) if $_->{childregex}; + }; + }; + +########################################################################### +####################### create_snippetlist ################################ +########################################################################### +sub create_snippetlist + { + my ( $regexps_ref, $code, $snippetlist_ref, $style_ref ) = @_ ; + my $length = length( $code ); + + ## An array of regular expression sturctures, each of which is an + ## array. @res is kept sorted by starting position of the RExen and + ## then by the position of the regex in the language file. This allows + ## us to just evaluate $res[0], and to hand write fast code that typically + ## handles 90% of the cases without resorting to the _big_ guns. + ## + ## FWIW, I pronounce '@res' REEZE, as in the plural of '$re'. + ## + my @res ; + + my $pos ; + + for ( @$regexps_ref ) { + pos( $code ) = 0 ; +#++$m ; + next unless $code =~ m/($_->{regex})/gms ; + + $pos = pos( $code ) ; +# $res[@res] = [ +# $_->{regex}, +# $ { $ { $$style_ref{'tags'} } { $_->{style} } } { 'start' }, +# $ { $ { $$style_ref{'tags'} } { $_->{style} } } { 'stop' }, +# $_->{childregex}, +# $pos - length( $1 ), +# $pos, +# scalar( @res ), +# ] ; + $res[@res] = [ + $_->{regex}, + $_->{starttag}, + $_->{endtag}, + $_->{childregex}, + $pos - length( $1 ), + $pos, + scalar( @res ), + ] ; + } + + ## 90% of all child regexes end up with 0 or 1 regex that needs to be + ## worried about. Trimming out the 0's speeds things up a bit and + ## makes the below loop simpler, since there's always at least + ## 1 regexp. It donsn't speed things up much by itself: the percentage + ## of times this fires is really small. But it does simplify the loop + ## below and speed it up. + unless ( @res ) { + $code =~ s/($ENTITIES)/$ENTITIES{$1}/ge ; + push @$snippetlist_ref, $code ; + return ; + } + + @res = sort { $a->[4] <=> $b->[4] || $a->[6] <=> $b->[6] } @res ; + + ## Add a dummy at the end, which makes the logic below simpler / faster. + $res[@res] = [ + undef, + undef, + undef, + undef, + $length, + $length, + scalar( @res ), + ] ; + + ## These are declared here for (minor) speed improvement. + my $re ; + my $match_spos ; + my $match_pos ; + my $re_spos ; + my $re_pos ; + my $re_num ; + my $prefix ; + my $snippet ; + my $rest ; + my $i ; + my $l ; + +my @changed_res ; +my $j ; + + $pos = 0 ; +MAIN: + while ( $pos < $length ) { + $re = $res[0] ; + + $match_spos = $re->[4] ; + $match_pos = $re->[5] ; + + if ( $match_spos > $pos ) { + $prefix = substr( $code, $pos, $match_spos - $pos ) ; + $prefix =~ s/($ENTITIES)/$ENTITIES{$1}/ge ; + push @$snippetlist_ref, $prefix ; + } + + if ( $match_pos > $match_spos ) { + $snippet = substr( $code, $match_spos, $match_pos - $match_spos ) ; + if ( @{$re->[3]} ) { + push @$snippetlist_ref, $re->[1] ; + create_snippetlist( $re->[3], $snippet, $snippetlist_ref, $style_ref ) ; + push @$snippetlist_ref, $re->[2] ; + } + else { + $snippet =~ s/($ENTITIES)/$ENTITIES{$1}/ge ; + push @$snippetlist_ref, $re->[1], $snippet, $re->[2]; + } + } + + $pos = $match_pos ; + + ## + ## Hand coded optimizations. Luckily, the cases that arise most often + ## are the easiest to tune. + ## + +# =pod + + if ( $res[1]->[4] >= $pos ) { + ## Only first regex needs to be moved, 2nd and later are still valid. + ## This is often 90% of the cases for Perl or C (others not tested, + ## just uncomment the $n, $o, and $p lines and try it yourself). +#++$n{1} ; +#++$m ; + pos( $code ) = $pos ; + unless ( $code =~ m/($re->[0])/gms ) { +#++$o{'0'} ; + if ( @res == 2 ) { + ## If the only regexp left is the dummy, we're done. + $rest = substr( $code, $pos ) ; + $rest =~ s/($ENTITIES)/$ENTITIES{$1}/ge ; + push @$snippetlist_ref, $rest ; + last ; + } + shift @res ; + } + else { + $re->[5] = $re_pos = pos( $code ) ; + $re->[4] = $re_spos = $re_pos - length( $1 ) ; + + ## Walk down the array looking for $re's new home. + ## The first few loop iterations are unrolled and done manually + ## for speed, which handles 85 to 90% of the cases where only + ## $re needs to be moved. + ## + ## Here's where that dummy regexp at the end of the array comes + ## in handy: we don't need to worry about array size here, since + ## it will always be after $re no matter what. The unrolled + ## loop stuff is outdented to make the conditionals fit on one + ## 80 char line. + ## Element 4 in @{$res[x]} is the start position of the match. + ## Element 6 is the order in which it was declared in the lang file. + $re_num = $re->[6] ; + if ( ( $re_spos <=> $res[1]->[4] || $re_num <=> $res[1]->[6] ) <= 0 ) { +#++$o{'1'} ; + next + } + $res[0] = $res[1] ; + +#++$o{'2'} ; + if ( ( $re_spos <=> $res[2]->[4] || $re_num <=> $res[2]->[6] ) <= 0 ) { + $res[1] = $re ; + next ; + } + $res[1] = $res[2] ; + + if ( ( $re_spos <=> $res[3]->[4] || $re_num <=> $res[3]->[6] ) <= 0 ) { +#++$o{'3'} ; + $res[2] = $re ; + next ; + } + $res[2] = $res[3] ; + + if ( ( $re_spos <=> $res[4]->[4] || $re_num <=> $res[4]->[6] ) <= 0 ) { +#++$o{'3'} ; + $res[3] = $re ; + next ; + } + $res[3] = $res[4] ; + + if ( ( $re_spos <=> $res[5]->[4] || $re_num <=> $res[5]->[6] ) <= 0 ) { +#++$o{'4'} ; + $res[4] = $re ; + next ; + } + $res[4] = $res[5] ; + +#++$o{'ugh'} ; + $i = 6 ; + $l = $#res ; + for ( ; $i < $l ; ++$i ) { + last + if ( + ( $re_spos <=> $res[$i]->[4] || $re_num <=> $res[$i]->[6] ) + <= 0 + ) ; + $res[$i-1] = $res[$i] ; + } +#++$p{sprintf( "%2d", $i )} ; + $res[$i-1] = $re ; + } + + next ; + } + +# =cut + + ## + ## End optimizations. You can comment them all out and this net + ## does all the work, just more slowly. If you do that, then + ## you also need to comment out the code below that deals with + ## the second entry in @res. + ## + +#my $ni = 0 ; + ## First re always needs to be tweaked +#++$m ; +#++$ni ; + pos( $code ) = $pos ; + unless ( $code =~ m/($re->[0])/gms ) { + if ( @res == 2 ) { + ## If the only regexp left is the dummy, we're done. + $rest = substr( $code, $pos ) ; + $rest =~ s/($ENTITIES)/$ENTITIES{$1}/ge ; + push @$snippetlist_ref, $rest ; + last ; + } + shift @res ; + @changed_res = () ; + $i = 0 ; + } + else { + $re->[5] = $re_pos = pos( $code ) ; + $re->[4] = $re_pos - length( $1 ) ; + @changed_res = ( $re ) ; + $i = 1 ; + } + + ## If the optimizations above are in, the second one always + ## needs to be tweaked, too. + $re = $res[$i] ; +#++$m ; +#++$ni ; + pos( $code ) = $pos ; + unless ( $code =~ m/($re->[0])/gms ) { + if ( @res == 2 ) { + ## If the only regexp left is the dummy, we're done. + $rest = substr( $code, $pos ) ; + $rest =~ s/($ENTITIES)/$ENTITIES{$1}/ge ; + push @$snippetlist_ref, $rest ; + last ; + } + shift @res ; + } + else { + $re->[5] = $re_pos = pos( $code ) ; + $re->[4] = $re_spos = $re_pos - length( $1 ) ; + if ( @changed_res && + ( $changed_res[0]->[4] <=> $re_spos || + $changed_res[0]->[6] <=> $re->[6] + ) > 0 + ) { + unshift @changed_res, $re ; + } + else { + $changed_res[$i] = $re ; + } + ++$i ; + } + + for ( ; ; ++$i ) { + local $_ = $res[$i] ; +#++$m ; + last if $_->[4] >= $pos ; +#++$ni ; +#++$m ; + pos( $code ) = $pos ; + unless ( $code =~ m/($_->[0])/gms ) { + if ( @res <= 2 ) { + $rest = substr( $code, $pos ) ; + $rest =~ s/($ENTITIES)/$ENTITIES{$1}/ge ; + push @$snippetlist_ref, $rest ; + last MAIN ; + } + ## If this regex is no longer needed, remove it by not pushing it + ## on to @changed_res. This means we need one less slot in @res. + shift @res ; + redo ; + } + + $_->[5] = $re_pos = pos( $code ) ; + $_->[4] = $re_spos = $re_pos - length( $1 ) ; + + ## Insertion sort in to @changed_res + $re_num = $_->[6] ; + for ( $j = $#changed_res ; $j > -1 ; --$j ) { + last + if ( + ( $changed_res[$j]->[4] <=> $re_spos || + $changed_res[$j]->[6] <=> $re_num + ) < 0 + ) ; + $changed_res[$j+1] = $changed_res[$j] ; + } + $changed_res[$j+1] = $_ ; + } + + ## Merge sort @changed_res and @res in to @res + $j = 0 ; + $l = $#res ; + for ( @changed_res ) { + while ( + $i < $l && + ( $_->[4] <=> $res[$i]->[4] || $_->[6] <=> $res[$i]->[6] ) > 0 + ) { + $res[$j++] = $res[$i++] ; + } + $res[$j++] = $_ ; + } +# =cut + } +}; + + +########################################################################## +####################### put_output ####################################### +########################################################################## +sub put_output { + my ( $params, $snippetlist_ref, $STYLE_REF ) = @_ ; + + my $result; + + my $prefix = ''; + $prefix = $params->{'line_number_prefix'}.'_' + if $params->{'line_number_prefix'}; + + $result = &{ $ { $$STYLE_REF{'linenumbers'}} {$params->{'linenumbers'}} + }(join ('', @$snippetlist_ref), $prefix); + + # print FILEHANDLE $result unless $params->{'dont_print_output'} ; + # print FILEHANDLE $$STYLE_REF{'footer'} unless $params->{'noheader'}; + + $result .= $$STYLE_REF{'footer'} unless $params->{noheader}; + + return $result; +}; + + +############################################################################ +####################### get_default_stylesheet ############################# +############################################################################ +sub get_default_stylesheet +{ + +my %STYLESHEET; + + +########## +########## different color modes for html. +# those are named html-dark, html-nobc and html-light. +# html-light is also named html +# the only difference between html-light and html-nobc is +# that html-light defines a body background and text color. +# nobc stands for no body colors. + +my ($bold, $underline, $reverse, $reset, $red, $green, $yellow, $blue, + $magenta, $cyan); +eval "use Term::ANSIColor"; +if ($@) { + $bold = "\e[1m"; + $underline = "\e[4m"; + $reverse = "\e[7m"; + $reset = "\e[0m"; + $red = "\e[31m"; + $green = "\e[32m"; + $yellow = "\e[33m"; + $blue = "\e[34m"; + $magenta = "\e[35m"; + $cyan = "\e[36m"; +} else { + $bold = color('bold'); + $underline = color('underline'); + $reverse = color('reverse'); + $reset = color('reset'); + $red = color('red'); + $green = color('green'); + $yellow = color('yellow'); + $blue = color('blue'); + $magenta = color('magenta'); + $cyan = color('cyan'); +} +$STYLESHEET{'xterm'} = { 'template' => '%%code%%', + 'content-type' => 'text/html', + 'linenumbers' => { + 'none' => sub { + return $_[0]; + }, + 'normal' => sub { + # o as the first parameter is the joined snippetlist + # o the second is an optional prefix, needed if more than one block + # in a file is highlighted. needed in patch-mode. may be empty + # the sub should the return a scalar made up of the joined lines including linenumbers + my @lines = split ( /\n/, $_[0] ); + my $nr = 0; + my $lengthofnr = length(@lines); + my $format = qq{%${lengthofnr}u %s\n} ; + join ('', map ( {$nr++; sprintf ( $format , $nr, $_ )} @lines)); + }, + 'linked' => sub { + # is not defined for xterm output, therefore do nothing + return $_[0]; + }, + }, + 'tags' => { + 'comment' => { 'start' => $blue, + 'stop' => $reset }, + 'doc comment' => { 'start' => "$bold$blue", + 'stop' => $reset }, + 'string' => { 'start' => $red, + 'stop' => $reset }, + 'esc string' => { 'start' => $magenta, + 'stop' => $reset }, + 'character' => { 'start' => $reset, + 'stop' => $reset }, + 'esc character' => { 'start' => $magenta, + 'stop' => $reset }, + 'numeric' => { 'start' => $red, + 'stop' => $reset }, + 'identifier' => { 'start' => $cyan, + 'stop' => $reset }, + 'predefined identifier' => { 'start' => $cyan, + 'stop' => $reset }, + 'type' => { 'start' => $cyan, + 'stop' => $reset }, + 'predefined type' => { 'start' => $green, + 'stop' => $reset }, + 'reserved word' => { 'start' => "$yellow", + 'stop' => $reset }, + 'library function' => { 'start' => $reset, + 'stop' => $reset }, + 'include' => { 'start' => $green, + 'stop' => $reset }, + 'preprocessor' => { 'start' => $green, + 'stop' => $reset }, + 'braces' => { 'start' => $reset, + 'stop' => $reset }, + 'symbol' => { 'start' => $green, + 'stop' => $reset }, + 'function header' => { 'start' => "$bold$red", + 'stop' => $reset }, + 'function header name' => { 'start' => "$bold$cyan", + 'stop' => $reset }, + 'function header args' => { 'start' => $cyan, + 'stop' => $reset }, + 'regex' => { 'start' => $magenta, + 'stop' => $reset }, + 'text' => { 'start' => $red, + 'stop' => $reset}, + + # HTML + 'entity' => { 'start' => $green, + 'stop' => $reset }, + + # MAKEFILE + 'assignment' => { 'start' => $green, + 'stop' => $reset }, + 'dependency line' => { 'start' => $cyan, + 'stop' => $reset }, + 'dependency target' => { 'start' => $blue, + 'stop' => $reset }, + 'dependency continuation'=> { 'start' => $magenta, + 'stop' => $reset }, + 'continuation' => { 'start' => $magenta, + 'stop' => $reset }, + 'macro' => { 'start' => $red, + 'stop' => $reset }, + 'int macro' => { 'start' => $red, + 'stop' => $reset }, + 'esc $$$' => { 'start' => $yellow, + 'stop' => $reset }, + 'separator' => { 'start' => $green, + 'stop' => $reset }, + 'line spec' => { 'start' => $cyan, + 'stop' => $reset }, + 'deletion' => { 'start' => $red, + 'stop' => $reset }, + 'insertion' => { 'start' => $blue, + 'stop' => $reset }, + 'modification' => { 'start' => $magenta, + 'stop' => $reset }, + } + }; +$STYLESHEET{'html-light'} = { 'template' => +' + + %%title%% + + +
+%%code%%
+
+

syntax highlighted by +Code2HTML, v. %%version%%

+ + +', + 'content-type' => 'text/html', + 'entities' => { 'listofchars' => '[<>&"]', # a regex actually + 'replace_by' => { + '&' => '&', + '<' => '<', + '>' => '>', + '"' => '"' + } + }, + 'linenumbers' => { + 'none' => sub { + return $_[0]; + }, + 'normal' => sub { + # o as the first parameter is the joined snippetlist + # o the second is an optional prefix, needed if more than one block + # in a file is highlighted. needed in patch-mode. may be empty + # the sub should the return a scalar made up of the joined lines including linenumbers + my @lines = split ( /\n/, $_[0] ); + + my $nr = 0; + my $lengthofnr = length(@lines); + my $format = qq{%${lengthofnr}u %s\n} ; + join ('', map ( {$nr++; sprintf ( $format , $nr, $nr, $_ )} @lines)); + }, + 'linked' => sub { + # this should do the same as above only with linenumbers that link to themselves + # If this style does not support this, use the same as above. + my @lines = split ( /\n/, $_[0] ); + + my $nr = 0; + my $lengthofnr = length(@lines); + my $format = qq{%$ {lengthofnr}u %s\n}; + join ('', map ( {$nr++; sprintf ( $format , $nr, $nr, $nr, $_ )} @lines)); + } + }, + 'tags' => { + 'comment' => { 'start' => '', + 'stop' => '' }, + 'doc comment' => { 'start' => '', + 'stop' => '' }, + 'string' => { 'start' => '', + 'stop' => '' }, + 'esc string' => { 'start' => '', + 'stop' => '' }, + 'character' => { 'start' => '', + 'stop' => '' }, + 'esc character' => { 'start' => '', + 'stop' => '' }, + 'numeric' => { 'start' => '', + 'stop' => '' }, + + 'identifier' => { 'start' => '', + 'stop' => '' }, + 'predefined identifier' => { 'start' => '', + 'stop' => '' }, + + 'type' => { 'start' => '', + 'stop' => '' }, + 'predefined type' => { 'start' => '', + 'stop' => '' }, + + 'reserved word' => { 'start' => '', + 'stop' => '' }, + 'library function' => { 'start' => '', + 'stop' => '' }, + + 'include' => { 'start' => '', + 'stop' => '' }, + 'preprocessor' => { 'start' => '', + 'stop' => '' }, + + 'braces' => { 'start' => '', + 'stop' => '' }, + 'symbol' => { 'start' => '', + 'stop' => '' }, + + 'function header' => { 'start' => '', + 'stop' => '' }, + 'function header name' => { 'start' => '', + 'stop' => '' }, + 'function header args' => { 'start' => '', + 'stop' => '' }, + + 'regex' => { 'start' => '', + 'stop' => '' }, + + 'text' => { 'start' => '', + 'stop' => ''}, + + # HTML + 'entity' => { 'start' => '', + 'stop' => '' }, + + # MAKEFILE + 'assignment' => { 'start' => '', + 'stop' => '' }, + 'dependency line' => { 'start' => '', + 'stop' => '' }, + 'dependency target' => { 'start' => '', + 'stop' => '' }, + 'dependency continuation'=> { 'start' => '', + 'stop' => '' }, + 'continuation' => { 'start' => '', + 'stop' => '' }, + 'macro' => { 'start' => '', + 'stop' => '' }, + 'int macro' => { 'start' => '', + 'stop' => '' }, + 'esc $$$' => { 'start' => '', + 'stop' => '' } + } + }; +# html-light is also called html + +$STYLESHEET{'html'} = $STYLESHEET{'html-light'}; + + +# html-nobc is a modification of html-light +# in such a way, that the body tag does not define +# a background and a text color +# nobc stands for no body colors. + +%{$STYLESHEET{'html-nobg'}} = %{$STYLESHEET{'html-light'}}; +${ $STYLESHEET{'html-nobg'}} {'template'} = ' + + %%title%% + + +
+%%code%%
+
+

syntax highlighted by +Code2HTML, v. %%version%%

+ + +'; + + +# html-dark is a modification of html-light +# in such a way, that the body tag does define +# different colors and that the colors are different. + +%{$STYLESHEET{'html-dark'}} = %{$STYLESHEET{'html-light'}}; +${ $STYLESHEET{'html-dark'}} {'template'} = ' + + %%title%% + + +
+%%code%%
+
+

syntax highlighted by +Code2HTML, v. %%version%%

+ + +'; +${ $STYLESHEET{'html-dark'}} {'tags'} = { + 'comment' => { 'start' => '', + 'stop' => '' }, + 'doc comment' => { 'start' => '', + 'stop' => '' }, + 'string' => { 'start' => '', + 'stop' => '' }, + 'esc string' => { 'start' => '', + 'stop' => '' }, + 'character' => { 'start' => '', + 'stop' => '' }, + 'esc character' => { 'start' => '', + 'stop' => '' }, + 'numeric' => { 'start' => '', + 'stop' => '' }, + + 'identifier' => { 'start' => '', + 'stop' => '' }, + 'predefined identifier' => { 'start' => '', + 'stop' => '' }, + + 'type' => { 'start' => '', + 'stop' => '' }, + 'predefined type' => { 'start' => '', + 'stop' => '' }, + + 'reserved word' => { 'start' => '', + 'stop' => '' }, + 'library function' => { 'start' => '', + 'stop' => '' }, + + 'include' => { 'start' => '', + 'stop' => '' }, + 'preprocessor' => { 'start' => '', + 'stop' => '' }, + + 'braces' => { 'start' => '', + 'stop' => '' }, + 'symbol' => { 'start' => '', + 'stop' => '' }, + + 'function header' => { 'start' => '', + 'stop' => '' }, + 'function header name' => { 'start' => '', + 'stop' => '' }, + 'function header args' => { 'start' => '', + 'stop' => '' }, + + 'regex' => { 'start' => '', + 'stop' => '' }, + + 'text' => { 'start' => '', + 'stop' => ''}, + + # HTML + 'entity' => { 'start' => '', + 'stop' => '' }, + + # MAKEFILE + 'assignment' => { 'start' => '', + 'stop' => '' }, + 'dependency line' => { 'start' => '', + 'stop' => '' }, + 'dependency target' => { 'start' => '', + 'stop' => '' }, + 'dependency continuation'=> { 'start' => '', + 'stop' => '' }, + 'continuation' => { 'start' => '', + 'stop' => '' }, + 'macro' => { 'start' => '', + 'stop' => '' }, + 'int macro' => { 'start' => '', + 'stop' => '' }, + 'esc $$$' => { 'start' => '', + 'stop' => '' } + }; + + +return \%STYLESHEET; + +}; + + + +############################################################################# +####################### get_default_database ################################ +############################################################################# +sub get_default_database +{ + +my %LANGUAGE; + +# written by PP +$LANGUAGE{'plain'} = { + 'filename' => '', + 'regex' => '', + 'patterns' => [] + }; + + + + + + +# taken from nedit +# modified by PP +$LANGUAGE{'ada'} = { + 'filename' => '(?i)\\.a(d[asb]?)?$', + 'regex' => '', + 'patterns' => [ + { + 'name' => 'Comments', + 'regex' => '--.*?$', + 'style' => 'comment', + 'childregex' => [], + }, + { + 'name' => 'String Literals', + 'regex' => '".*?("|$)', + 'style' => 'string', + 'childregex' => [] + }, + { + 'name' => 'Character Literals', + 'regex' => '\'.\'', + 'style' => 'character', + 'childregex' => [] + }, + { + 'name' => 'Ada Attributes', + 'regex' => '\'[a-zA-Z][a-zA-Z_]+\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'Numeric Literals', + 'regex' => '(((2|8|10|16)#[_0-9a-fA-F]*#)|[0-9.]+)', + 'style' => 'numeric', + 'childregex' => [] + }, + { + 'name' => 'Withs Pragmas Use', + 'regex' => '\\b(?i)((with|pragma|use)[ \\t\\n\\f\\r]+[a-zA-Z0-9_.]+;)+\\b', + 'style' => 'include', + 'childregex' => [] + }, + { + 'name' => 'Predefined Types', + 'regex' => '\\b(?i)(boolean|character|count|duration|float|integer|long_float|long_integer|priority|short_float|short_integer|string)\\b', + 'style' => 'predefined type', + 'childregex' => [] + }, + { + 'name' => 'Predefined Subtypes', + 'regex' => '\\b(?i)field|natural|number_base|positive|priority\\b', + 'style' => 'predefined type', + 'childregex' => [] + }, + { + 'name' => 'Reserved Words', + 'regex' => '\\b(?i)(abort|abs|accept|access|and|array|at|begin|body|case|constant|declare|delay|delta|digits|do|else|elsif|end|entry|exception|exit|for|function|generic|goto|if|in|is|limited|loop|mod|new|not|null|of|or|others|out|package|pragma|private|procedure|raise|range|record|rem|renames|return|reverse|select|separate|subtype|task|terminate|then|type|use|when|while|with|xor)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'Ada 95 Only', + 'regex' => '\\b(?i)(abstract|tagged|all|protected|aliased|requeue|until)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'Identifiers', + 'regex' => '\\b[a-zA-Z][a-zA-Z0-9_]*\\b', + 'style' => 'identifier', + 'childregex' => [] + }, + { + 'name' => 'Dot All', + 'regex' => '(?i)\\.all\\b', + 'style' => 'predefined identifier', + 'childregex' => [] + } + ] + }; +$LANGUAGE{'ada95'} = $LANGUAGE{'ada'}; + + + + + + + + + + + + + + + +# written by JA +$LANGUAGE{'awk'} = { + 'filename' => '(?i)\\.awk$', + 'regex' => '^\\s*#\\s*![^\\s]*awk', + 'patterns' => [ + { + 'name' => 'comment', + 'regex' => '#.*?$', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'string', + 'regex' => '""|".*?([^\\\\](\\\\\\\\)*)"|"\\\\\\\\"', +# 'regex' => '""|"\\\\\\\\"|"[^"\\\\]"|"[^"].*?[^\\\\]"', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => 'string', + 'regex' => '\'\'|\'.*?([^\\\\](\\\\\\\\)*)\'|\'\\\\\\\\\'', +# 'regex' => '\'\'|\'\\\\\\\\\'|\'[^\'\\\\]\'|\'[^\'].*?[^\\\\]\'', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => 'function header', + 'regex' => 'function[\\t ]+([a-zA-Z0-9_]+)[\\t \\n]*(\\{|\\n)', + 'style' => 'function header', + 'childregex' => [ + { + 'name' => 'function coloring', + 'regex' => '[\\t ]([a-zA-Z0-9_]+)', + 'style' => 'function header name', + 'childregex' => [] + } + ] + }, + { + 'name' => 'regex matching I 1', + 'regex' => '(\\b| )?(/)(\\\\/|[^/\\n])*(/[gimesox]*)', + 'style' => 'regex', + 'childregex' => [] + }, + { + 'name' => 'regex matching I 2', + 'regex' => '(?:\\b| )(?:(?:m|q|qq)([!"#$%&\'*+-/]))(\\\\\\2|[^\\2\\n])*(\\2[gimesox]*)', + 'style' => 'regex', + 'childregex' => [] + }, + { + 'name' => 'regex matching II', + 'regex' => '(?:\\b| )?(?:s([!"#$%&\'*+-/]))(?:\\\\\\2|[^\\2\\n])*?(\\2)[^(\\2)\\n]*?(\\2[gimesox]*)', + 'style' => 'regex', + 'childregex' => [] + }, + { + 'name' => 'translate', + 'regex' => '(?:\\b| )(?:(?:tr|y)([^\w\s]))(?:\\\\\\2|[^\\2\\n])*?(\\2)[^(\\2)\\n]*?(\\2[gimesox]*)', + 'style' => 'regex', + 'childregex' => [] + }, + { + 'name' => 'keywords', + 'regex' => '\\b(BEGIN|END|ARGC|ARGIND|ARGV|CONVFMT|ENVIRON|ERRNO|FIELDWIDTHS|FILENAME|FNR|FS|IGNORECASE|NF|NR|OFMT|OFS|ORS|RS|RT|RSTART|RLENGTH|SUBSEP)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'keywords 2', + 'regex' => '\\b(if|while|do|for|in|break|continue|delete|exit|next|nextfile|function)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'library fns', + 'regex' => '\\b(close|getline|print|printf|system|fflush|atan2|cos|exp|int|log|rand|sin|sqrt|srand|gensub|gsub|index|length|split|sprintf|sub|substr|tolower|toupper|systime|strftime)\\b', + 'style' => 'library function', + 'childregex' => [] + }, + { + 'name' => 'braces and parens', + 'regex' => '[\\[\\]\\{\\}\\(\\)]', + 'style' => 'braces', + 'childregex' => [] + }, + { + 'name' => '<< stuff', + 'regex' => '<<\'([^\\n]*)\';.*?^\\2$', + 'style' => 'text', + 'childregex' => [] + }, + { + 'name' => '<< stuff', + 'regex' => '<<([^\\n]*).*?^\\2$', + 'style' => 'text', + 'childregex' => [] + } + ] + }; + + + + + + + + + + + + + + + +# taken from nedit +# modified by PP +$LANGUAGE{'c'} = { + 'filename' => '\\.[ch]$', + 'regex' => '', + 'patterns' => [ + { + 'name' => 'comment', + 'regex' => '/\\*.*?\\*/', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'doc comment', + 'regex' => '/\\*\\*.*?\\*/', + 'style' => 'doc comment', + 'childregex' => [] + }, + { + 'name' => 'string', + 'regex' => '""|".*?([^\\\\](\\\\\\\\)*)"|"\\\\\\\\"', +# 'regex' => '""|"\\\\\\\\"|"[^"\\\\]"|"[^"].*?[^\\\\]"', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => 'preprocessor line', + 'regex' => '^[ \\t]*#.*?$', + 'style' => 'preprocessor', + 'childregex' => [ + { + 'name' => 'string', + 'regex' => '""|".*?([^\\\\](\\\\\\\\)*)"|"\\\\\\\\"', +# 'regex' => '""|"\\\\\\\\"|"[^"\\\\]"|"[^"].*?[^\\\\]"', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => '', + 'regex' => '<.*?>', + 'style' => 'string', + 'childregex' => [] + }, + { + 'name' => 'comment', + 'regex' => '[^/]/\\*.*?\\*/', + 'style' => 'comment', + 'childregex' => [] + } + ] + }, + { + 'name' => 'character constant', + 'regex' => '\'(\\\\)?.\'', + 'style' => 'character', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => 'numeric constant', + 'regex' => '\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\\b', + 'style' => 'numeric', + 'childregex' => [] + }, + { + 'name' => 'storage keyword', + 'regex' => '\\b(const|extern|auto|register|static|unsigned|signed|volatile|char|double|float|int|long|short|void|typedef|struct|union|enum)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'keyword', + 'regex' => '\\b(return|goto|if|else|case|default|switch|break|continue|while|do|for|sizeof)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'braces', + 'regex' => '[\\{\\}]', + 'style' => 'braces', + 'childregex' => [] + }, + { + 'name' => 'symbols', + 'regex' => '([\\*\\-\\+=:;%&\\|<>\\(\\)\\[\\]!])', + 'style' => 'symbol', + 'childregex' => [] + }, + { + 'name' => 'identifiers', + 'regex' => '([a-zA-Z_][a-zA-Z_0-9]*)', + 'style' => 'identifier', + 'childregex' => [] + } + ] + }; + + + + + + + + + + + + + + + +# taken from nedit +# modified by PP +$LANGUAGE{'c++'} = { + 'filename' => '\\.(c(c|pp|xx)|h(h|pp|xx)|C(C|PP|XX)?|H(H|PP|XX)?|i)$', + 'regex' => '', + 'patterns' => [ + { + 'name' => 'comment', + 'regex' => '/\\*.*?\\*/', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'doc comment', + 'regex' => '/\\*\\*.*?\\*/', + 'style' => 'doc comment', + 'childregex' => [] + }, + { + 'name' => 'cplus comment', + 'regex' => '//.*?$', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'string', + 'regex' => '""|"\\\\\\\\"|".*?([^\\\\](\\\\\\\\)*)"', +# 'regex' => '""|"\\\\\\\\"|"[^"\\\\]"|"[^"].*?[^\\\\]"', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => 'preprocessor line', + 'regex' => '^[ \\t]*#.*?$', + 'style' => 'preprocessor', + 'childregex' => [ + { + 'name' => 'string', + 'regex' => '""|".*?([^\\\\](\\\\\\\\)*)"|"\\\\\\\\"', +# 'regex' => '""|"\\\\\\\\"|"[^"\\\\]"|"[^"].*?[^\\\\]"', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => '', + 'regex' => '<.*?>', + 'style' => 'string', + 'childregex' => [] + }, + { + 'name' => 'comment', + 'regex' => '[^/]/\\*.*?\\*/', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'cplus comment', + 'regex' => '//.*?$', + 'style' => 'comment', + 'childregex' => [] + } + ] + }, + { + 'name' => 'character constant', + 'regex' => '\'(\\\\)?.\'', + 'style' => 'character', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => 'numeric constant', + 'regex' => '\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\\b', + 'style' => 'numeric', + 'childregex' => [] + }, + { + 'name' => 'storage keyword', + 'regex' => '\\b(class|typename|typeid|template|friend|virtual|inline|explicit|operator|overload|public|private|protected|const|extern|auto|register|static|mutable|unsigned|signed|volatile|char|double|float|int|long|short|bool|wchar_t|void|typedef|struct|union|enum)\\b', + 'style' => 'reserved word', + 'childregex' => [], + }, + { + 'name' => 'keyword', + 'regex' => '\\b(new|delete|this|return|goto|if|else|case|default|switch|break|continue|while|do|for|catch|throw|sizeof|true|false|namespace|using|dynamic_cast|static_cast|reinterpret_cast)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'braces', + 'regex' => '[\\{\\}]', + 'style' => 'braces', + 'childregex' => [] + }, + { + 'name' => 'symbols', + 'regex' => '([\\*\\-\\+=:;%&\\|<>\\(\\)\\[\\]!])', + 'style' => 'symbol', + 'childregex' => [] + }, + { + 'name' => 'identifiers', + 'regex' => '([a-zA-Z_][a-zA-Z_0-9]*)', + 'style' => 'identifier', + 'childregex' => [] + } + ] + }; +$LANGUAGE{'cc'} = $LANGUAGE{'c++'}; +$LANGUAGE{'cpp'} = $LANGUAGE{'c++'}; +$LANGUAGE{'cxx'} = $LANGUAGE{'c++'}; + + + + + + + + + + +# written by VRS +$LANGUAGE{'gpasm'} = { + 'filename' => '(?i)\\.(asm|inc)$', + 'regex' => '', + 'patterns' => [ + { + 'name' => 'args', + 'regex' => '^.*$', + 'style' => 'symbol', + 'childregex' => [ + { + 'name' => 'comment', + 'regex' => ';.*?$', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'labels', + 'regex' => '^[A-Za-z_][A-Za-z_0-9]*:?', + 'style' => 'identifier', + 'childregex' => [] + }, + + { + 'name' => 'menonics', + 'regex' => '^[ \t]+[A-Za-z_][A-Za-z_0-9]*', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'string', + 'regex' => '""|".*?([^\\\\](\\\\\\\\)*)"|"\\\\\\\\"', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + } + + + ] + } + ] + }; + + + + + + + + +# written by JA +$LANGUAGE{'groff'} = { + 'filename' => '\\.groff$', + 'regex' => '', + 'patterns' => [ + { + 'name' => 'comment', + 'regex' => '\\\\".*?$', + 'style' => 'comment', + 'childregex' => [] + } + ] + }; + + + + + + + + + + + + + + + +# taken from nedit +# modified by PP +$LANGUAGE{'html'} = { + 'filename' => '(?i)\\.(html?|mhtml|php)$', + 'regex' => '', + 'patterns' => [ + { + 'name' => 'comment', + 'regex' => '', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'entity', + 'regex' => '\\&[-.a-zA-Z0-9#]*;?', + 'style' => 'entity', + 'childregex' => [] + }, + { + 'name' => 'tag', + 'regex' => '<(/|!)?[-.a-zA-Z0-9]*.*?>', + 'style' => 'predefined identifier', + 'childregex' => [ + { + 'name' => 'double quote string', + 'regex' => '".*?"', + 'style' => 'string', + 'childregex' => [] + }, + { + 'name' => 'single quote string', + 'regex' => '\'.*?\'', + 'style' => 'string', + 'childregex' => [] + }, + { + 'name' => 'brackets', + 'regex' => '[<>]', + 'style' => 'braces', + 'childregex' => [] + }, + { + 'name' => 'attribute', + 'regex' => '[^\'" ]+(?=.)', + 'style' => 'identifier', + 'childregex' => [] + } + ] + } + ] + }; + + + +# Added May 17, 2002, Jim M. +$LANGUAGE{'xml'} = { + 'filename' => '(?i)\\.(xml|xps|xsl|axp|ppd)?$', + 'regex' => '', + 'patterns' => [ + { + 'name' => 'comment', + 'regex' => '', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'entity', + 'regex' => '\\&[-.a-zA-Z0-9#]*;?', + 'style' => 'entity', + 'childregex' => [] + }, + { + 'name' => 'tag', + 'regex' => '<(/|!)?[-.a-zA-Z0-9]*.*?>', + 'style' => 'predefined identifier', + 'childregex' => [ + { + 'name' => 'double quote string', + 'regex' => '".*?"', + 'style' => 'string', + 'childregex' => [] + }, + { + 'name' => 'single quote string', + 'regex' => '\'.*?\'', + 'style' => 'string', + 'childregex' => [] + }, + { + 'name' => 'brackets', + 'regex' => '[<>]', + 'style' => 'braces', + 'childregex' => [] + }, + { + 'name' => 'attribute', + 'regex' => '[^\'" ]+(?=.)', + 'style' => 'identifier', + 'childregex' => [] + } + ] + } + ] + }; + + + + + + + + + + + + + + + +# taken from nedit +# modified by PP +$LANGUAGE{'java'} = { + 'filename' => '\\.java$', + 'regex' => '', + 'patterns' => [ + { + 'name' => 'doc comment', + 'regex' => '/\\*\\*.*?\\*/', + 'style' => 'doc comment', + 'childregex' => [] + }, + { + 'name' => 'comment', + 'regex' => '/\\*.*?\\*/', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'cplus comment', + 'regex' => '//.*?$', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'string', + 'regex' => '""|".*?([^\\\\](\\\\\\\\)*)"|"\\\\\\\\"', +# 'regex' => '""|"\\\\\\\\"|"[^"\\\\]"|"[^"].*?[^\\\\]"', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => 'single quoted', + 'regex' => '\'\'|\'.*?([^\\\\](\\\\\\\\)*)\'|\'\\\\\\\\\'', +# 'regex' => '\'\'|\'\\\\\\\\\'|\'[^\'\\\\]\'|\'[^\'].*?[^\\\\]\'', + 'style' => 'string', + 'childregex' => [] + }, + { + 'name' => 'numeric constant', + 'regex' => '\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\\b', + 'style' => 'numeric', + 'childregex' => [] + }, + { + 'name' => 'include', + 'regex' => '\\b(import|package)\\b.*?$', + 'style' => 'include', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\(.|\\n)', + 'style' => 'esc character', + 'childregex' => [] + }, + { + 'name' => 'comment', + 'regex' => '[^/]/\\*.*?\\*/', + 'style' => 'comment', + 'childregex' => [] + } + ] + }, + { + 'name' => 'storage keyword', + 'regex' => '\\b(abstract|boolean|byte|char|class|double|extends|final|float|int|interface|long|native|private|protected|public|short|static|transient|synchronized|void|volatile|implements)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'keyword', + 'regex' => '\\b(break|case|catch|continue|default|do|else|false|finally|for|if|instanceof|new|null|return|super|switch|this|throw|throws|true|try|while)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'braces and parens', + 'regex' => '[\\{\\}\\(\\)\\[\\]]', + 'style' => 'braces', + 'childregex' => [] + }, + { + 'name' => 'Identifiers', + 'regex' => '\\b[a-zA-Z_][a-zA-Z0-9_]*\\b', + 'style' => 'identifier', + 'childregex' => [] + }, + { + 'name' => 'symbols', + 'regex' => '([\\*\\-\\+=:;%&\\|<>!])', + 'style' => 'symbol', + 'childregex' => [] + } + ] + }; + + + + + + + + + + + + + + +# taken from nedit +# modified by PP +$LANGUAGE{'javascript'} = { + 'filename' => '(?i)\\.js$', + 'regex' => '', + 'patterns' => [ + { + 'name' => 'comment', + 'regex' => '/\\*.*?\\*/', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'cplus comment', + 'regex' => '//.*?$', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'numeric constant', + 'regex' => '\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\\b', + 'style' => 'numeric', + 'childregex' => [] + }, + { + 'name' => 'events', + 'regex' => '\\b(onAbort|onBlur|onClick|onChange|onDblClick|onDragDrop|onError|onFocus|onKeyDown|onKeyPress|onLoad|onMouseDown|onMouseMove|onMouseOut|onMouseOver|onMouseUp|onMove|onResize|onSelect|onSubmit|onUnload)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'braces', + 'regex' => '[\\{\\}]', + 'style' => 'braces', + 'childregex' => [] + }, + { + 'name' => 'statements', + 'regex' => '\\b(break|continue|else|for|if|in|new|return|this|typeof|var|while|with)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'function', + 'regex' => 'function[\\t ]+([a-zA-Z0-9_]+)[\\t \\(]+.*?[\\n{]', + 'style' => 'function header', + 'childregex' => [ + { + 'name' => 'function args', + 'regex' => '\\(.*?\\)', + 'style' => 'function header args', + 'childregex' => [] + }, + { + 'name' => 'function name', + 'regex' => '[\\t ][a-zA-Z0-9_]+', + 'style' => 'function header name', + 'childregex' => [] + } + ] + }, + { + 'name' => 'built in object type', + 'regex' => '\\b(anchor|Applet|Area|Array|button|checkbox|Date|document|elements|FileUpload|form|frame|Function|hidden|history|Image|link|location|Math|navigator|Option|password|Plugin|radio|reset|select|string|submit|text|textarea|window)\\b', + 'style' => 'predefined type', + 'childregex' => [] + }, + { + 'name' => 'string', + 'regex' => '".*?("|$)', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'colors', + 'regex' => '(aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|#008000|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|#[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9])', + 'style' => 'identifier', + 'childregex' => [] + } + ] + }, + { + 'name' => 'string', + 'regex' => '\'.*?(\'|$)', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'colors', + 'regex' => '(aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|#008000|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|#[A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9][A-Fa-f0-9])', + 'style' => 'identifier', + 'childregex' => [], + } + ] + }, + { + 'name' => 'event capturing', + 'regex' => '\\b(captureEvents|releaseEvents|routeEvent|handleEvent)\\b.*?(\\)|$)', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'predefined methods', + 'regex' => '\\b(abs|acos|alert|anchor|asin|atan|atan2|back|big|blink|blur|bold|ceil|charAt|clear|clearTimeout|click|close|confirm|cos|escape|eval|exp|fixed|floor|focus|fontcolor|fontsize|forward|getDate|getDay|getHours|getMinutes|getMonth|getSeconds|getTime|getTimezoneOffset|getYear|go|indexOf|isNaN|italics|javaEnabled|join|lastIndexOf|link|log|max|min|open|parse|parseFloat|parseInt|pow|prompt|random|reload|replace|reset|reverse|round|scroll|select|setDate|setHours|setMinutes|setMonth|setSeconds|setTimeout|setTime|setYear|sin|small|sort|split|sqrt|strike|sub|submit|substring|sup|taint|tan|toGMTString|toLocaleString|toLowerCase|toString|toUpperCase|unescape|untaint|UTC|write|writeln)\\b', + 'style' => 'library function', + 'childregex' => [] + }, + { + 'name' => 'properties', + 'regex' => '\\b(action|alinkColor|anchors|appCodeName|appName|appVersion|bgColor|border|checked|complete|cookie|defaultChecked|defaultSelected|defaultStatus|defaultValue|description|E|elements|enabledPlugin|encoding|fgColor|filename|forms|frames|hash|height|host|hostname|href|hspace|index|lastModified|length|linkColor|links|LN2|LN10|LOG2E|LOG10E|lowsrc|method|name|opener|options|parent|pathname|PI|port|protocol|prototype|referrer|search|selected|selectedIndex|self|SQRT1_2|SQRT2|src|status|target|text|title|top|type|URL|userAgent|value|vlinkColor|vspace|width|window)\\b', + 'style' => 'predefined identifier', + 'childregex' => [] + }, + { + 'name' => 'operators', + 'regex' => '([=;->/&|])', + 'style' => 'symbol', + 'childregex' => [] + } + ] + }; +$LANGUAGE{'js'} = $LANGUAGE{'javascript'}; + + + + + + + + +# written by Andreas Krennmair +# extremely incomplete + +$LANGUAGE{'lisp'} = { + 'filename' => '\\.(lsp|l)$', + 'regex' => '', + 'patterns' => [ + { + 'name' => 'parens', + 'regex' => '[()]', + 'style' => 'braces', + 'childregex' => [] + }, + { + 'name' => 'comment', + 'regex' => ';.*?$', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'string', + 'regex' => '".*?("|$)', + 'style' => 'string', + 'childregex' => [] + }, + { + 'name' => 'keywords', + 'regex' => '\\b(defun |xyz)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'numeric constant', + 'regex' => '(#\([0-9]+ [0-9]+\)|[0-9]+)', + 'style' => 'numeric', + 'childregex' => [] + }, + { + 'name' => 'identifiers', + 'regex' => '([-a-zA-Z]+)', + 'style' => 'identifier', + 'childregex' => [] + } + ] + }; + + + + + + + + + + +# written by JA +$LANGUAGE{'m4'} = { + 'filename' => '\\.m4$', + 'regex' => '', + 'patterns' => [ + { + 'regex' => 'dnl.*?$', + 'style' => 'doc comment', + 'childregex' => [] + }, + { + 'regex' => '#.*?$', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'regex' => '\\b(define|undefine|defn|pushdef|popdef|indir|builtin|changequote|changecom|changeword|m4wrap|m4exit|include|sinclude|divert|undivert|divnum|cleardiv|shift|dumpdef|traceon|traceoff|debugfile|debugmode|len|index|regexp|substr|translit|patsubst|format|incr|decr|syscmd|esyscmd|sysval|maketemp|errprint)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'regex' => '\\b(ifdef|ifelse|loops)\\b', + 'style' => 'reserved word', + 'childregex' => [ + { + 'regex' => '[$]\\$?({[^}]*}|[^a-zA-Z0-9_/\\t\\n\\.,\\\\[\\\\{\\\\(]|[0-9]+|[a-zA-Z_][a-zA-Z0-9_]*)?', + 'style' => 'identifier', + 'childregex' => [] + } + ] + } + ] + }; + + + + + + + + + + + + + + + +# taken from nedit +# modified by PP +$LANGUAGE{'make'} = { + 'filename' => '[Mm]akefile.*', + 'regex' => '', + 'patterns' => [ + { + 'name' => 'Comment', + 'regex' => '#.*?$', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'Assignment', + 'regex' => '^( *| [ \\t]*)[A-Za-z0-9_+]*[ \\t]*(\\+|:)?=', + 'style' => 'assignment', + 'childregex' => [] + }, + { + 'name' => 'Dependency Line', + 'regex' => '^ *([A-Za-z0-9./$(){} _%+-]|\\n)*::?', + 'style' => 'dependency line', + 'childregex' => [ + { + 'name' => 'Dependency Target', + 'regex' => '[A-Za-z0-9./$(){} _%+-]+', + 'style' => 'dependency target', + 'childregex' => [] + }, + { + 'name' => 'Dependency Continuation', + 'regex' => '\\\\\\n', + 'style' => 'dependency continuation', + 'childregex' => [] + }, + { + 'name' => 'comment', + 'regex' => '#.*?$', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'macro', + 'regex' => '\\$([A-Za-z0-9_]|\\([^)]*\\)|{[^}]*})', + 'style' => 'macro', + 'childregex' => [] + }, + { + 'name' => 'int macro', + 'regex' => '\\$([<@*?%]|\\$@)', + 'style' => 'int macro', + 'childregex' => [] + } + ] + }, + { + 'name' => 'Continuation', + 'regex' => '\\\\$', + 'style' => 'continuation', + 'childregex' => [] + }, + { + 'name' => 'Macro', + 'regex' => '\\$([A-Za-z0-9_]|\\([^)]*\\)|{[^}]*})', + 'style' => 'macro', + 'childregex' => [] + }, + { + 'name' => 'Internal Macro', + 'regex' => '\\$([<@*?%]|\\$@)', + 'style' => 'int macro', + 'childregex' => [] + }, + { + 'name' => 'Escaped $$$', + 'regex' => '\\$\\$', + 'style' => 'esc $$$', + 'childregex' => [] + }, + { + 'name' => 'Include', + 'regex' => '^include[ \\t]', + 'style' => 'include', + 'childregex' => [] + } + ] + }; +$LANGUAGE{'makefile'} = $LANGUAGE{'make'}; + + + + + + + + + + + + + + + +# taken from nedit +# modified by PP +$LANGUAGE{'pas'} = { + 'filename' => '(?i)\\.p(as)?$', + 'regex' => '', + 'patterns' => [ + { + 'name' => 'comment1 (* *)', + 'regex' => '\\(\\*.*?\\*\\)', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'comment2 { }', + 'regex' => '\\{.*?\\}', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'string', + 'regex' => '\'.*?(\'|$)', + 'style' => 'string', + 'childregex' => [] + }, + { + 'name' => 'preprocessor line', + 'regex' => '^[ \\t]*#.*?$', + 'style' => 'preprocessor', + 'childregex' => [ + { + 'name' => 'comment1 (* *)', + 'regex' => '\\(\\*.*?\\*\\)', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'comment2 { }', + 'regex' => '\\{.*?\\}', + 'style' => 'comment', + 'childregex' => [] + } + ] + }, + { + 'name' => 'character constant', + 'regex' => '\'.\'', + 'style' => 'character', + 'childregex' => [] + }, + { + 'name' => 'numeric constant', + 'regex' => '\\b((0(x|X)[0-9a-fA-F]*)|[0-9.]+((e|E)(\\+|-)?)?[0-9]*)(L|l|UL|ul|u|U|F|f)?\\b', + 'style' => 'numeric', + 'childregex' => [] + }, + { + 'name' => 'storage and ops', + 'regex' => '\\b(?i)(and|array|const|div|export|file|function|import|in|label|mod|module|nil|not|only|or|packed|pow|pragma|procedure|program|protected|qualified|record|restricted|set|type|var)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'keywords', + 'regex' => '\\b(?i)(begin|case|do|downto|else|end|for|goto|if|of|otherwise|repeat|then|to|until|while|with)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'sumbols', + 'regex' => '([\\*\\-\\+=:;<>\\(\\)\\[\\]!]|[^/]/[^/])', + 'style' => 'symbol', + 'childregex' => [] + }, + { + 'name' => 'identifiers', + 'regex' => '([a-zA-Z_][a-zA-Z_0-9.^]*[a-zA-Z_0-9]|[a-zA-Z_][a-zA-Z_0-9]*)', + 'style' => 'identifier', + 'childregex' => [ + { + 'regex' => '(\\.|\\^)+', + 'style' => 'symbol', + 'childregex' => [] + } + ] + } + ], + }; +$LANGUAGE{'pascal'} = $LANGUAGE{'pas'}; + + + + + + + + + + + + + + + +# taken from nedit +# modified by PP +# modified by BS +# modified by JD +# modified by JP +$LANGUAGE{'perl'} = { + 'filename' => '(?i)\\.p([lm5]|od)$', + 'regex' => '^\\s*#\\s*!([^\\s]*\\b|.*env\\s+)perl', + 'patterns' => [ + { + 'name' => 'comment', + 'regex' => '(?:#.*?(?:\r?\n\s*)+)+', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'variables', + 'regex' => '[\\$@%]\\$?(?:{[^}]*}|[^a-zA-Z0-9_/\\t\\n\\.,\\\\[\\\\{\\\\(]|[0-9]+|[a-zA-Z_][a-zA-Z0-9_]*)?', + 'style' => 'identifier', + 'childregex' => [] + }, + { + 'name' => '"" string', + 'regex' => '""|".*?([^\\\\](\\\\\\\\)*)"|"\\\\\\\\"', +# 'regex' => '""|"\\\\\\\\"|"[^"\\\\]"|"[^"].*?[^\\\\]"', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + }, + { + 'name' => 'variables', + 'regex' => '[\\$@%]\\$?(?:{[^}]*}|[^a-zA-Z0-9_/\\t\\n\\.,\\\\[\\\\{\\\\(]|[0-9]+|[a-zA-Z_][a-zA-Z0-9_]*)?', + 'style' => 'identifier', + 'childregex' => [] + } + ] + }, + { + 'name' => '\'\' string', + 'regex' => '\'\'|\'.*?([^\\\\](\\\\\\\\)*)\'|\'\\\\\\\\\'', +# 'regex' => '\'\'|\'\\\\\\\\\'|\'[^\'\\\\]\'|\'[^\'].*?[^\\\\]\'', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => 'more strings - q// qw//', + 'regex' => '(?:\\b| )(?:q|qw)([^\w\s])(?:\\\\\\2|[^\\2\\n])*\\2', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => 'more strings - qq// qx//', + 'regex' => '(?:\\b| )(?:qq|qx)([^\w\s])(?:\\\\\\2|[^\\2\\n])*\\2', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + }, + { + 'name' => 'variables', + 'regex' => '[\\$@%]\\$?(?:{[^}]*}|[^a-zA-Z0-9_/\\t\\n\\.,\\\\[\\\\{\\\\(]|[0-9]+|[a-zA-Z_][a-zA-Z0-9_]*)?', + 'style' => 'identifier', + 'childregex' => [] + } + ] + }, + { + 'name' => 'subroutine header', + 'regex' => 'sub[\\t ]+(?:[a-zA-Z0-9_]+)[\\t \\n]*(?:\\{|\\(|\\n)', + 'style' => 'function header', + 'childregex' => [ + { + 'name' => 'subroutine header coloring', + 'regex' => '[\\t ][a-zA-Z0-9_]+', + 'style' => 'function header name', + 'childregex' => [] + } + ] + }, + { + 'name' => 'regex matching I', + 'regex' => '(?:\\b| )?(?:/(?:\\\\/|[^/\\n])*(?:/[gimesox]*)|s([^\w\s])(?:\\\\\\2|[^\\2\\n])*?(\\2)[^(\\2)\\n]*?(\\2[gimesox]*))', + 'style' => 'regex', + 'childregex' => [] + }, + { + 'name' => 'regex matching II', + 'regex' => '(?:\\b| )(?:m|qq?|tr|y)([^\w\s])(?:\\\\\\2|[^\\2\\n])*(?:\\2[gimesox]*)', + 'style' => 'regex', + 'childregex' => [] + }, + { + 'name' => 'keywords', + 'regex' => '\\b(my|local|new|if|until|while|elsif|else|eval|unless|for|foreach|continue|exit|die|last|goto|next|redo|return|local|exec|do|use|require|package|eval|BEGIN|END|eq|ne|not|\\|\\||\\&\\&|and|or)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'library functions', + 'regex' => '\\b(?:a(?:bs|ccept|larm|tan2)|b(?:ind|inmode|less)|c(?:aller|hdir|hmod|homp|hop|hr|hroot|hown|losedir|lose|onnect|os|rypt)|d(?:bmclose|bmopen|efined|elete|ie|ump)|e(?:ach|nd(?:grent|hostent|netent|protoent|pwent|servent)|of|xec|xists|xp)|f(?:ctnl|ileno|lock|ork|ormat|ormline)|g(?:et(?:c|grent|grgid|grnam|hostbyaddr|hostbyname|hostent|login|netbyaddr|netbyname|netent|peername|pgrp|ppid|priority|protobyname|protobynumber|protoent|pwent|pwnam|pwuid|servbyname|servbyport|servent|sockname|sockopt)|lob|mtime|rep)|hex|i(?:mport|ndex|nt|octl)|join|keys|kill|l(?:cfirst|c|ength|ink|isten|og|ocaltime|stat)|m(?:ap|kdir|sgctl|sgget|sgrcv)|no|o(?:ct|pendir|pen|rd)|p(?:ack|ipe|op|os|rintf|rint|ush)|quotemeta|r(?:and|eaddir|ead|eadlink|ecv|ef|ename|eset|everse|ewinddir|index|mdir)|s(?:calar|eekdir|eek|elect|emctl|emget|emop|end|et(?:grent|hostent|netent|pgrp|priority|protoent|pwent|sockopt)|hift|hmctl|hmget|hmread|hmwrite|hutdown|in|leep|ocket|ocketpair|ort|plice|plit|printf|qrt|rand|tat|tudy|ubstr|ymlink|yscall|ysopen|ysread|ystem|yswrite)|t(?:elldir|ell|ie|ied|ime|imes|runcate)|u(?:c|cfirst|mask|ndef|nlink|npack|nshift|ntie|time)|values|vec|w(?:ait|aitpid|antarray|arn|rite)|qw|-[rwxoRWXOezsfdlpSbctugkTBMAC])\\b', + 'style' => 'library function', + 'childregex' => [] + }, + { + 'name' => 'braces, parens and brakets', + 'regex' => '[\\[\\]\\{\\}\\(\\)]', + 'style' => 'braces', + 'childregex' => [] + }, + { + 'name' => '<< stuff', + 'regex' => '<<(?:("|\')([^\\n]*)\\2|\\w*).*?^\\3$', + 'style' => 'text', + 'childregex' => [] + }, + { + 'name' => 'POD', + 'regex' => '^=.*?^(?:=cut|\\Z)', + 'style' => 'doc comment', + 'childregex' => [] + } + ] + }; + + + + + + + + + + + + + + + +# Thanks to Matt Giwer +$LANGUAGE{'pov'} = { + 'filename' => '(?i)\\.pov$', + 'regex' => '', + 'patterns' => [ + { + 'name' => 'doc comment', + 'regex' => '/\\*\\*.*?\\*/', + 'style' => 'doc comment', + 'childregex' => [] + }, + { + 'name' => 'comment', + 'regex' => '/\\*.*?\\*/', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'cplus comment', + 'regex' => '//.*?$', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'string', + 'regex' => '""|".*?([^\\\\](\\\\\\\\)*)"|"\\\\\\\\"', +# 'regex' => '""|"\\\\\\\\"|"[^"\\\\]"|"[^"].*?[^\\\\]"', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => 'preprocessor line', + 'regex' => '^[ \\t]*#.*?$', + 'style' => 'preprocessor', + 'childregex' => [ + { + 'name' => 'string', + 'regex' => '""|".*?([^\\\\](\\\\\\\\)*)"|"\\\\\\\\"', +# 'regex' => '""|"\\\\\\\\"|"[^"\\\\]"|"[^"].*?[^\\\\]"', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => '', + 'regex' => '<.*?>', + 'style' => 'string', + 'childregex' => [] + }, + { + 'name' => 'comment', + 'regex' => '[^/]/\\*.*?\\*/', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'cplus comment', + 'regex' => '//.*?$', + 'style' => 'comment', + 'childregex' => [] + } + ] + }, + { + 'name' => 'character constant', + 'regex' => '\'(\\\\)?.\'', + 'style' => 'character', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => 'numeric constant', + 'regex' => '\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\\b', + 'style' => 'numeric', + 'childregex' => [] + }, + { + 'name' => 'keyword', + 'regex' => '\\b(abs|absorption|acos|acosh|adaptive|adc_bailout|agate|agate_turb|all|alpha|ambient|ambient_light|angle|aperture|append|arc_angle|area_light|array|asc|asin|asinh|assumed_gamma|atan|atan2|atanh|average|background|bezier_spline|bicubic_patch|black_hole|blob|blue|blur_samples|bounded_by|box|boxed|bozo|break|brick|brick_size|brightness|brilliance|bumps|bump_map|bump_size|camera|case|caustics|ceil|checker|chr|clipped_by|clock|clock_delta|color|color_map|colour|colour_map|component|composite|concat|cone|confidence|conic_sweep|control0|control1|cos|cosh|count|crackle|crand|cube|cubic|cubic_spline|cubic_wave|cylinder|cylindrical|debug|declare|default|defined|degrees|density|density_file|density_map|dents|difference|diffuse|dimensions|dimension_size|direction|disc|distance|distance_maximum|div|eccentricity|else|emission|end|error|error_bound|exp|extinction|fade_distance|fade_power|falloff|falloff_angle|false|fclose|file_exists|filter|finish|fisheye|flatness|flip|floor|focal_point|fog|fog_alt|fog_offset|fog_type|fopen|frequency|gif|global_settings|gradient|granite|gray_threshold|green|height_field|hexagon|hf_gray_16|hierarchy|hollow|hypercomplex|if|ifdef|iff|ifndef|image_map|include|int|interior|interpolate|intersection|intervals|inverse|ior|irid|irid_wavelength|jitter|julia_fractal|lambda|lathe|leopard|light_source|linear_spline|linear_sweep|local|location|log|looks_like|look_at|low_error_factor|macro|mandel|map_type|marble|material|material_map|matrix|max|max_intersections|max_iteration|max_trace_level|media|media_attenuation|media_interaction|merge|mesh|metallic|min|minimum_reuse|mod|mortar|nearest_count|no|normal|normal_map|no_shadow|number_of_waves|object|octaves|off|offset|omega|omnimax|on|once|onion|open|orthographic|panoramic|perspective|pgm|phase|phong|phong_size|pi|pigment|pigment_map|planar|plane|png|point_at|poly|polygon|poly_wave|pot|pow|ppm|precision|prism|pwr|quadratic_spline|quadric|quartic|quaternion|quick_color|quick_colour|quilted|radial|radians|radiosity|radius|rainbow|ramp_wave|rand|range|ratio|read|reciprocal|recursion_limit|red|reflection|reflection_exponent|refraction|render|repeat|rgb|rgbf|rgbft|rgbt|right|ripples|rotate|roughness|samples|scale|scallop_wave|scattering|seed|shadowless|sin|sine_wave|sinh|sky|sky_sphere|slice|slope_map|smooth|smooth_triangle|sor|specular|sphere|spherical|spiral1|spiral2|spotlight|spotted|sqr|sqrt|statistics|str|strcmp|strength|strlen|strlwr|strupr|sturm|substr|superellipsoid|switch|sys|t|tan|tanh|text|texture|texture_map|tga|thickness|threshold|tightness|tile2|tiles|torus|track|transform|translate|transmit|triangle|triangle_wave|true|ttf|turbulence|turb_depth|type|u|ultra_wide_angle|undef|union|up|use_color|use_colour|use_index|u_steps|v|val|variance|vaxis_rotate|vcross|vdot|version|vlength|vnormalize|vrotate|v_steps|warning|warp|water_level|waves|while|width|wood|wrinkles|write|x|y|yes|z)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'braces', + 'regex' => '[\\{\\}]', + 'style' => 'braces', + 'childregex' => [] + }, + { + 'name' => 'symbols', + 'regex' => '([\\*\\-\\+=:;%&\\|<>\\(\\)\\[\\]!])', + 'style' => 'symbol', + 'childregex' => [] + }, + { + 'name' => 'identifiers', + 'regex' => '([a-zA-Z_][a-zA-Z_0-9]*)', + 'style' => 'identifier', + 'childregex' => [] + } + ] + }; +$LANGUAGE{'povray'} = $LANGUAGE{'pov'}; + + + + +# by Tom Good +$LANGUAGE{'python'} = { + 'filename' => '(?i)\\.py$', + 'regex' => '^\\s*#\\s*![^\\s]*python', + 'patterns' => [ + { + 'name' => 'python comment', + 'regex' => '#.*?$', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'single quote string', + 'regex' => '\'.*?\'', + 'style' => 'string', + 'childregex' => [] + }, + + { + 'name' => 'string', + 'regex' => '""|"\\\\\\\\"|".*?([^\\\\](\\\\\\\\)*)"', + 'regex' => '""|".*?([^\\\\](\\\\\\\\)*)"|"\\\\\\\\"', + 'regex' => '""|"\\\\\\\\"|"[^"\\\\]"|"[^"].*?[^\\\\]"', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => 'character constant', + 'regex' => '\'(\\\\)?.\'', + 'style' => 'character', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '\\\\.', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => 'numeric constant', + 'regex' => '\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f)?\\b', + 'style' => 'numeric', + 'childregex' => [] + }, + { + 'name' => 'keyword', + 'regex' => '\\b(and|assert|break|class|continue|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|raise|return|try|while)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'braces', + 'regex' => '[\\{\\}]', + 'style' => 'braces', + 'childregex' => [] + }, + { + 'name' => 'symbols', + 'regex' => '([\\*\\-\\+=:;%&\\|<>\\(\\)\\[\\]!])', + 'style' => 'symbol', + 'childregex' => [] + }, + { + 'name' => 'identifiers', + 'regex' => '([a-zA-Z_][a-zA-Z_0-9]*)', + 'style' => 'identifier', + 'childregex' => [] + }, + { + 'name' => 'function', + 'regex' => '[\\t ]*def[\\t ]+([a-zA-Z0-9_]+)[\\t \\(]+.*?[\\n{]', + 'style' => 'function header', + 'childregex' => [ + { + 'name' => 'function args', + 'regex' => '\\(.*?\\)', + 'style' => 'function header args', + 'childregex' => [] + }, + { + 'name' => 'function name', + 'regex' => '[\\t ][a-zA-Z0-9_]+', + 'style' => 'function header name', + 'childregex' => [] + } + ] + }, + { + 'name' => 'library functions', + 'regex' => '\\b(__import__|abs|apply|buffer|callable|chr|cmp|coerce|compile|complex|delatter|dir|divmod|eval|execfile|filter|float|getattr|globals|hasattr|hash|hex|id|input|int|intern|isinstance|issubclass|len|list|locals|long|map|max|min|oct|open|ord|pow|range|raw_input|reduce|reload|repr|round|setattr|slice|str|tuple|type|unichr|unicode|vars|xrange|zip)\\b', + 'style' => 'library function', + 'childregex' => [] + }, + ] + }; + + + +# by Joshua Swink +$LANGUAGE{'ruby'} = { + 'filename' => '\\.rb$', + 'regex' => '^\\s*#\\s*![^\\s]*\\bruby\\b', + 'patterns' => [ + { + 'name' => 'comment', + 'regex' => '(?:#.*?(?:\r?\n\s*)+)+', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'predefined variables', + 'regex' => '(?:\\$(?:[!@&`\'+\\d~=/\\\\,;.<>_*\\$?:"]|DEBUG|FILENAME|LOAD_PATH|stdin|stdout|stderr|VERBOSE|-[0adFiIlpv])|\\b(?:TRUE|FALSE|NIL|STDIN|STDOUT|STDERR|ENV|ARGF|ARGV|DATA|RUBY_VERSION|RUBY_RELEASE_DATE|RUBY_PLATFORM)\\b)', + 'style' => 'predefined identifier', + 'childregex' => [] + }, + { + 'name' => 'variables', + 'regex' => '[\\$@](?:{[^}]*}|[^\\w/\\t\\n\\.,\\\\[\\\\{\\\\(]|[0-9]+|[a-zA-Z_][\\w.]*)?', + 'style' => 'identifier', + 'childregex' => [] + }, + { + 'name' => '"" string', + 'regex' => '""|"(?:\\\\\\\\)+"|".*?(?:[^\\\\](?:\\\\\\\\)*)"|%[Qwx]?([^\\w\\[\\](){}<>])\\2|%[Qwx]?([^\\w\\[\\](){}<>]).*?(?:[^\\\\](?:\\\\\\\\)*)\\3|%[Qwx]?([^\\w\\[\\](){}<>])\\\\\\\\\\4|%[Qwx]?\\[\\]|%[Qwx]?\\[.*?([^\\\\](\\\\\\\\)*)\\]|%[Qwx]?\\[\\\\\\\\\\]|%[Qwx]?\\{\\}|%[Qwx]?\\{.*?([^\\\\](\\\\\\\\)*)\\}|%[Qwx]?\\{\\\\\\\\\\}|%[Qwx]?\\(\\)|%[Qwx]?\\(.*?([^\\\\](\\\\\\\\)*)\\)|%[Qwx]?\\(\\\\\\\\\\)|%[Qwx]?<>|%[Qwx]?<.*?([^\\\\](\\\\\\\\)*)>|%[Qwx]?<\\\\\\\\>', + + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex', => '\\\\(?:x[\\da-fA-F]{2}|\d\d\d|c.|M-\\\\C-.|M-.|C-.|.)', + 'style' => 'esc character', + 'childregex' => [] + }, + { + 'name' => 'string expression', + 'regex' => '#[\\$\\@][a-zA-Z_][\\w.]*|#\\{[\\$\\@]?[^\\}]*\\}', + 'style' => 'identifier', + 'childregex' => [] + } + ] + }, + { + 'name' => '\'\' string', + 'regex' => '\'\'|\'(?:\\\\\\\\)+\'|\'.*?(?:[^\\\\](?:\\\\\\\\)*)\'|%q([^\\w\\[\\](){}<>])\\2|%q([^\\w\\[\\](){}<>]).*?(?:[^\\\\](?:\\\\\\\\)*)\\3|%q([^\\w\\[\\](){}<>])\\\\\\\\\\4|%q\\[\\]|%q\\[.*?([^\\\\](\\\\\\\\)*)\\]|%q\\[\\\\\\\\\\]|%q\\{\\}|%q\\{.*?([^\\\\](\\\\\\\\)*)\\}|%q\\{\\\\\\\\\\}|%q\\(\\)|%q\\(.*?([^\\\\](\\\\\\\\)*)\\)|%q\\(\\\\\\\\\\)|%q<>|%q<.*?([^\\\\](\\\\\\\\)*)>|%q<\\\\\\\\>', + 'style' => 'string', + 'childregex' => [ + { + 'name' => 'esc character', + 'regex' => '(?:\\\\\'|\\\\\\\\)', + 'style' => 'esc character', + 'childregex' => [] + } + ] + }, + { + 'name' => 'subroutine header', + 'regex' => 'def[\\t ]+\\w[\\w.]*(?:\\([^)]*\\))?', + 'style' => 'function header', + 'childregex' => [ + { + 'name' => 'arg list', + 'regex' => '\\(.*\\)', + 'style' => 'function header args', + 'childregex' => [ + { + 'name' => 'arg list parens', + 'regex' => '[\\(\\)]', + 'style' => 'symbol', + 'childregex' => [] + } + ] + }, + { + 'name' => 'subroutine header', + 'regex' => '[\\t ]\w+', + 'style' => 'function header name', + 'childregex' => [] + } + ] + }, + { + 'name' => 'class header', + 'regex' => 'class[\\t ]+\\w+(?:\\s*<\\s*\\w+)?', + 'style' => 'function header', + 'childregex' => [ + { + 'name' => 'class ancestor', + 'regex' => '<\\s*\\w+', + 'style' => 'include', + 'childregex' => [ + { + 'name' => 'inheritance doohickey', + 'regex' => '<', + 'style' => 'symbol', + 'childregex' => [] + } + ] + }, + { + 'name' => 'class main', + 'regex' => '[\\t ]\\w+', + 'style' => 'type', + 'childregex' => [] + } + ] + }, + { + 'name' => 'regex matching 0', + 'regex' => '(?:%r([^\\w\\[\\](){}<>])\\2|%r([^\\w\\[\\](){}<>]).*?(?:[^\\\\](?:\\\\\\\\)*)\\3|%r([^\\w\\[\\](){}<>])\\\\\\\\\\4|%r\\[\\]|%r\\[.*?([^\\\\](\\\\\\\\)*)\\]|%r\\[\\\\\\\\\\]|%r\\{\\}|%r\\{.*?([^\\\\](\\\\\\\\)*)\\}|%r\\{\\\\\\\\\\}|%r\\(\\)|%r\\(.*?([^\\\\](\\\\\\\\)*)\\)|%r\\(\\\\\\\\\\)|%r<>|%r<.*?([^\\\\](\\\\\\\\)*)>|%r<\\\\\\\\>)[ixpno]*', + 'style' => 'regex', + 'childregex' => [ + { + 'name' => 'string expression', + 'regex' => '#[\\$\\@][a-zA-Z_][\\w.]*|#\\{[\\$\\@]?[a-zA-Z_][^\\}]*\\}', + 'style' => 'identifier', + 'childregex' => [] + } + ] + }, + { + 'name' => 'regex matching I', + 'regex' => '(?:\\b| )?(?:/(?:\\\\/|[^/\\n])*(?:/[ixpno]*))', + 'style' => 'regex', + 'childregex' => [ + { + 'name' => 'string expression', + 'regex' => '#[\\$\\@][a-zA-Z_][\\w.]*|#\\{[\\$\\@]?[a-zA-Z_][^\\}]*\\}', + 'style' => 'identifier', + 'childregex' => [] + } + ] + }, + { + 'name' => 'reserved words', + 'regex' => '\\b(BEGIN|class|ensure|nil|self|when|END|def|false|not|super|while|alias|defined|for|or|then|yield|and|do|if|redo|true|begin|else|in|rescue|undef|break|elsif|module|retry|unless|case|end|next|return|until)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'kernel module methods', + 'regex', => '\\b(Array|Float|Integer|String|at_exit|autoload|binding|caller|catch|chop|chomp|chomp!|eval|exec|exit|fail|fork|format|gets|global_variables|gsub|iterator|lambda|load|local_variables|loop|open|p|print|printf|proc|putc|puts|raise|rand|readline|readlines|require|select|sleep|split|sprintf|srand|sub|syscall|system|test|trace_var|trap|untrace_var)\\b', + 'style' => 'library function', + 'childregex' => [] + }, + { + 'name' => 'braces, parens and brakets', + 'regex' => '[\\[\\]\\{\\}\\(\\)]', + 'style' => 'braces', + 'childregex' => [] + }, + { + 'name' => '<< stuff', + 'regex' => '<<(?:("|\')([^\\n]*)\\2|\\w*).*?^\\3$', + 'style' => 'text', + 'childregex' => [] + }, + { + 'name' => 'symbols', + 'regex' => '(?:[:*-+<>=^!,/]+|\.\.+)', + 'style' => 'symbol', + 'childregex' => [] + }, + { + 'name' => 'numbers', + 'regex' => '\d[\d.]*', + 'style' => 'numeric', + 'childregex' => [] + }, + { + 'name' => 'embedded documentation', + 'regex' => '^=.*?^(?:=end|\\Z)', + 'style' => 'doc comment', + 'childregex' => [] + } + ] + }; + +# taken from nedit +# modified by PP +# very inclomplete! +$LANGUAGE{'sql'} = { + 'filename' => '(?i)\\.sql$', + 'regex' => '', + 'patterns' => [ + { + 'name' => 'keywords I', + 'regex' => '(?i)(,|%|<|>|:=|=|\\(|\\)|\\bselect|on|from|order by|desc|where|and|or|not|null|true|false)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'comment I', + 'regex' => '--.*?$', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'comment II', + 'regex' => '/\\*.*?\\*/', + 'style' => 'comment', + 'childregex' => [] + }, + { + 'name' => 'string', + 'regex' => '\'\'|\'.*?([^\\\\](\\\\\\\\)*)\'|\'\\\\\\\\\'', +# 'regex' => '(\'\'|\'[^\'\\\\]\'|\'[^\'].*?[^\\\\]\')', + 'style' => 'string', + 'childregex' => [] + }, + { + 'name' => 'keywords II', + 'regex' => '(?i)end if;|\\b(create|replace|begin|end|function|return|fetch|open|close|into|is|in|when|others|grant|on|to|exception|show|set|out|pragma|as|package)\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'keywords III', + 'regex' => '(?i)\\balter\\b', + 'style' => 'reserved word', + 'childregex' => [] + }, + { + 'name' => 'datatypes', + 'regex' => '(?i)\\b(integer|blol|date|numeric|character|varying|varchar|char)\\b', + 'style' => 'predefined type', + 'childregex' => [] + }, + { + 'name' => 'words', + 'regex' => '(?i)\\b(constraint|key|references|primary|table|foreign|add|insert|group by)\\b', + 'style' => 'reserved word', + 'childregex' => [] + } + ] + }; + + + + +# enhanced by W. Friebel +$LANGUAGE{'patch'} = { + 'filename' => '(?i)\\.patch$|\\.diff$', + 'regex' => '', + 'patterns' => [ + { + 'name' => 'header', + 'regex' => '^Index: .*?$|^===== .*?$|^diff .*?$|^--- .*?$|^\+\+\+ .*?$|^\*\*\* .*?$', + 'style' => 'separator', + 'childregex' => [] + }, + { + 'name' => 'hunk', + 'regex' => '^@@ .*?$', + 'style' => 'line spec', + 'childregex' => [] + }, + { + 'name' => 'from', + 'regex' => '^-.*?$', + 'style' => 'deletion', + 'childregex' => [] + }, + { + 'name' => 'to', + 'regex' => '^\+.*?$', + 'style' => 'insertion', + 'childregex' => [] + }, + { + 'name' => 'mod', + 'regex' => '^\!.*?$', + 'style' => 'modification', + 'childregex' => [] + }, + ] + }; + + + +##### +# +# LANGUAGE: shell script +# + +$LANGUAGE{'shellscript'} = { + 'filename' => '\\.(sh|shell)$', + 'regex' => '^\\s*#\\s*![^\\s]*(sh|bash|ash|zsh|ksh)', + 'patterns' => [ { + 'name' => 'comment', +# 'regex' => '^[ \t]*[^$]?\#[^!]?.*?$', + 'regex' => '(^| )#([^\\!].)*?$', + 'style' => 'comment', + 'childregex' => [] + }, { + 'name' => 'identifier', + 'regex' => '[a-zA-Z][a-zA-Z0-9_]*=', + 'style' => 'identifier', + 'childregex' => [ { + 'name' => 'identifier', + 'regex' => '[a-zA-Z][a-zA-Z0-9_]*', + 'style' => 'identifier', + 'childregex' => [] + } ] + }, { + 'name' => 'identifier', + 'regex' => '\\$([0-9#\\*]|[a-zA-Z][a-zA-Z0-9_]*)', + 'style' => 'identifier', + 'childregex' => [] + }, { + 'name' => 'interpreter line', + 'regex' => '^[ \t]*#!.*?$', + 'style' => 'preprocessor', + childregex => [] + }, { + 'name' => 'string', + 'regex' => '""|"(\\\\"|[^\\"])*"', + 'style' => 'string', + childregex => [ { + 'name' => 'identifier', + 'regex' => '\\$([0-9#\\*]|[a-zA-Z][a-zA-Z0-9_]*)', + 'style' => 'identifier', + 'childregex' => [] + } ] + } ] +}; + +$LANGUAGE{'sh'} = $LANGUAGE{'shellscript'}; +return \%LANGUAGE; + +}; +use Getopt::Std; +getopts('i:l:') || exit 2; + # external colorizer ? + if ( $ENV{LESSCOLORIZER} and basename($ENV{LESSCOLORIZER}) ne 'code2color' ) { + # for security reasons do accept only a limited set of colorizers + die "$ENV{LESSCOLORIZER} is not an allowed colorizer, use one of ", + join(', ',@colorizers), " instead\n" + if ! grep {basename($ENV{LESSCOLORIZER}) eq $_} @colorizers; + die "$ENV{LESSCOLORIZER} not found or not an executable\n" + if ! -x $ENV{LESSCOLORIZER} + and ! grep { -x "$_/$ENV{LESSCOLORIZER}" } split /:/, $ENV{PATH}; + # call external colorizer + if ($ENV{LESSCOLORIZER} eq 'pygmentize') { + # do not call pygmentize with - and use option -g + @ARGV = grep {$_ ne '-'} @ARGV; + unshift @ARGV, '-g'; + } + system($ENV{LESSCOLORIZER}, @ARGV); + exit; + } + $str = main(parse_passed_params( infile => $ARGV[0] || '-', + outfile => '-', +# linenumbers => 1 , + langmode => $opt_l , + outputformat => 'xterm' , + # many other options + )); + +1; + +__END__ + +=head1 Code2HTML + + Convert source code (c,java,perl,html,...) into formatted html. + +=head1 SYNOPSIS + + use Code2HTML; + $html = code2html( $sourcecode ); + # or + code2html( infile => 'file.java' , + outfile => 'file.html', + linenumbers => 1 , + langmode => 'perl' , + # many other options + ); + +=head1 DESCRIPTION + +Code2HTML converts source code into color-coded, formatted html, +either as a simple code2html() function call, or as an Apache handler. + +This package is an adaptation of Peter Palfrader's code2html application. + +The statement + + use Code2HTML; + +exports the function code2html(), which takes the following arguments + + $html = code2html( + input => $source_code, + infile => 'filename.extension', + + outfile => 'file.html', + outputformat => 'html', # or html-dark, or ... + + langmode => 'java', # or perl,html,c,... + langfile => 'langFile', # specify alternative + # syntax definitions + + linenumbers => 1, # turn on linenumbers + linknumbers => 1, # linenumber links + line_number_prefix => '-', # linenumber anchors + replacetabs => 8, # tabs to spaces + + noheader => '', # don't use template + template => 'filename', # override template + + title => $title, # set html page title + content_type => 1, # output httpd header + ); + +All input parameters are optional except the source code +specification, which must be defined by either input or infile keys, or +by passing exactly one argument which will then be taken to be the +source code. + + input source code to be converted (or set source -infile) + + infile name of file with code to be converted (or use -input) + + langmode language of source file. If omitted, code2html + will try to guess from the language from the file extension + or start of the source code. Language modes provided are + + ada, ada95, awk, c, c++, cc, cxx, groff, html, + java, javascript, js, m4, make, makefile, pas, + pas, pascal, perl, plain, pov, povray, ruby, sql. + + langfile filename of file with alternative syntax definitions + + outfile name of file to put html in. If omitted, + just return html in $html=code2html(...) + + outputformat style of output html. Available formats are + html (default), html-dark, html-light, html-nobg. + + replacetabs replace tabs in source with given number of spaces + + title set title of output html page + + content_type output a Content-Type httpd header + + linenumbers print line numbers in source code listing + +=head1 AUTHOR + +Jim Mahoney (mahoney AT marlboro.edu), Peter Palfrader, and others. + +=head1 COPYRIGHT and LICENSE + + Copyright (c) 1999, 2000 by Peter Palfrader and others. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +``Software''), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +=head1 SEE ALSO + + Peter Palfrader's Code2HTML page at http://www.palfrader.org/code2html/ + diff --git a/home/.local/bin/lesspipe.sh b/home/.local/bin/lesspipe.sh new file mode 100755 index 0000000..321226a --- /dev/null +++ b/home/.local/bin/lesspipe.sh @@ -0,0 +1,840 @@ +#!/bin/bash +# lesspipe.sh, a preprocessor for less (version 1.83) +#=============================================================================== +### THIS FILE IS GENERATED FROM lesspipe.sh.in, PLEASE GET THE ZIP FILE +### from https://github.com/wofr06/lesspipe.sh/archive/lesspipe.zip +### AND RUN configure TO GENERATE A lesspipe.sh THAT WORKS IN YOUR ENVIRONMENT +#=============================================================================== +# +# Usage: lesspipe.sh is called when the environment variable LESSOPEN is set: +# LESSOPEN="|lesspipe.sh %s"; export LESSOPEN (sh like shells) +# setenv LESSOPEN "|lesspipe.sh %s" (csh, tcsh) +# Use the fully qualified path if lesspipe.sh is not in the search path +# View files in multifile archives: +# less archive_file:contained_file +# This can be used to extract ASCII files from a multifile archive: +# less archive_file:contained_file>extracted_file +# As less is not good for extracting raw data use instead: +# lesspipe.sh archive_file:contained_file>extracted_file +# Even a file in a multifile archive that itself is contained in yet +# another archive can be viewed this way: +# less super_archive:archive_file:contained_file +# Display the last file in the file1:..:fileN chain in raw format: +# Suppress input filtering: less file1:..:fileN: (append a colon) +# Suppress decompression: less file1:..:fileN:: (append 2 colons) +# +# Required programs and supported formats: see the separate file README +# License: GPL (see file LICENSE) +# History: see the separate file ChangeLog +# Author: Wolfgang Friebel, DESY (Wolfgang.Friebel AT desy.de) +# +#=============================================================================== +( [[ -n 1 && -n 2 ]] ) > /dev/null 2>&1 || exec zsh -y --ksh-arrays -- "$0" ${1+"$@"} +#setopt KSH_ARRAYS SH_WORD_SPLIT 2>/dev/null +set +o noclobber +tarcmd='tar' + +dir=${LESSOPEN#\|} +dir=${dir%%lesspipe.sh*\%s} +dir=${dir%%/} +PATH=$PATH:$dir + +cmd_exist () { + command -v "$1" > /dev/null 2>&1 && return 0 || return 1 +} + +filecmd() { + file -L -s "$@" + file -L -s -i "$@" 2> /dev/null | sed -n 's/.*charset=/;/p' | tr a-z A-Z +} + +sep=: # file name separator +altsep== # alternate separator character +if [[ -e "$1" && "$1" = *$sep* || "$1" = *$altsep ]]; then + sep=$altsep + xxx="${1%=}" + set "$xxx" +fi +if cmd_exist mktemp; then + tmpdir=$(mktemp -d "${TMPDIR:-/tmp}/lesspipe.XXXXXXXXXX") + + nexttmp () { + # nexttmp -d returns a directory + mktemp $1 "${tmpdir}/XXXXXXXX" + } +else + tmpdir=${TMPDIR:-/tmp}/lesspipe.$RANDOM + mkdir $tmpdir + + nexttmp () { + new="$tmpdir/lesspipe.$RANDOM" + [[ "$1" = -d ]] && mkdir $new + echo $new + } +fi +[[ -d "$tmpdir" ]] || exit 1 +trap "rm -rf '$tmpdir'" 0 +trap - PIPE + +unset iconv +iconv() { + if [[ -z "$iconv" ]]; then + arg=$(printf "%s$(command iconv --help 2>/dev/null | \ + sed -n 's/.*\(--.*-subst=\)\(FORMATSTRING\).*/\1\\033[7m?\\033[m/p' | \ + tr \\n ' ')") + if [[ -n "$arg" ]]; then + iconv="command iconv -c $arg -t //TRANSLIT" + else + iconv="command iconv -c" + fi + fi + if $iconv "$@" > /dev/null 2>&1; then + msg "append $sep to filename to view the $2 encoded data" + $iconv "$@" + fi +} + +msg () { + if [[ -n "$LESSQUIET" ]]; then + return + fi + echo "==> $@" +} + +filetype () { + # wrapper for 'file' command + typeset name + name="$1" + if [[ "$1" = - ]]; then + dd bs=40000 count=1 > "$tmpdir/file" 2>/dev/null + set "$tmpdir/file" "$2" + name="$filen" + fi + if [[ ("$name" = *.br || "$name" = *.bro || "$name" = *.tbr) ]]; then + # In current format, brotli can only be detected by extension + echo " brotli compressed data" + return + fi + typeset type + # type=" $(filecmd -b "$1")" # not supported by all versions of 'file' + type=$(filecmd "$1" | cut -d : -f 2-) + if [[ "$type" = " empty" ]]; then + # exit if file returns "empty" (e.g., with "less archive:nonexisting_file") + exit 1 + elif [[ "$type" = *XML* && "$name" = *html ]]; then + type=" HTML document text" + elif [[ ("$type" = *HTML* || "$type" = *ASCII*) && "$name" = *xml ]]; then + type=" XML document text" + elif [[ "$type" != *lzip\ compressed* && ("$name" = *.lzma || "$name" = *.tlz) ]]; then + type=" LZMA compressed data" + elif [[ ("$type" = *Zip* || "$type" = *ZIP*) && ("$name" = *.jar || "$name" = *.xpi) ]]; then + type=" Zip compressed Jar archive" + elif [[ "$type" = *Microsoft\ Office\ Document* && ("$name" = *.ppt) ]]; then + type=" PowerPoint document" + elif [[ "$type" = *Microsoft\ Office\ Document* && ("$name" = *.xls) ]]; then + type=" Excel document" + elif [[ "$type" = *Hierarchical\ Data\ Format* && ("$name" = *.nc4) ]]; then + type=" NetCDF Data Format data" + elif [[ "$type" = *roff\ *,* && ("$name" = */[Mm]akefile || "$name" = */[Mm]akefile.* || "$name" = */BSDmakefile || "$name" = *.mk) ]]; then + # Sometimes a BSD makefile is identified as "troff or + # preprocessor input text" probably due to its ".if" style + # directives. + type=" BSD makefile script,${type#*,}}" + fi + echo "$type" +} + +show () { + file1="${1%%$sep*}" + rest1="${1#$file1}" + while [[ "$rest1" = ::* ]]; do + if [[ "$rest1" = "::" ]]; then + break + else + rest1="${rest1#$sep$sep}" + file1="${rest1%%$sep*}" + rest1="${rest1#$file1}" + file1="${1%$rest1}" + fi + done + if [[ ! -e $file1 && "$file1" != '-' ]]; then + return + fi + rest11="${rest1#$sep}" + file2="${rest11%%$sep*}" + rest2="${rest11#$file2}" + while [[ "$rest2" = ::* ]]; do + if [[ "$rest2" = "::" ]]; then + break + else + rest2="${rest2#$sep$sep}" + file2="${rest2%%$sep*}" + rest2="${rest2#$file2}" + file2="${rest11%$rest2}" + fi + done + if [[ "$file2" != "" ]]; then + in_file="-i$file2" + fi + rest2="${rest11#$file2}" + rest11="$rest1" + + if cmd_exist html2text || cmd_exist elinks || cmd_exist links || cmd_exist lynx || cmd_exist w3m; then + PARSEHTML=yes + else + PARSEHTML=no + fi + + if [[ "$cmd" = "" ]]; then + type=$(filetype "$file1") || exit 1 + if cmd_exist lsbom; then + if [[ ! -f "$file1" ]]; then + if [[ "$type" = *directory* ]]; then + if [[ "$file1" = *.pkg ]]; then + if [[ -f "$file1/Contents/Archive.bom" ]]; then + type="bill of materials" + file1="$file1/Contents/Archive.bom" + msg "This is a Mac OS X archive directory, showing its contents (bom file)" + fi + fi + fi + fi + fi + get_cmd "$type" "$file1" "$rest1" + if [[ "$cmd" != "" ]]; then + show "-$rest1" + else + isfinal "$type" "$file1" "$rest11" + fi + elif [[ "$c1" = "" ]]; then + c1=("${cmd[@]}") + type=$("${c1[@]}" | filetype -) || exit 1 + get_cmd "$type" "$file1" "$rest1" + if [[ "$cmd" != "" ]]; then + show "-$rest1" + else + "${c1[@]}" | isfinal "$type" - "$rest11" + fi + elif [[ "$c2" = "" ]]; then + c2=("${cmd[@]}") + type=$("${c1[@]}" | "${c2[@]}" | filetype -) || exit 1 + get_cmd "$type" "$file1" "$rest1" + if [[ "$cmd" != "" ]]; then + show "-$rest1" + else + "${c1[@]}" | "${c2[@]}" | isfinal "$type" - "$rest11" + fi + elif [[ "$c3" = "" ]]; then + c3=("${cmd[@]}") + type=$("${c1[@]}" | "${c2[@]}" | "${c3[@]}" | filetype -) || exit 1 + get_cmd "$type" "$file1" "$rest1" + if [[ "$cmd" != "" ]]; then + show "-$rest1" + else + "${c1[@]}" | "${c2[@]}" | "${c3[@]}" | isfinal "$type" - "$rest11" + fi + elif [[ "$c4" = "" ]]; then + c4=("${cmd[@]}") + type=$("${c1[@]}" | "${c2[@]}" | "${c3[@]}" | "${c4[@]}" | filetype -) || exit 1 + get_cmd "$type" "$file1" "$rest1" + if [[ "$cmd" != "" ]]; then + show "-$rest1" + else + "${c1[@]}" | "${c2[@]}" | "${c3[@]}" | "${c4[@]}" | isfinal "$type" - "$rest11" + fi + elif [[ "$c5" = "" ]]; then + c5=("${cmd[@]}") + type=$("${c1[@]}" | "${c2[@]}" | "${c3[@]}" | "${c4[@]}" | "${c5[@]}" | filetype -) || exit 1 + get_cmd "$type" "$file1" "$rest1" + if [[ "$cmd" != "" ]]; then + echo "$0: Too many levels of encapsulation" + else + "${c1[@]}" | "${c2[@]}" | "${c3[@]}" | "${c4[@]}" | "${c5[@]}" | isfinal "$type" - "$rest11" + fi + fi +} + +get_cmd () { + cmd= + typeset t + if [[ "$1" = *[bg]zip*compress* || "$1" = *compress\'d\ * || "$1" = *packed\ data* || "$1" = *LZMA\ compressed* || "$1" = *lzip\ compressed* || "$1" = *[Xx][Zz]\ compressed* || "$1" = *Zstandard\ compressed* || "$1" = *[Bb]rotli\ compressed* || "$1" = *LZ4\ compressed* ]]; then ## added '#..then' to fix vim's syntax parsing + if [[ "$3" = $sep$sep ]]; then + return + elif [[ "$1" = *bzip*compress* ]] && cmd_exist bzip2; then + cmd=(bzip2 -cd "$2") + if [[ "$2" != - ]]; then filen="$2"; fi + case "$filen" in + *.bz2) filen="${filen%.bz2}";; + *.tbz) filen="${filen%.tbz}.tar";; + esac + return + elif [[ "$1" = *lzip\ compressed* ]] && cmd_exist lzip; then + cmd=(lzip -cd "$2") + if [[ "$2" != - ]]; then filen="$2"; fi + case "$filen" in + *.lz) filen="${filen%.lz}";; + *.tlz) filen="${filen%.tlz}.tar";; + esac + elif [[ "$1" = *LZMA\ compressed* ]] && cmd_exist lzma; then + cmd=(lzma -cd "$2") + if [[ "$2" != - ]]; then filen="$2"; fi + case "$filen" in + *.lzma) filen="${filen%.lzma}";; + *.tlz) filen="${filen%.tlz}.tar";; + esac + elif [[ "$1" = *gzip\ compress* || "$1" = *compress\'d\ * || "$1" = *packed\ data* ]]; then ## added '#..then' to fix vim's syntax parsing + cmd=(gzip -cd "$2") + if [[ "$2" != - ]]; then filen="$2"; fi + case "$filen" in + *.gz) filen="${filen%.gz}";; + *.tgz) filen="${filen%.tgz}.tar";; + esac + elif [[ "$1" = *[Xx][Zz]\ compressed* ]] && cmd_exist xz; then + cmd=(xz -cd "$2") + if [[ "$2" != - ]]; then filen="$2"; fi + case "$filen" in + *.xz) filen="${filen%.xz}";; + *.txz) filen="${filen%.txz}.tar";; + esac + elif [[ "$1" = *Zstandard\ compressed* ]] && cmd_exist zstd; then + cmd=(zstd -cdq "$2") + if [[ "$2" != - ]]; then filen="$2"; fi + case "$filen" in + *.zst) filen="${filen%.zst}";; + *.tzst) filen="${filen%.tzst}.tar";; + esac + elif [[ "$1" = *[Bb]rotli\ compressed* ]] && cmd_exist brotli; then + cmd=(brotli -cd -- "$2") + if [[ "$2" != - ]]; then filen="$2"; fi + case "$filen" in + *.br|*.bro) filen="${filen%.*}";; + *.tbr) filen="${filen%.*}.tar";; + esac + elif [[ "$1" = *LZ4\ compressed* ]] && cmd_exist lz4; then + cmd=(lz4 -cdq "$2") + if [[ "$2" != - ]]; then filen="$2"; fi + case "$filen" in + *.lz4) filen="${filen%.*}";; + *.tl4|*.tz4|*.tlz4) filen="${filen%.*}.tar";; + esac + fi + return + fi + + rsave="$rest1" + rest1="$rest2" + if [[ "$file2" != "" ]]; then + if [[ "$1" = *\ tar* || "$1" = *\ tar* ]]; then + cmd=(istar "$2" "$file2") + elif [[ "$1" = *Debian* ]]; then + data=`ar t "$2"|grep data.tar` + cmd2=("unpack_cmd" "$data") + t=$(nexttmp) + if [[ "$file2" = control/* ]]; then + istemp "ar p" "$2" control.tar.gz | gzip -dc - > "$t" + file2=".${file2:7}" + else + istemp "ar p" "$2" $data | $("${cmd2[@]}") > "$t" + fi + cmd=(istar "$t" "$file2") + elif [[ "$1" = *RPM* ]] && cmd_exist cpio && ( cmd_exist rpm2cpio || cmd_exist rpmunpack ); then + cmd=(isrpm "$2" "$file2") + elif [[ "$1" = *Jar\ archive* ]] && cmd_exist fastjar; then + cmd=(isjar "$2" "$file2") + elif [[ "$1" = *Zip* || "$1" = *ZIP* ]] && cmd_exist unzip; then + cmd=(istemp "unzip -avp" "$2" "$file2") + elif [[ "$1" = *RAR\ archive* ]]; then + if cmd_exist unrar; then + cmd=(istemp "unrar p -inul" "$2" "$file2") + elif cmd_exist rar; then + cmd=(istemp "rar p -inul" "$2" "$file2") + elif cmd_exist bsdtar; then + cmd=(istemp "bsdtar Oxf" "$2" "$file2") + fi + elif [[ "$1" = *7-zip\ archive* || "$1" = *7z\ archive* ]] && cmd_exist 7za; then + cmd=(istemp "7za e -so" "$2" "$file2") + elif [[ "$1" = *7-zip\ archive* || "$1" = *7z\ archive* ]] && cmd_exist 7zr; then + cmd=(istemp "7zr e -so" "$2" "$file2") + elif [[ "$1" = *[Cc]abinet* ]] && cmd_exist cabextract; then + cmd=(iscab "$2" "$file2") + elif [[ "$1" = *\ ar\ archive* ]]; then + cmd=(istemp "ar p" "$2" "$file2") + elif [[ "$1" = *ISO\ 9660* ]] && cmd_exist isoinfo; then + cmd=(isoinfo "-i$2" "-x$file2") + fi + if [[ "$cmd" != "" ]]; then + filen="$file2" + fi + fi +} + +iscab () { + typeset t + if [[ "$1" = - ]]; then + t=$(nexttmp) + cat > "$t" + set "$t" "$2" + fi + cabextract -pF "$2" "$1" +} + +istar () { + $tarcmd Oxf "$1" "$2" 2>/dev/null +} + +isdvi () { + typeset t + if [[ "$1" != *.dvi ]]; then + t="$tmpdir/tmp.dvi" + cat "$1" > "$t" + set "$t" + fi + dvi2tty -q "$1" +} + +istemp () { + typeset prog + typeset t + prog="$1" + t="$2" + shift + shift + if [[ "$t" = - ]]; then + t=$(nexttmp) + cat > "$t" + fi + if [[ $# -gt 0 ]]; then + $prog "$t" "$@" 2>/dev/null + else + $prog "$t" 2>/dev/null + fi +} + +nodash () { + typeset prog + prog="$1" + shift + if [[ "$1" = - ]]; then + shift + if [[ $# -gt 0 ]]; then + $prog "$@" 2>/dev/null + else + $prog 2>/dev/null + fi + else + $prog "$@" 2>/dev/null + fi +} + +isrpm () { + if cmd_exist rpm2cpio && cmd_exist cpio; then + typeset t + if [[ "$1" = - ]]; then + t=$(nexttmp) + cat > "$t" + set "$t" "$2" + fi + # setup $b as a batch file containing "$b.out" + typeset b + b=$(nexttmp) + echo "$b.out" > "$b" + # to support older versions of cpio the --to-stdout option is not used here + rpm2cpio "$1" 2>/dev/null|cpio -i --quiet --rename-batch-file "$b" "$2" + cat "$b.out" + elif cmd_exist rpmunpack && cmd_exist cpio; then + # rpmunpack will write to stdout if it gets file from stdin + # extract file $2 from archive $1, assume that cpio is sufficiently new + # (option --to-stdout existing) if rpmunpack is installed + cat "$1" | rpmunpack | gzip -cd | cpio -i --quiet --to-stdout "$2" + fi +} + +isjar () { + case "$2" in + /*) echo "lesspipe can't unjar files with absolute paths" >&2 + exit 1 + ;; + ../*) echo "lesspipe can't unjar files with ../ paths" >&2 + exit 1 + ;; + esac + typeset d + d=$(nexttmp -d) + [[ -d "$d" ]] || exit 1 + cat "$1" | ( + cd "$d" + fastjar -x "$2" + if [[ -f "$2" ]]; then + cat "$2" + fi + ) +} + +#parsexml () { nodash "elinks -dump -default-mime-type text/xml" "$1"; } +parsehtml () { + if [[ "$PARSEHTML" = no ]]; then + msg "No suitable tool for HTML parsing found, install one of html2text, elinks, links, lynx or w3m" + return + elif cmd_exist html2text; then + if [[ "$1" = - ]]; then html2text; else html2text "$1"; fi + elif cmd_exist lynx; then + if [[ "$1" = - ]]; then set - -stdin; fi + lynx -dump -force_html "$1" && return + elif cmd_exist w3m; then + nodash "w3m -dump -T text/html" "$1" + elif cmd_exist elinks; then + nodash "elinks -dump -force-html" "$1" + elif cmd_exist links; then + if [[ "$1" = - ]]; then set - -stdin; fi + links -dump -force_html "$1" + fi +} + +unpack_cmd() { + cmd_string="cat" + if [[ "$1" == *xz ]]; then + cmd_string="xz -dc -" + elif [[ "$1" == *gz ]]; then + cmd_string="gzip -dc -" + elif [[ "$1" == *bz2 ]]; then + cmd_string="bzip2 -dc -" + elif [[ "$1" == *lzma ]]; then + cmd_string="lzma -dc -" + elif [[ "$1" == *zst ]]; then + cmd_string="zstd -dcq -" + elif [[ ("$1" == *br || "$1" == *bro) ]]; then + cmd_string="brotli -dc -" + elif [[ "$1" == *lz4 ]]; then + cmd_string="lz4 -dcq -" + fi + echo "$cmd_string" +} + +isfinal() { + typeset t + if [[ "$3" = $sep$sep ]]; then + cat "$2" + return + elif [[ "$3" = $sep* ]]; then + if [[ "$3" = $sep ]]; then + msg "append :. or : to activate syntax highlighting" + else + lang=${3#$sep} + lang="-l ${lang#.}" + lang=${lang%%-l } + if cmd_exist code2color; then + code2color $PPID ${in_file:+"$in_file"} $lang "$2" + if [[ $? = 0 ]]; then + return + fi + fi + fi + cat "$2" + return + fi + + # color requires -r or -R when calling less + typeset COLOR + if [[ $(tput colors) -ge 8 && ("$LESS" = *-*r* || "$LESS" = *-*R*) ]]; then + COLOR="--color=always" + fi + + if [[ "$1" = *No\ such* ]]; then + exit 1 + elif [[ "$1" = *directory* ]]; then + cmd=(ls -lA $COLOR "$2") + if ! ls $COLOR > /dev/null 2>&1; then + cmd=(ls -lA -G "$2") + if ! ls -lA -G > /dev/null 2>&1; then + cmd=(ls -lA "$2") + fi + fi + msg "This is a directory, showing the output of ${cmd[@]}" + if [[ ${cmd[2]} = '-G' ]]; then + CLICOLOR_FORCE=1 "${cmd[@]}" + else + "${cmd[@]}" + fi + elif [[ "$1" = *\ tar* || "$1" = *\ tar* ]]; then + msg "use tar_file${sep}contained_file to view a file in the archive" + if [[ -n $COLOR ]] && cmd_exist tarcolor; then + $tarcmd tvf "$2" | tarcolor + else + $tarcmd tvf "$2" + fi + elif [[ "$1" = *RPM* ]]; then + header="use RPM_file${sep}contained_file to view a file in the RPM" + if cmd_exist rpm; then + echo $header + istemp "rpm -qivp" "$2" + header=""; + fi + if cmd_exist cpio && cmd_exist rpm2cpio; then + echo $header + echo "================================= Content ======================================" + istemp rpm2cpio "$2" 2>/dev/null|cpio -i -tv 2>/dev/null + elif cmd_exist cpio && cmd_exist rpmunpack; then + echo $header + echo "================================= Content ======================================" + cat "$2" | rpmunpack | gzip -cd | cpio -i -tv 2>/dev/null + else + msg "please install rpm2cpio or rpmunpack to see the contents of RPM files" + fi + elif [[ "$1" = *roff* ]] && cmd_exist groff; then + DEV=utf8 + if [[ $LANG != *UTF*8* && $LANG != *utf*8* ]]; then + if [[ "$LANG" = ja* ]]; then + DEV=nippon + else + DEV=latin1 + fi + fi + MACRO=andoc + if [[ "$2" = *.me ]]; then + MACRO=e + elif [[ "$2" = *.ms ]]; then + MACRO=s + fi + msg "append $sep to filename to view the nroff source" + groff -s -p -t -e -T$DEV -m$MACRO "$2" + elif [[ "$1" = *Debian* ]]; then + msg "use Deb_file${sep}contained_file to view a file in the Deb" + if cmd_exist dpkg; then + nodash "dpkg -I" "$2" + else + echo + istemp "ar p" "$2" control.tar.gz | gzip -dc - | $tarcmd tvf - | sed -r 's/(.{48})\./\1control/' + fi + data=`ar t "$2"|grep data.tar` + cmd2=("unpack_cmd" "$data") + echo + istemp "ar p" "$2" $data | $("${cmd2[@]}") | $tarcmd tvf - + # do not display all perl text containing pod using perldoc + #elif [[ "$1" = *Perl\ POD\ document\ text* || "$1" = *Perl5\ module\ source\ text* ]]; then + elif [[ "$1" = *Perl\ POD\ document\ text* ]] && cmd_exist perldoc; then + msg "append $sep to filename to view the perl source" + istemp perldoc "$2" + elif [[ "$1" = *\ script* ]]; then + set "plain text" "$2" + elif [[ "$1" = *text\ executable* ]]; then + set "plain text" "$2" + elif [[ "$1" = *PostScript* ]]; then + if cmd_exist pstotext; then + msg "append $sep to filename to view the postscript file" + nodash pstotext "$2" + elif cmd_exist ps2ascii; then + msg "append $sep to filename to view the postscript file" + istemp ps2ascii "$2" + else + msg "install pstotext or ps2ascii to view a textual representation of the file contents" + fi + elif [[ "$1" = *executable* ]]; then + msg "append $sep to filename to view the raw file" + nodash strings "$2" + elif [[ "$1" = *\ ar\ archive* ]]; then + msg "use library${sep}contained_file to view a file in the archive" + istemp "ar vt" "$2" + elif [[ "$1" = *shared* ]] && cmd_exist nm; then + msg "This is a dynamic library, showing the output of nm" + istemp nm "$2" + elif [[ "$1" = *Jar\ archive* ]] && cmd_exist fastjar; then + msg "use jar_file${sep}contained_file to view a file in the archive" + nodash "fastjar -tf" "$2" + elif [[ "$1" = *Zip* || "$1" = *ZIP* ]] && cmd_exist unzip; then + msg "use zip_file${sep}contained_file to view a file in the archive" + istemp "unzip -lv" "$2" + elif [[ "$1" = *RAR\ archive* ]]; then + if cmd_exist unrar; then + msg "use rar_file${sep}contained_file to view a file in the archive" + istemp "unrar v" "$2" + elif cmd_exist rar; then + msg "use rar_file${sep}contained_file to view a file in the archive" + istemp "rar v" "$2" + elif cmd_exist bsdtar; then + msg "use rar_file${sep}contained_file to view a file in the archive" + istemp "bsdtar tvf" "$2" + fi + elif [[ "$1" = *7-zip\ archive* || "$1" = *7z\ archive* ]] && cmd_exist 7za; then + typeset res + res=$(istemp "7za l" "$2") + if [[ "$res" = *\ 1\ file* ]]; then + msg "a 7za archive containing one file was silently unpacked" + if [[ "$2" != - ]]; then + 7za e -so "$2" 2>/dev/null + else + # extract name of temporary file containing the 7za archive + t=${res#*Listing\ archive:\ } + t2=" +" + t=${t%%$t2*} + 7za e -so $t 2>/dev/null + fi + else + msg "use 7za_file${sep}contained_file to view a file in the archive" + echo "$res" + fi + elif [[ "$1" = *7-zip\ archive* || "$1" = *7z\ archive* ]] && cmd_exist 7zr; then + typeset res + res=$(istemp "7zr l" "$2") + if [[ "$res" = *\ 1\ file* ]]; then + msg "a 7za archive containing one file was silently unpacked" + if [[ "$2" != - ]]; then + 7zr e -so "$2" 2>/dev/null + else + # extract name of temporary file containing the 7za archive + t=${res#*Listing\ archive:\ } + t2=" +" + t=${t%%$t2*} + 7zr e -so $t 2>/dev/null + fi + else + msg "use 7za_file${sep}contained_file to view a file in the archive" + echo "$res" + fi + elif [[ "$1" = *[Cc]abinet* ]] && cmd_exist cabextract; then + msg "use cab_file${sep}contained_file to view a file in the cabinet" + istemp "cabextract -l" "$2" + elif [[ "$1" = *\ DVI* ]] && cmd_exist dvi2tty; then + msg "append $sep to filename to view the raw DVI file" + isdvi "$2" + elif [[ "$PARSEHTML" = yes && "$1" = *HTML* ]]; then + msg "append $sep to filename to view the HTML source" + parsehtml "$2" + elif [[ "$1" = *PDF* ]] && cmd_exist pdftotext; then + msg "append $sep to filename to view the PDF source" + istemp pdftotext "$2" - + elif [[ "$PARSEHTML" = yes && "$1" = *PDF* ]] && cmd_exist pdftohtml; then + msg "append $sep to filename to view the PDF source" + t=$(nexttmp) + cat "$2" > "$t"; pdftohtml -stdout "$t" | parsehtml - + elif [[ "$1" = *Hierarchical\ Data\ Format* ]] && cmd_exist h5dump; then + istemp h5dump "$2" + elif [[ "$1" = *NetCDF* || "$1" = *Hierarchical\ Data\ Format* ]] && cmd_exist ncdump; then + istemp ncdump "$2" + elif [[ "$1" = *Matlab\ v[0-9.]*\ mat-file* ]] && cmd_exist matdump; then + msg "append $sep to filename to view the raw data" + matdump -d "$2" + elif [[ "$1" = *DjVu* ]] && cmd_exist djvutxt; then + msg "append $sep to filename to view the DjVu source" + djvutxt "$2" + elif [[ "$1" = *Microsoft\ Word* || "$1" = *Microsoft\ Office* ]]; then + if cmd_exist antiword; then + msg "append $sep to filename to view the raw word document" + antiword "$2" + elif cmd_exist catdoc; then + msg "append $sep to filename to view the raw word document" + catdoc "$2" + else + msg "install antiword or catdoc to view human readable text" + cat "$2" + fi + elif [[ "$1" = *Rich\ Text\ Format* ]] && cmd_exist unrtf; then + if [[ "$PARSEHTML" = yes ]]; then + msg "append $sep to filename to view the RTF source" + istemp "unrtf --html" "$2" | parsehtml - + else + msg "append $sep to filename to view the RTF source" + istemp "unrtf --text" "$2" | sed -e "s/^### .*//" | fmt -s + fi + elif [[ "$PARSEHTML" = yes && "$1" = *Excel\ document* ]] && cmd_exist xlhtml; then + msg "append $sep to filename to view the spreadsheet source" + xlhtml -te "$2" | parsehtml - + elif [[ "$PARSEHTML" = yes && "$1" = *PowerPoint\ document* ]] && cmd_exist ppthtml; then + msg "append $sep to filename to view the PowerPoint source" + ppthtml "$2" | parsehtml - + elif [[ "$PARSEHTML" = yes && ("$1" = *OpenDocument\ [CHMPST]* || "$1" = *OpenOffice\.org\ 1\.x\ [CIWdgpst]*) ]] && cmd_exist unzip; then + if cmd_exist o3tohtml; then + msg "append $sep to filename to view the OpenOffice or OpenDocument source" + istemp "unzip -avp" "$2" content.xml | o3tohtml | parsehtml - + elif cmd_exist sxw2txt; then + msg "append $sep to filename to view the OpenOffice or OpenDocument source" + istemp sxw2txt "$2" + else + msg "install at least sxw2txt from the lesspipe package to see plain text in openoffice documents" + fi + elif [[ "$1" = *ISO\ 9660* ]] && cmd_exist isoinfo; then + if [[ "$2" != - ]]; then + msg "append $sep to filename to view the raw data" + isoinfo -d -i "$2" + joliet=`isoinfo -d -i "$2" | egrep '^Joliet'|cut -c1` + echo "================================= Content ======================================" + isoinfo -lR$joliet -i "$2" + fi + elif [[ "$1" = *image\ data* || "$1" = *JPEG\ file* || "$1" = *JPG\ file* ]] && cmd_exist identify; then + msg "append $sep to filename to view the raw data" + identify -verbose "$2" + elif [[ "$1" = *MPEG\ *layer\ 3\ audio* || "$1" = *MPEG\ *layer\ III* || "$1" = *mp3\ file* || "$1" = *MP3* ]]; then + if cmd_exist id3v2; then + msg "append $sep to filename to view the raw data" + istemp "id3v2 -l" "$2" + elif cmd_exist mp3info2; then + msg "append $sep to filename to view the raw data" + mp3info2 "$2" + elif cmd_exist mp3info; then + msg "append $sep to filename to view the raw data" + mp3info "$2" + fi + elif [[ "$1" = *bill\ of\ materials* ]] && cmd_exist lsbom; then + msg "append $sep to filename to view the raw data" + lsbom -p MUGsf "$2" + elif [[ "$1" = *perl\ Storable* ]]; then + msg "append $sep to filename to view the raw data" + perl -MStorable=retrieve -MData::Dumper -e '$Data::Dumper::Indent=1;print Dumper retrieve shift' "$2" + elif [[ "$1" = *UTF-8* && $LANG != *UTF-8 ]] && cmd_exist iconv -c; then + iconv -c -f UTF-8 "$2" + elif [[ "$1" = *ISO-8859* && $LANG != *ISO-8859-1 ]] && cmd_exist iconv -c; then + iconv -c -f ISO-8859-1 "$2" + elif [[ "$1" = *UTF-16* && $LANG != *UTF-16 ]] && cmd_exist iconv -c; then + iconv -c -f UTF-16 "$2" + elif [[ "$1" = *GPG\ encrypted\ data* || "$1" = *PGP\ *ncrypted* ]] && cmd_exist gpg; then + msg "append $sep to filename to view the encrypted file" + gpg -d "$2" + elif [[ "$1" = *Apple\ binary\ property\ list* ]] && cmd_exist plutil; then + msg "append $sep to filename to view the raw data" + plutil -convert xml1 -o - "$2" + elif [[ "$1" = *data* ]]; then + msg "append $sep to filename to view the raw data" + nodash strings "$2" + elif [[ "$2" = *.crt || "$2" = *.pem ]] && cmd_exist openssl; then + msg "append $sep to filename to view the raw data" + openssl x509 -hash -text -noout -in "$2" + elif [[ "$2" = *.csr ]] && cmd_exist openssl; then + msg "append $sep to filename to view the raw data" + openssl req -text -noout -in "$2" + elif [[ "$2" = *.crl ]] && cmd_exist openssl; then + msg "append $sep to filename to view the raw data" + openssl crl -hash -text -noout -in "$2" + else + set "plain text" "$2" + fi + if [[ "$1" = *plain\ text* ]]; then + if cmd_exist code2color; then + code2color $PPID ${in_file:+"$in_file"} "$2" + if [[ $? = 0 ]]; then + return + fi + fi + fi + if [[ "$2" = - ]]; then + cat + fi +} + +IFS=$sep a="$@" +IFS=' ' +if [[ "$a" = "" ]]; then + if [[ "$0" != /* ]]; then + pat=`pwd`/ + fi + if [[ "$SHELL" = *csh ]]; then + echo "setenv LESSOPEN \"|$pat$0 %s\"" + else + echo "LESSOPEN=\"|$pat$0 %s\"" + echo "export LESSOPEN" + fi +else + # check for pipes so that "less -f ... <(cmd) ..." works properly + [[ -p "$1" ]] && exit 1 + show "$a" +fi diff --git a/home/.local/bin/op b/home/.local/bin/op new file mode 120000 index 0000000..8bf5a84 --- /dev/null +++ b/home/.local/bin/op @@ -0,0 +1 @@ +../../../private/home/.local/bin/op \ No newline at end of file diff --git a/home/.ssh b/home/.ssh new file mode 120000 index 0000000..286c706 --- /dev/null +++ b/home/.ssh @@ -0,0 +1 @@ +../private/home/.ssh/ \ No newline at end of file diff --git a/home/.termux/colors.properties b/home/.termux/colors.properties new file mode 100644 index 0000000..ca66117 --- /dev/null +++ b/home/.termux/colors.properties @@ -0,0 +1 @@ +# Using default color theme. \ No newline at end of file diff --git a/home/.termux/termux.properties b/home/.termux/termux.properties new file mode 100644 index 0000000..ad095c3 --- /dev/null +++ b/home/.termux/termux.properties @@ -0,0 +1,3 @@ +extra-keys = [['ESC','/','|','-','~','UP',':'],['TAB','CTRL','ALT','_','LEFT','DOWN','RIGHT']]: +bell-character=vibrate + diff --git a/home/.tidyrc b/home/.tidyrc new file mode 100644 index 0000000..8574810 --- /dev/null +++ b/home/.tidyrc @@ -0,0 +1,30 @@ +indent: auto +indent-spaces: 2 +wrap: 88 +markup: yes +output-xml: no +input-xml: no +show-warnings: yes +numeric-entities: yes +quote-marks: yes +quote-nbsp: yes +quote-ampersand: yes +break-before-br: yes +uppercase-tags: no +uppercase-attributes: no +char-encoding: utf8 +new-inline-tags: cfif, cfelse, math, mroot, + mrow, mi, mn, mo, msqrt, mfrac, msubsup, munderover, + munder, mover, mmultiscripts, msup, msub, mtext, + mprescripts, mtable, mtr, mtd, mth +new-blocklevel-tags: cfoutput, cfquery +new-empty-tags: cfelse +drop-empty-elements: no +vertical-space: yes +sort-attributes: alpha +priority-attributes: id, name +clean: yes +#Enable the followin go not break jinja templates. +#show-body-only: yes +#fix-uri: no +merge-divs: no diff --git a/home/.tmux.conf b/home/.tmux.conf new file mode 100644 index 0000000..73cb096 --- /dev/null +++ b/home/.tmux.conf @@ -0,0 +1,63 @@ +set-option -g update-environment "DISPLAY \ + KRB5CCNAME \ + SSH_ASKPASS \ + SSH_CONNECTION \ + WINDOWID \ + GPG_TTY \ + XAUTHORITY" + +set-environment -gr "SSH_AUTH_SOCK" +# BASIC SETTINGS +# -------------------------------- + +# Disable the default C-b prefix as well +#unbind C-b + +# Switch the default prefix to C-a like in GNU screen +#set-option -g prefix C-a + +# Quick window switching on C-a C-a +#bind-key C-a last-window + +# Handle nested passthrough Of C-a a +#bind-key a send-prefix + +# Use a faster wait time, not waiting for escape sequence +set -s escape-time 1 + +# Use vim directions for moving around +bind h select-pane -L +bind j select-pane -D +bind k select-pane -U +bind l select-pane -R +bind H previous-window +bind L next-window + +# Logical window numbering from 1 to match keyboard +set -g base-index 1 +set-window-option -g pane-base-index 1 + +# Enable mouse: +setw -g mouse on + +set-window-option -g mode-keys vi + + +# Enable UTF8 +#set -g status-utf8 on +#set -g utf8 on + +# Better colours +set -g status-bg white +set -g status-fg black + +# Enable 256 colour mode +set -g default-terminal "screen-256color" + +##ALEX +set -g status-keys vi +set -g visual-bell on + +#Make copy and paste work properly. +bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -i -sel clip > /dev/null" +bind-key p run "xclip -o -sel clip | tmux load-buffer - ; tmux paste-buffer" diff --git a/home/.useful b/home/.useful new file mode 120000 index 0000000..b1c8904 --- /dev/null +++ b/home/.useful @@ -0,0 +1 @@ +../private/home/.useful/ \ No newline at end of file diff --git a/home/.vimrc b/home/.vimrc new file mode 100644 index 0000000..57546f2 --- /dev/null +++ b/home/.vimrc @@ -0,0 +1,9 @@ +if !exists("g:my_environ_dir") + let g:my_environ_dir = expand('~/.alex-environ') +endif + +exe "source " . g:my_environ_dir . "/home/.vimrc.d/base" +exe "source " . g:my_environ_dir . "/home/.vimrc.d/filetypes" + +exe "source " . g:my_environ_dir . "/home/.vimrc.d/plugins" +exe "source " . g:my_environ_dir . "/home/.vimrc.d/dev-environ" diff --git a/home/.vimrc.d/base b/home/.vimrc.d/base new file mode 100644 index 0000000..fb97708 --- /dev/null +++ b/home/.vimrc.d/base @@ -0,0 +1,175 @@ +" Definitions +" --------------------------------------- +let g:my_vim_dir = expand('~/.vim') +let g:my_vimrc = expand('~/.vimrc') + +if !exists("g:my_environ_dir") + let g:my_environ_dir = expand('~/.alex-environ') +endif + +" Remove ALL autocommands to prevent them from being loaded twice. +if has('autocmd') + autocmd! +endif + +" Syntax Highlighting +if has('syntax') + syntax enable + set background=dark +endif + +" OPTIONS +" --------------------------------------- +set nocompatible " The most important VIM option + +scriptencoding utf-8 " Convert all scripts into UTF8 format + +" Typing options: +set smarttab +set tabstop=4 " Set the default tabstops +set shiftwidth=4 " Set the default autoindent +set softtabstop=4 +set expandtab +set hidden +set omnifunc=syntaxcomplete#Complete "Autocompletion + +set autoindent " Sensible indenting +set shiftround " Round indents to a multiple of 'shiftwidth' +set complete-=i " Don't scan includes, since it can be very slow. +set backspace=indent,eol,start " Set for maximum backspace smartness + +" Searching options: +set ignorecase " Ignore case in searches ... (\c\C override) +set smartcase " ... unless there are caps in the search +set incsearch " Perform incremental search as you type search +set hlsearch " Highlight all search matches + +" Highlighting options: +set showmatch " Show the matching bracket +set matchpairs=(:),{:},[:] " List of characters we expect in balanced pairs +set cursorline " Highlights the current line + +" Mouse options: +set mouse=a " Enable the mouse for all modes + +" General options: +set history=1000 " Save more history. +set visualbell " Don't ding all the time + +" Setup line numbers. Relative numbers in normal mode, otherwise normal +" numbers. +set number relativenumber +if has('autocmd') + augroup numbertoggle + autocmd! + autocmd BufEnter,FocusGained,InsertLeave * set relativenumber + autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber + augroup END +endif + +" Open new split panes to right and bottom, which feels more natural +set splitbelow +set splitright + +" BACKUPS, UNDO and SWAP FILES +" --------------------------------------- +" Save your backups to a less annoying place than the current directory. +" If you have .vim-backup in the current directory, it'll use that. +" Otherwise it saves it to ~/.vim/backup or . if all else fails. +if isdirectory(g:my_vim_dir . '/backup') == 0 + execute 'silent !mkdir -p ' . g:my_vim_dir . '/backup >/dev/null 2>&1' +endif +set backupdir-=. +set backupdir+=. +set backupdir-=~/ +execute 'set backupdir^=' . g:my_vim_dir . '/backup/' +set backupdir^=./.vim-backup/ +set backup +" Prevent backups from overwriting each other. The naming is weird, +" since I'm using the 'backupext' variable to append the path. +" So the file '/home/docwhat/.vimrc' becomes '.vimrc%home%docwhat~' +if has('autocmd') + autocmd BufWritePre * nested let &backupext = substitute(expand('%:p:h'), '/', '%', 'g') . '~' +endif + +if has('macunix') + set backupskip+=/private/tmp/* +endif + +" Save your swp files to a less annoying place than the current directory. +" If you have .vim-swap in the current directory, it'll use that. +" Otherwise it saves it to ~/.vim/swap, ~/tmp or . +if isdirectory(g:my_vim_dir . '/swap') == 0 + execute 'silent !mkdir -p ' . g:my_vim_dir . '/swap >/dev/null 2>&1' +endif +set directory=./.vim-swap// +execute 'set directory+=' . g:my_vim_dir . '/swap//' +set directory+=~/tmp// +set directory+=. + +" viminfo stores the the state of your previous editing session +execute 'set viminfo+=n' . g:my_vim_dir . '/viminfo' +set viminfo^=!,h,f0,:100,/100,@100 + +if exists('+undofile') + " undofile - This allows you to use undos after exiting and restarting + " This, like swap and backups, uses .vim-undo first, then ~/.vim/undo + " :help undo-persistence + " This is only present in 7.3+ + if isdirectory(g:my_vim_dir . '/undo') == 0 + execute 'silent !mkdir -p ' . g:my_vim_dir . '/undo >/dev/null 2>&1' + endif + set undodir=./.vim-undo/ + execute 'set undodir+=' . g:my_vim_dir . '/undo/' + set undofile + set undolevels=1000 " maximum number of changes that can be undone + set undoreload=10000 " maximum number lines to save for undo on a buffer reload +endif + +" When editing a file, always jump to the last known cursor position. +" Don't do it when the position is invalid or when inside an event handler +" (happens when dropping a file on gvim). +" Also don't do it when the mark is in the first line, that is the default +" position when opening a file. +if has('autocmd') + autocmd BufReadPost * nested + \ if line("'\"") > 1 && line("'\"") <= line("$") | + \ exe "normal! g`\"" | + \ endif +endif + +" APPEARANCE +" --------------------------------------- +if has('gui_running') + set guifont=Monospace\ 14 +endif + +" Fallback colors +colorscheme peachpuff + +" KEYBOARD BINDINGS +" --------------------------------------- +map [ :NERDTreeToggle +map ] :CtrlP + +""" FIXES FOR GLITCHES ETC. +" --------------------------------------- +""" Fix copy and paste +if exists('##TextYankPost') + augroup OSCYank + autocmd TextYankPost * if v:event.operator is 'y' && v:event.regname is '' | execute 'OSCYankReg "' | endif + augroup END +endif + +""" Fix the terminal background on WSL +if (&term =~ '^xterm' && &t_Co == 256) + set t_ut= | set ttyscroll=1 +endif + +""" MORE tabs. +set tabpagemax=100 + +""" COMMANDS +" --------------------------------------- +" For when you forget to sudo... Really Write the file. +cnoremap w!! w !sudo tee % >/dev/null diff --git a/home/.vimrc.d/coc/coc-settings.json b/home/.vimrc.d/coc/coc-settings.json new file mode 100644 index 0000000..7170a6d --- /dev/null +++ b/home/.vimrc.d/coc/coc-settings.json @@ -0,0 +1,10 @@ +{ + "python.linting.enabled": false, + "rust-client.disableRustup": true, + "javascript.format.enabled": false, + "javascript.validate.enable": false, + "typescript.format.enabled": false, + "typescript.validate.enable": false, + "json.format.enable": false, + "diagnostic.displayByAle": true +} diff --git a/home/.vimrc.d/dev-environ b/home/.vimrc.d/dev-environ new file mode 100644 index 0000000..2a901ff --- /dev/null +++ b/home/.vimrc.d/dev-environ @@ -0,0 +1,44 @@ + +"""Base Settings for ALE +command! ALEDisableFixers let g:ale_fix_on_save=0 +let g:ale_fix_on_save = 1 + +"ALE defaults to all linters turned on, so this turns some off. +let g:ale_linters = { + \ 'python': ['flake8', 'pylint', 'black'], + \ 'php': ['phpcs'], + \ 'spec': ['rpmlint'], + \} + +" Ale defaults to all fixers turned off, so this turns some on. +" Fixing AUTOMATICALLY CHANGES YOUR CODE on save. +let g:ale_fixers = { + \ '*': ['remove_trailing_lines', 'trim_whitespace'], + \ 'python': ['black', 'isort'], + \ 'yaml': ['prettier'], + \ 'go': ['gofmt', 'goimports'], + \ 'php': ['php_cs_fixer'], + \ 'scss': ['prettier'], + \ 'rust': ['rustfmt'], + \ 'javascript' : ['eslint'], + \ 'typescript': ['eslint'], + \ 'vue': ['eslint'], + \ 'json' :['jq'], + \} + +" ALE settings for speficic languages. +"PHP +let g:ale_php_phpcs_standard = 'PSR12' + +"FORTRAN +let g:ale_fortran_gcc_use_free_form = 0 + +"JSON +let g:ale_json_jq_options = '--sort-keys' + +"""Base Settings for COC +let g:coc_config_home = '~/.alex-environ/home/.vimrc.d/coc' +let g:coc_global_extensions = ['coc-python', 'coc-rls', 'coc-tsserver', 'coc-json', 'coc-htmldjango'] +"""Language Specific Options. +"Remeber that COC has it's own settings file too, so most of it's settings are +"there. diff --git a/home/.vimrc.d/filetypes b/home/.vimrc.d/filetypes new file mode 100644 index 0000000..9355594 --- /dev/null +++ b/home/.vimrc.d/filetypes @@ -0,0 +1,48 @@ +"BASICS +" --------------------------------------- +"Settings for specific filetypes that rely on base-vim only (no plugins) +filetype plugin indent on +filetype plugin on + +"LANGUAGE SPECIFIC +" --------------------------------------- +"Apache +au BufNewFile,BufRead /*/httpd/conf.d/* setf apache + +"Django +autocmd BufNewFile,BufRead *.djt set syntax=django +autocmd BufNewFile,BufRead *.html.djt set syntax=htmldjango + +"Python + au BufNewFile,BufRead *.py + \ setlocal tabstop=4 + \ | setlocal softtabstop=4 + \ | setlocal shiftwidth=4 + \ | setlocal expandtab + \ | setlocal autoindent + \ | setlocal fileformat=unix + +"FORTRAN +let fortran_fixed_source = 1 +let fortran_do_enddo=1 +let fortran_indent_less=1 +function SetfortranOptions() + setlocal incsearch + setlocal ignorecase + setlocal smartcase + setlocal smarttab + setlocal expandtab + setlocal tabstop=2 + setlocal shiftwidth=2 +endfunction +autocmd FileType fortran call SetfortranOptions() + +"PHP +" Don't beep on > character +au BufWinEnter *.php set mps-=<:> + +"Latex +let g:tex_flavor='latex' + +"Vim +au BufNewFile,BufRead */.vimrc.d/* set filetype=vim diff --git a/home/.vimrc.d/plugins b/home/.vimrc.d/plugins new file mode 100644 index 0000000..c77fa0d --- /dev/null +++ b/home/.vimrc.d/plugins @@ -0,0 +1,60 @@ +" VUNDLE +" --------------------------------------- +filetype off " Turn off before processing Vundle (required) +let g:ale_disable_lsp = 1 "ALE plays nice with COC. Must be before plugins. + +" PLUGINS +" --------------------------------------- +function! LoadPlugins() + Plug 'scrooloose/nerdtree' " NERDTree for vim file explorer + Plug 'w0rp/ale' " Syntax checking and Fixing + + if exists('##TextYankPost') + Plug 'ojroques/vim-oscyank', { 'branch': 'main' } " Fix the clipboard + endif + + if executable('node') " Coc only works if nodejs is available. + Plug 'neoclide/coc.nvim', {'branch': 'release'} "Autocompetion + endif + + " THEMES + Plug 'altercation/vim-colors-solarized' " Solarized is a pretty colour scheme + Plug 'morhetz/gruvbox' " gruvbox is a good colour scheme on 256 colours + + Plug 'amanning9/django-plus.vim' " Improvements for identifying files in django projects. +endfunction + +" PLUGIN INITIALISATION +" --------------------------------------- +" Only install vundle and bundles if git exists... +if executable('git') && has('autocmd') + " Install Plug and run for the first time + if empty(glob('~/.vim/autoload/plug.vim')) + echomsg 'Running vim for the first time, bootstrapping vim configuration...' + silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + autocmd VimEnter * PlugInstall --sync | source $MYVIMRC + endif +endif + +" Initialise plugins on every vim load +execute 'set rtp+=' . g:my_vim_dir . '/bundle/vundle/' +silent! call plug#begin('~/.vim/plugged') +call LoadPlugins() +call plug#end() + +" THEME CONFIGURATION +" --------------------------------------- +" Use solarized light in GUI, otherwise gruvbox dark +if has('gui_running') + set background=dark + colorscheme solarized + "set guifont=Menlo\ Regular:h12 +else + set background=dark + colorscheme gruvbox +endif + +" Put these back on. +filetype plugin indent on +filetype plugin on diff --git a/home/.vimrc.simple b/home/.vimrc.simple new file mode 100644 index 0000000..b1dbe43 --- /dev/null +++ b/home/.vimrc.simple @@ -0,0 +1,6 @@ +if !exists("g:my_environ_dir") + let g:my_environ_dir = expand('~/.alex-environ') +endif + +exe "source " . g:my_environ_dir . "/home/.vimrc.d/base" +exe "source " . g:my_environ_dir . "/home/.vimrc.d/filetypes" diff --git a/home/scripts/askpass.sh b/home/scripts/askpass.sh new file mode 100755 index 0000000..7312456 --- /dev/null +++ b/home/scripts/askpass.sh @@ -0,0 +1,5 @@ +#!/usr/bin/bash +source $AE_HOME/.bashrc.d/functions.sh +opon +op get item $sudo_pass_uuid --fields password +opoff diff --git a/home/scripts/hassfix.sh b/home/scripts/hassfix.sh new file mode 100755 index 0000000..675c40e --- /dev/null +++ b/home/scripts/hassfix.sh @@ -0,0 +1,3 @@ +#!/usr/bin/bash + +yprint.py $@ | sed -E -e "s/'(\!include.*)'/\1/g" diff --git a/home/scripts/puma b/home/scripts/puma new file mode 120000 index 0000000..0c64524 --- /dev/null +++ b/home/scripts/puma @@ -0,0 +1 @@ +../../private/home/scripts/puma \ No newline at end of file diff --git a/home/scripts/rootpass b/home/scripts/rootpass new file mode 120000 index 0000000..791a188 --- /dev/null +++ b/home/scripts/rootpass @@ -0,0 +1 @@ +../../private/home/scripts/rootpass \ No newline at end of file diff --git a/home/scripts/ssh_agent_setup b/home/scripts/ssh_agent_setup new file mode 100755 index 0000000..df61eb0 --- /dev/null +++ b/home/scripts/ssh_agent_setup @@ -0,0 +1,72 @@ +#!/bin/sh + + +SSH_ENV=$HOME/.ssh/environment.`hostname` + +start_agent () +{ + # If not running interactively, don't do anything else + [[ $- != *i* ]] && return + + if [ `uname -o` = "Cygwin" ] + then + echo "Connecting to ssh-pageant..." + eval $(/usr/bin/ssh-pageant -r -a "/tmp/.ssh-pageant-$USERNAME") + else + ssh-agent > ${SSH_ENV} + chmod 600 ${SSH_ENV} + . ${SSH_ENV} > /dev/null + echo "Created a new ssh-agent $SSH_AGENT_PID" + fi + +} + +load_keys () +{ + if [ "$alex_load_keys" == "1" ] + then + ssh-add + fi +} + +# Source SSH settings, if applicable +# If a ssh auth socket exists at this point, it must be from a forwarded agent. +if [ -n "${SSH_AUTH_SOCK+set}" ] +then + if [ -f "${SSH_ENV}" ] + then + AUTH_SOCK=$SSH_AUTH_SOCK + . ${SSH_ENV} > /dev/null + kill -9 $SSH_AGENT_PID + pkill -9 -u $USER ssh-agent + rm $SSH_ENV + unset SSH_AGENT_PID + unset SSH_ENV + SSH_AUTH_SOCK=$AUTH_SOCK + export SSH_AUTH_SOCK + fi + echo "Connected to forwarded SSH agent ${SSH_AUTH_SOCK}." + echo "The following keys are available:" + ssh-add -l +else + if [ -f "${SSH_ENV}" ] + then + . ${SSH_ENV} > /dev/null + ssh-add -L > /dev/null 2>&1 + case $? in + 0) echo "Connected to existing ssh-agent $SSH_AGENT_PID." + echo "The following keys are available:" + ssh-add -l + ;; + 1) echo "Connected to existing ssh-agent $SSH_AGENT_PID. No keys were found in the agent." + load_keys + ;; + 2) start_agent + load_keys + ;; + esac + else + start_agent + load_keys + fi +fi diff --git a/home/scripts/tmux.sh b/home/scripts/tmux.sh new file mode 100755 index 0000000..c52042b --- /dev/null +++ b/home/scripts/tmux.sh @@ -0,0 +1,42 @@ +#!/usr/bin/bash + +#If tmux dosn't exist, or we're already in tmux, don't so anything +if command -v tmux &> /dev/null && [ -n "$PS1" ] && [[ ! "$TERM" =~ screen ]] && [[ ! "$TERM" =~ tmux ]] && [ -z "$TMUX" ] +then + +# Get all temux sessions, and see if anyone is attached. +sessions=`tmux ls -F "#{session_name}:#{session_attached}"` + + +# Check what sessions exist. +# Pick a disconnected one to connect to. (the last one). +connectto="-1" +for item in ${sessions//\\n/ } +do + name=`echo $item | cut -d":" -f1` + connected=`echo $item | cut -d":" -f2` + if [ $connected -eq "0" ] + then + connectto=$name + fi +done + +#iterm2 wants command mode +tmuxargs="" +if [ `uname -o` = "Darwin" ] +then + tmuxargs="" +fi + +# If we got a session to connect to, connect to it. +# If not, safe to create a new session. +if [ $connectto -eq "-1" ] +then + exec tmux $tmuxargs new +else + exec tmux $tmuxargs attach -t $connectto +fi + +#We created a tmux session, bashrc will run inside it. Stop executing this one. +return +fi diff --git a/home/scripts/yprint.py b/home/scripts/yprint.py new file mode 100755 index 0000000..6a757e0 --- /dev/null +++ b/home/scripts/yprint.py @@ -0,0 +1,23 @@ +#!/usr/bin/python3 + +import sys +import yaml + + +def default_ctor(loader, tag_suffix, node): + return tag_suffix + ' ' + node.value + + +yaml.add_multi_constructor('', default_ctor, Loader=yaml.FullLoader) + +data = sys.stdin.read() + +yobject = yaml.load(data, Loader=yaml.FullLoader) + +tidyyaml = yaml.dump(yobject, + default_flow_style=False, + explicit_start=True, + width=50, + indent=4) + +print(tidyyaml) diff --git a/setup/auth_keys b/setup/auth_keys new file mode 120000 index 0000000..dff418d --- /dev/null +++ b/setup/auth_keys @@ -0,0 +1 @@ +../private/setup/auth_keys/ \ No newline at end of file diff --git a/setup/git_hooks/auth_keys.sh b/setup/git_hooks/auth_keys.sh new file mode 120000 index 0000000..cf04982 --- /dev/null +++ b/setup/git_hooks/auth_keys.sh @@ -0,0 +1 @@ +../../private/setup/auth_keys.sh \ No newline at end of file diff --git a/setup/git_hooks/fix-ssh.sh b/setup/git_hooks/fix-ssh.sh new file mode 100755 index 0000000..5a8083e --- /dev/null +++ b/setup/git_hooks/fix-ssh.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +chmod 600 ~/.alex-environ/home/.ssh/config +chmod 600 ~/.alex-environ/home/.ssh/config.d/config_clever +chmod 600 ~/.alex-environ/home/.ssh/config.d/config_xforward diff --git a/setup/linters b/setup/linters new file mode 100644 index 0000000..78bcbc7 --- /dev/null +++ b/setup/linters @@ -0,0 +1,10 @@ +from fedora packages +python3-flake8 +python3-pylint +tidy +csslint +yamllinkt +vint + +from npm -g +fixjson diff --git a/setup/setupscript.sh b/setup/setupscript.sh new file mode 100755 index 0000000..89dee6b --- /dev/null +++ b/setup/setupscript.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +#set template path +environ_dir=~/.alex-environ +template_dir=${environ_dir}/setup/templates +environ_home=${environ_dir}/home + +########## Move git repo to standard location +cd ~ +mv alex-environ .alex-environ + +########## Create .config if it doesn't exist +mkdir -p ~/.config + +########## Copy templates into local files then edit them with vim. +cd ~/.alex-environ/setup/templates + +# VIMrc (first as we are gonna use vim to edit everything else) +cat ${template_dir}/vimrc_template >> ~/.vimrc +vim ~/.vimrc + +# Bash_profile +cat ${template_dir}/bash_profile_local_template >> ~/.bash_profile +vim ~/.bash_profile + +# Bashrc +cat ${template_dir}/bashrc_local_template >> ~/.bashrc +vim ~/.bashrc + +# Bash logout +cat ${template_dir}/bash_logout_template >> ~/.bash_logout +vim ~/.bash_logout + +# Git config +cat ${template_dir}/gitconfig_template >> ~/.gitconfig +vim ~/.gitconfig + +# TMUX config +cat ${template_dir}/tmux.conf_template >> ~/.tmux.conf +vim ~/.tmux.conf + +# SSH config +cat ${template_dir}/sshconfig_template >> ~/.ssh/config +vim ~/.ssh/config +chmod 600 ~/.ssh/config + +########## Setup the git hooks which run when this repo is pulled +cp ${template_dir}/post-merge ~/.alex-environ/.git/hooks + +########## Create authorized_keys and run the auth keys script +touch ~/.ssh/authorized_keys +~/.alex-environ/setup/git_hooks/auth_keys.sh + +########## Link files which do not support includes +##### In .config +#flake8 +ln -s ${environ_home}/.config/flake8 ~/.config/flake8 +#pylint +ln -s ${environ_home}/.config/pylintrc ~/.config/pylintrc +#matplotlib +ln -s ${environ_home}/.config/matplotlib ~/.config/matplotlib +#yamllint +ln -s ${environ_home}/.config/yamllint ~/.config/yamllint +#mypy +ln -s ${environ_home}/.config/mypy ~/.config/mypy + +##### In home dir +ln -s ${environ_home}/.fonts ~/.fonts diff --git a/setup/templates/bash_logout_template b/setup/templates/bash_logout_template new file mode 100644 index 0000000..5f5bd7d --- /dev/null +++ b/setup/templates/bash_logout_template @@ -0,0 +1,5 @@ +# ~/.bash_logout + +if [ -f ~/.alex-environ/home/.bash_logout ]; then + . ~/.alex-environ/home/.bash_logout +fi diff --git a/setup/templates/bash_profile_local_template b/setup/templates/bash_profile_local_template new file mode 100644 index 0000000..e8a7ad8 --- /dev/null +++ b/setup/templates/bash_profile_local_template @@ -0,0 +1,24 @@ +# .bash_profile + +# Get the aliases and functions +if [ -f ~/.bashrc ]; then + . ~/.bashrc +fi + +#Add to PATH HERE +#PATH=$PATH: + +export alex_load_keys=0 + +#source alex's global bash_profile +if [ -f ~/.alex-environ/home/.bash_profile ]; then + . ~/.alex-environ/home/.bash_profile +fi + +#set my prompt. Comment this for local propt color +if [ -f ~/.alex-environ/home/.bash_profile.d/prompt ]; then + . ~/.alex-environ/home/.bash_profile.d/prompt +fi + +#Start Tmux, if we want it +# . ~/.alex-environ/home/scripts/tmux.sh diff --git a/setup/templates/bashrc_local_template b/setup/templates/bashrc_local_template new file mode 100644 index 0000000..2bf3d4e --- /dev/null +++ b/setup/templates/bashrc_local_template @@ -0,0 +1,20 @@ +# .bashrc +# .bashrc template + +#SET PATH IN .BASH_PROFILE + +# Source global definitions +if [ -f /etc/bashrc ]; then + . /etc/bashrc +fi + +# GLOBAL bashrc +if [ -f ~/.alex-environ/home/.bashrc ]; then +. ~/.alex-environ/home/.bashrc +fi + +#if [ -f ~/.alex-environ/home/.bashrc.d/work ]; then +#. ~/.alex-environ/home/.bashrc.d/work +#fi + +# Local User specific aliases and functions diff --git a/setup/templates/gitconfig_template b/setup/templates/gitconfig_template new file mode 100644 index 0000000..0fda19d --- /dev/null +++ b/setup/templates/gitconfig_template @@ -0,0 +1,5 @@ +[user] + email = mail@alex-m.co.uk + name = Alex Manning +[include] + path = .alex-environ/home/.gitconfig diff --git a/setup/templates/post-merge b/setup/templates/post-merge new file mode 100755 index 0000000..5eec801 --- /dev/null +++ b/setup/templates/post-merge @@ -0,0 +1,3 @@ +#!/bin/bash +~/.alex-environ/setup/git_hooks/fix-ssh.sh +~/.alex-environ/setup/git_hooks/auth_keys.sh diff --git a/setup/templates/sshconfig_template b/setup/templates/sshconfig_template new file mode 100644 index 0000000..05a9c70 --- /dev/null +++ b/setup/templates/sshconfig_template @@ -0,0 +1,2 @@ +Include ~/.alex-environ/home/.ssh/config +Include ~/.alex-environ/home/.ssh/config.d/config_clever diff --git a/setup/templates/tmux.conf_template b/setup/templates/tmux.conf_template new file mode 100644 index 0000000..8cbd11f --- /dev/null +++ b/setup/templates/tmux.conf_template @@ -0,0 +1 @@ +source-file ~/.alex-environ/home/.tmux.conf diff --git a/setup/templates/vimrc_template b/setup/templates/vimrc_template new file mode 100644 index 0000000..5db851e --- /dev/null +++ b/setup/templates/vimrc_template @@ -0,0 +1 @@ +source ~/.alex-environ/home/.vimrc diff --git a/tmp/.gitinclude b/tmp/.gitinclude new file mode 100644 index 0000000..e69de29