summary refs log tree commit diff stats
path: root/tests/cpp/amodule.nim
Commit message (Expand)AuthorAgeFilesLines
* fixes #9222 (#9224)cooldome2018-10-091-0/+10
>28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
#set -x
#alias local=typeset
# don't activate for bash or zsh for now
#[ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ] && return

# If not running interactively, don't do anything
#[ -z "$PS1" ] && return
setopt PROMPT_SUBST

if [ "$$" = "1" ]; then
	echo "Whoah?! I'm init!"
	PREFIX="${PREFIX}[I AM INIT] "
fi

SHNAME=$(. whatshell)

SERIAL=''
if [ -r /proc/self/fd/0 ]; then
	TTY_FULL=$(LANG=C readlink /proc/self/fd/0 2>/dev/null || LANG=C realpath /proc/self/fd/0)
else
	TTY_FULL=$(tty)
fi
TTY=${TTY_FULL#/dev/}
export TTY

case "$TTY_FULL" in
	/dev/ttyS*)
		SERIAL=1
		;;
esac


prompt_helper(){
	# display return code in prompt 
	RET=$?
	if [ $RET = 0 ]; then
		RET=
	else
		RET="[$RET]"
	fi

	local pwd
	case $PWD in
	$HOME*)
		pwd="~${PWD#"$HOME"}"
		;;
	*)
		pwd=$PWD
		;;
	esac
	PWEXT=$pwd

	if [ "$CHECKWINSIZE" ]; then
		set -- $(stty size)
		export LINES=$1
		export COLUMNS=$2		
		#echo "$COLUMNS x $LINES"
	fi
	# workaround for updating terminal size when connecting via serial port
	if [ "$SERIAL" ]; then
		local rows
		local cols
		IFS='[;' read -rp $'\033\033[r\033[999;999H\033[6n\033' -d R -s _ rows cols
		if [ "x$rows $cols" != "x$LINES $COLUMNS" ]; then
			stty rows "$rows" cols "$cols"
		fi
	fi

	if [ "$RPROMPT" ]; then
		#local RP1=${RPROMPT@P}
		#local RP2=${RP1//$'\1'+([!$'\2'])$'\2'/}
		local RP1=$RPROMPT
		local RP2=$RPROMPT
		printf "\0337\033[$((COLUMNS - ${#RP2} + 1 ))G%s\0338" "$RP1" > /dev/tty
	fi
#printf "%s" "$PS1" > /dev/tty

	case "$TERM" in
	(xterm*|rxvt*|vt102|screen*)
		pretty_title "$SHNAME";;
	esac
	return 0
}

set_title(){
	#set -x
        printf "\033]0;%s\a" "${*-}" > /dev/tty
}

pretty_title(){
        local extra=${*-}

        local user=
        if [ "$EUID" -ne 0 ]; then
                user="/${USER}"
        fi
        local host=${DISPLAYHOST-$HOSTNAME}
        local tty="(${COLUMNS}x${LINES} ${TTY})"
        #local pwd=${PWD/$HOME/~}

        if [ -n "$extra" ]; then
                extra=" <$extra>"
        fi

        set_title "$host$user:$extra $PWEXT $tty"
}

blackterm(){
        setfg ffffff
        setbg 000000
        tango
        color dark
}
whiteterm(){
        setfg 000000
        setbg ffffff
        tango
        color light
}
grayterm(){
        setfg bebebe
        setbg 333333
        tango
        color dark
}

setcolors(){
        local i=0
        #printf "\033]4;"
        #for arg; do
        #        printf "%s;#%s" "$i" "$arg"
        #        ((++i))
        #done
	#printf "\a"
        #i=0
        for arg; do
                printf "\033]P%x%s\a" "$i" "$arg"
        	printf "\033]4;%s;#%s\a" "$i" "$arg"
                ((++i))
        done
}

tango(){
        setcolors \
                1e1e1e \
                cc0000 \
                4e9a06 \
                c4a000 \
                3464a4 \
                75507b \
                0b939b \
                d3d7cf \
                555753 \
                ef2929 \
                8ae234 \
                fce94f \
                729fcf \
                ad7fa8 \
                00f5e9 \
                eeeeec
}

setopt(){
        printf "\033]%s;#%s\a" "$1" "$2"
}

setfg(){
	setopt 10 "$1"
	setopt 12 "$1"
	setopt 13 "$1"
	setopt 17 "$1"
        printf "\033]Pg%s\a" "$1"
}

setbg(){
	setopt 11 "$1"
	setopt 14 "$1"
        printf "\033]Ph%s\a" "$1"
}

preexec(){
#set -x
        if [ "$SHOW_COMMAND" ]; then
		local command
		if [ -n "$BASH_COMMAND" ]; then
			command=$BASH_COMMAND
		elif [ -n "$ZSH_VERSION" ]; then
			command=$1
		else
			eval 'command=${.sh.command}'
			#echo XXX $command
		fi
#echo "FOOOBAR $command"
                #local short=${command:0:50}
                local short
                eval 'short=${command:0:50}'
                pretty_title "$short"
                case "$TERM" in screen)
                        printf "\033%.20s\033\\" "$short"
                esac
        fi
}

LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.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:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:';
export LS_COLORS

set -o emacs
#alias grep='grep --color=auto'
#alias grpe='grep --color=auto'
#alias gerp='grep --color=auto'
#alias ls='ls -F --color=auto'
alias ls='ls -F'
alias sc='du -schx -- *|sort -h'
#alias vi='vim "+sy on" "+colo elflord" "+se nu" "+se ai" "+se si" "+se hls"'
alias vi='vim "+sy on" "+colo elflord" "+se nu ai si hls ru"'

: "${EUID:=$(id -u)}"
CSI=$(printf '\033[')
if [ -n "$YASH_VERSION$BASH_VERSION" ]; then
	START="\["
	SC="$START$CSI"
	END="\]"
	EC="m$END"
else
	SC="$CSI"
	EC="m"
	START=
	END=
fi

RED="${SC}1;31$EC"
GREEN="${SC}1;32$EC"
BLUE="${SC}1;34$EC"
DBLUE="${SC}34$EC"
STD="${SC}$EC"

BGCOLOR="48;5;52"
BGCOLOR=""
if [ -n "$BGCOLOR" ]; then
	STD="${SC}0;$BGCOLOR$EC"
	PREFIX="$STD$PREFIX"
	printf '%s' "$STD${CSI}J"
fi

: "${HOSTNAME:=$(hostname)}"
DISPLAYHOST=${HOSTNAME%%.*}

CHECKWINSIZE=1
SHOW_COMMAND=1

if [ "$EUID" = 0 ]; then
        UCOLOR=$RED
	SYMBOL='#'
else
        UCOLOR=$GREEN
	SYMBOL='$'
fi

case "$TERM" in
dumb)
        PS1="${DISPLAYHOST}.\w$SYMBOL "
        ;;
*)
	RPROMPT=
	RPROMPT="$(basename "$SHELL")"
	PS1="$PREFIX${UCOLOR}${DISPLAYHOST}${STD}.${BLUE}$START\$(prompt_helper;printf %s \"\$PWEXT\$RET\")$END${STD}$SYMBOL "
	#PS1="$PREFIX${UCOLOR}${DISPLAYHOST}${STD}.${BLUE}\$(prompt_helper)\$PWEXT\$RET${STD}$SYMBOL "
        ;;
esac


echo "siprof"

# LASTARG: save and restore the value of $_
#if [ -z "$ZSH_VERSION" ]; then
#	trap 'LASTARG="$_";$PREEXEC_COMMAND;: $LASTARG' DEBUG
#fi
#PREEXEC_COMMAND="preexec"