Sponsored Content
Full Discussion: Campimeter.sh for macOS
Top Forums Programming Campimeter.sh for macOS Post 303043482 by wisecracker on Wednesday 29th of January 2020 12:39:09 PM
Old 01-29-2020
Campimeter.sh for macOS

Hi Neo...
Quote:
I tend to have a low attention span, so when I get a proof-of-concept like this up and running (and prove it works), even if the final results are not "polished", I then want to "call it good enough" and quickly move on to the next project.
This is me too except for the attention span. As soon as I find a solution to something I let others better it.
And as for doing something different I have done some bizarre stuff on here... <wink> /Me awaits the mickey take... ;oD
OT: Here is a small snippet for a terminal window you might like under OSX 10.14.6 on this MBP, solved and going into the Campimeter code.
Code:
#!/bin/bash
# Campimeter.sh

clear

# Set terminal to full screen and default sizes.
set_size()
{
    osascript << "FULL_SCREEN"
        tell application "Terminal" to activate
        tell application "System Events" to keystroke "f" using { command down, control down }
        delay 3
FULL_SCREEN
}

initialise()
{
    clear
    printf "%b" "\033[0;30;47m"
    clear
    SIZE=( $( stty size ) )
    VERT_CENTRE=$(( ${SIZE[0]} / 2 ))
    HORIZ_CENTRE=$(( ${SIZE[1]} / 2 ))
    printf "%b" "\033[${VERT_CENTRE};${HORIZ_CENTRE}f\033[0;30;42m  \033[0;30;47m\033[1;1f"
}

set_size

initialise

printf "\033[33;33f\033[1;31;47m*\033[0;30;47m\033[1;1f"

sleep 3

set_size

Enjoy...

Last edited by wisecracker; 01-30-2020 at 03:29 AM.. Reason: Corrected the "shebang", 30-01-2020. Thanks Ravinder...
These 2 Users Gave Thanks to wisecracker For This Post:
 

6 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

UNIX on MacOS X

I am interested in knowing if anyone out there has been using the BSD UNIX that underlies MacOS X. Is this an "industrial strength" version of UNIX? Can I run X-Windows on such a machine? How about TeXing, pythoning, PERLing or using other useful UNIX goodies near and dear to my shrunken... (1 Reply)
Discussion started by: ncmathsadist
1 Replies

2. UNIX for Dummies Questions & Answers

Vuze/MacOS X: Too many open files

1) How can I stop Vuze from reporting the following error: "Too many open files" ? 2) What directory do I need to be in to effectively utilize this command: sudo bash -c 'ulimit -n 8192; sudo -u username ./azureus' ? 3) Is this the maximum number of files that I can allot to Vuze on OS X... (1 Reply)
Discussion started by: JFraser1
1 Replies

3. UNIX for Beginners Questions & Answers

Memory leak with awk on MacOs

Dear all, I use awk quite a bit for data wrangling ... today I find weird behavior that I cannot wrap my head around. if I execute the following command (simplified to illustrate the behavior ... nothing to do with the real command) bash-3.2$ awk... (3 Replies)
Discussion started by: comm|getline
3 Replies

4. UNIX for Beginners Questions & Answers

Macos is the UNIX?

why,just beacuse that its the bottom layer uses a small amount of bsd code? In my opinion, macos and Unix are completely different. The directories are long directory structures. For example, /application, /system, /user, /volumes, etc. are completely different from the traditional /bin/ /sbin... (5 Replies)
Discussion started by: malaizhichun
5 Replies

5. OS X (Apple)

MacOS 10.15 (Catalina) switches from bash to zsh

Interestingly Apple has decided to switch the default shell for new users from bash to zsh in MacOS Catalina (10.15) Use zsh as the default shell on your Mac - Apple Support Another interesting fact is that Catalina also comes with /bin/dash (5 Replies)
Discussion started by: Scrutinizer
5 Replies

6. OS X (Apple)

My original Python Campimeter code, originall for OSX 10.7.5.

Hi all... This was the original code I created to expand a terminal on the fly using Python 2.6.x to the now 3.8.0 without modification under OSX 10.7.5. I had no idea at the time that the MBP terminal could be full screen until here:... (0 Replies)
Discussion started by: wisecracker
0 Replies
SPLITVT(1)						      NONESSENTIAL UTILITIES							SPLITVT(1)

NAME
splitvt - run two shells in a split window SYNOPSIS
splitvt [options] [shell] OPTIONS
-upper command Runs 'command' in the upper window -lower command Runs 'command' in the lower window -bottom Stats with the focus in the bottom window -s numlines Sets 'numlines' to the number of lines in the top window. This number will be modified if the screen isn't big enough to handle the full size. -t title Sets an xterm title bar to 'title' -login Runs the programs under each window as though they were login shells. This is useful to have csh source it's .login file, bash source .profile, etc. -nologin Ovverrides any "set login on" statement in the startup file. -rcfile file Loads 'file' as the startup file instead of ~/.splitvtrc. -norc Suppresses loading your ~/.splitvtrc -f Allow setting the height of either the top or the bottom window to less than 3 lines. -v Print out the version number of splitvt DESCRIPTION
This program splits the screen into two windows, one above the other, and runs a shell in each one. The default shell is taken from the SHELL environment variable, or /bin/csh if SHELL isn't in the environment, but another shell can be specified on the command line. The top window is the default current window, but you can change to the other by pressing ^W. Pressing ^V will quote the next character to the current shell. Pressing ^O will put splitvt into command mode. These special characters (command mode, switch window, and quote next character) can be modified from within the .splitvtrc file. When in command mode, splitvt will read one non-numeric character, perform the requested command, and then revert to normal operations. Numeric characters are interpreted as a parameter for the specified command. The currently supported commands are: 'h' Print a help window for the escape commands '-' Shrink the current window '+' Expand the current window 'c' Select a block of text in the current window 'p' Paste the selected text to the current window 'k' Kill the current window (hangup signal) 'x' Lock the screen, after prompting for password 'r' Repaint the screen (clearing screen garbage) 'q' Quickly quit splitvt, killing the running shells More functions may be added in the future. If the -s command line option is used, the upper window will be bound to the user defined number of lines even if the screen is resized. Otherwise, the screen will be split into two equal parts based on the new size of the screen. The environment variable SPLITVT is set in the shells forked by splitvt. In the shell running in the upper window, this variable is set to the value "upper", while the shell running in the lower window has this variable set to the value "lower". This is useful in shell scripts to provide different behavior depending on which window the script is running in. An example of this is shown in the file "menu" in the examples directory in the splitvt distribution. When splitvt starts up, it looks in your home directory for a file named .splitvtrc You can set a number of parameters from within this file, including all of the special characters, the default number of lines in the upper window, whether or not to run the commands as login shells, and even default commands to run in each window. Here is an example of a .splitvtrc file: # This is an example .splitvtrc file. set command_char ^O set quote_char ^V set switch_char ^W set upper_lines 12 run -upper /bin/sh run -lower top set login on # This next line would override the above run statements #run /bin/tcsh If programs like vi are doing strange things to the window while in splitvt, you probably need to set the LINES environment variable to a correct value, or set the terminal's window sizing correctly. This should be done automatically, but may need to be corrected. If you are running under an xterm window, the title bar will probably be updated to show the version of splitvt that you are running. Under a true xterm window, you can also switch which half of the window you are typing into by clicking the mouse in the half of the window in which you want to type. You can also drag and drop the separator bar by pressing down on the mouse button over the separator bar, hold- ing it down, moving the mouse to where you want the bar to end up, and then releasing the button. splitvt will attempt to erase the current utmp entry, and replace it with entries for the two windows. This allows you to use programs such as 'talk' within the splitvt windows. If you do not have write permission to the /var/run/utmp file, you will not be able to modify the utmp entries. splitvt can be made set-uid root. splitvt will reset its user id to that of the person running it, just before it exec()'s the shell under the window. The splitvt process remains with root permissions, and will change ownership of the pseudo terminals to that of the person running splitvt, and then reset it to root when the window is closed. SPLITVT IS NOT GUARANTEED TO BE A SAFE SET-UID PROGRAM! I have done all I know to keep splitvt a safely usable set-uid program, but I do not know everything, and am not responsible for any secu- rity weaknesses splitvt might posess. BUGS
When used with a certain public domain version of ksh, you have to manually kill -9 on the shell processes after you quit splitvt. This has to do with a bug in that version of ksh (Version 06/03/86a and possibly others). If splitvt is compiled with xterm support, when run under an xterm, the cut and paste feature is semi-disabled. The title bar may also be reset to the string "xterm" after splitvt quits. See the comments at the top of splitvt.c for how to disable xterm support. Ansi colors are not repainted on screen refresh. CAVEATS
There may be conflicts between splitvt's characters and other programs. You can either change splitvt's default characters with command line options, or you can type Ctrl-V (the quote character) within splitvt, and the next character typed will be sent to the current window, no matter what it is. splitvt can only be used by terminals using vt100 emulation, due to the use of specific vt100 escape codes. (vt300, xterm, Linux console, etc, emulation also works) When running in an xterm, if you press the escape key, you will have to type another character in order for the escape to be seen by the running program. AUTHOR
Sam Lantinga slouken@cs.ucdavis.edu SPLITVT
1/5/95 SPLITVT(1)
All times are GMT -4. The time now is 07:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy