Warning: there may be occasional oddness due to css and blog edits. **KNOWN ISSUE: possible hidden text**

Tuesday, April 28, 2026

Shell config overhaul

I ran into a problem that gui elements including fonts were once more extra small and unusable.  I knew that I had some environment variables set in my ~/.fvwm/config file and some in my ~/.cshrc file.  What I discovered were some mistakes and a pile of junk in various files that was no longer needed or were duplications.  I decided it was time for a shell config overhaul.

The various environment variables which are meant to modify how QT or QT-based applications render were set in multiple places, multiple files.  In order to be certain that everything works correctly and as intended, I need to have one place for these adjustments and others when needed.  Then I won't be wondering why later after an edit to one location fails to have the effect because its still different in another place that might be loaded later or conditionally somehow.

The .cshrc files can be chained or live-appended with one line, to source it which essentially means to read it into memory.  If you modify your .cshrc file and are already logged-in or have a terminal already opened, you can cause your changes to be applied by source .cshrc, and such a line can be placed in a file as well.

FVWM has its own configuration file, but if I separate useful portions of the .cshrc file into its own file, I can both chain load it with source from one .cshrc file to another, as well as append it with a particular line in my ~/.fvwm/config file.  This will mean that all those things will be used in multiple places or for more than one purpose, but only one copy to edit.  The only difference is that an xterm opened via FVWM might need FVWM itself to be refreshed (reloaded) for its config file to adopt the changes affecting an xterm or shell aliases or more.

Taking my own advice from a previous post, sample configs can change so I sought out the appropriate file, /usr/share/skel/dot.cshrc which turns out to be rather small but this is the one that is automatically copied for any new user with csh or tcsh shells.  I looked at other sample files, one which is very interesting /usr/share/examples/csh/dot.cshrc because it is not precisely ready-to-use but filled with ideas that one could include in their ~/.cshrc file.  The actual official /etc/csh.cshrc has only one line, a comment.

I am going to copy the /usr/share/skel/dot.cshrc as my ~/.cshrc file, then take the useful parts of .cshrc-local and .cshrc-personal files for a fresh .cshrc-local, and all the piles of notes into a new file maybe named .shell-notes or .cshrc-notes or something.  This has me thinking that maybe it would make sense to force myself into individual single-purpose files.  Each file could become large but would also make it simple to find what has been done, or potential for re-use in even more things.  I was not initially planning to modify the default .cshrc file I copied, but I think it would be best if I do instead of duplicating for overrides.  It is a small file, I'll just comment out or add a revised line as needed.

Three of the four files, starting with ~/.cshrc taken from /usr/share/skel/dot.cshrc with modifications.

#
# .cshrc - csh resource script, read at beginning of execution by each shell
#
# see also csh(1), environ(7).
# more examples available at /usr/share/examples/csh/
#

#alias h		history 25
#alias j		jobs -l
#alias la	ls -aF
#alias lf	ls -FA
#alias ll	ls -lAF

# These are normally set through /etc/login.conf.   You may override them here
# if wanted.
set path = (/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin /usr/local/libexec/ccache $HOME/bin $HOME/scripts)
# A righteous umask
umask 22

setenv	EDITOR	vi
setenv	PAGER	less

if ($?prompt) then
	# An interactive shell -- set some stuff up
	set prompt = "%{\033[31m%}${USER}%{\033[0m%}@%{\033[32m%}%m%{\033[0m%} %{\033[35m%}[%~]%{\033[0m%} %# "
	#set prompt = "%N@%m:%~ %# "
	set promptchars = "%#"

	set filec
	set history = 1000
	set savehist = (1000 merge)
	set autolist = ambiguous
	# Use history to aid expansion
	set autoexpand
	set autorehash
	set mail = (/var/mail/$USER)
	if ( $?tcsh ) then
		bindkey "^W" backward-delete-word
		bindkey -k up history-search-backward
		bindkey -k down history-search-forward
	endif

endif

source /home/tigersharke/.cshrc-env
source /home/tigersharke/.cshrc-alias

The new .cshrc-envfile filled with setenv statements, now alphabetized for future convenience.

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# set assignments go in .cshrc
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
setenv AUTOLOGOUT 30
setenv BLOCKSIZE K
setenv CCACHE_DIR /var/cache/ccache
setenv CCACHE_PATH /usr/bin:/usr/local/bin
setenv CCACHE_LOGFILE /var/log/ccache.log
setenv CLICOLOR true
setenv CRYPTOGRAPHY_OPENSSL_NO_LEGACY true
setenv EDITOR vi
setenv IRCNICK Tigersharke
setenv IRCNAME thatoneguy
setenv IRCSERVER irc.libera.chat
setenv LANG en_US.UTF-8
setenv LANGUAGE en_US.UTF-8
setenv LC_ALL en_US.UTF-8
setenv LC_CTYPE POSIX
setenv LSCOLORS Exfxcxdxbxegedabagacad
setenv PAGER more
setenv QT_AUTO_SCREEN_SCALE_FACTOR 1
setenv QT_ENABLE_HIGHDPI_SCALING 1
setenv QT_QPA_PLATFORM xcb
setenv QT_QPA_PLATFORMTHEME qt6ct

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# pkg install misc/qt5ct or misc/qt6ct:
#  QT_QPA_PLATFORMTHEME qt6ct
# Boolean 0/1:
#  QT_AUTO_SCREEN_SCALE_FACTOR 1
#  QT_ENABLE_HIGHDPI_SCALING 1
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# QT_SCREEN_SCALE_FACTORS
# Sets a list of screen scale factors.  The list can be in one of two formats;
# either a semicolon-separated list of screen scale factors ("1;1.5;2"), or
# a semicolon-separated list of screen=factor entries ("screenA=1;screenB=1.5;
# screenC=2").  Setting this environment variable is not recommended since it
# prevents Qt from using system DPI values.
#
#When stuck with vesa:
#setenv QT_SCALE_FACTOR .25
#setenv QT_SCREEN_SCALE_FACTORS .25
#
#When stuck with scfb:
#setenv QT_SCALE_FACTOR .35
#setenv QT_SCREEN_SCALE_FACTORS .35
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

These are the aliases that remain, in its own .cshrc-alias file. Some aliases are necessary for camelcase or executable name mystery and others are for convenience.  Mostly organized alphabetical by alias name which is how alias would list them, but with a few reminders at the bottom I don't remember for porting things.  I can use tabs to space things for easier readability in vi but not from the alias output.

alias 2gs			mame apple2gs -sl7 "cffa2" -hard1 "software/my_appleIIgs-hdd.chd" -hard2 "software/my_IIgs-hdd-120mb.chd"
alias fixnet 			/etc/rc.d/netif restart ign0
alias fixtime 			ntpdate -b 0.freebsd.pool.ntp.org
alias freedroidrpg 		freedroidRPG
alias less			less --mouse
alias today			date "+%m/%d/%Y"
alias neovim			nvim
alias neovim-qt 		nvim-qt
alias notepadnext 		NotepadNext
alias veloren 			veloren-voxygen
alias ircii 			irc
alias ircII 			irc
alias myworldip 		lynx -dump checkip.dyndns.org
alias nice  			/usr/bin/nice
alias pkeg-distclean		'poudriere distclean -a'
alias portlint  		'echo;echo;\portlint'
alias quitx 			'killall -HUP Xorg'
alias recert			make -C  /usr/ports/security/ca_root_nss reinstall clean
alias rekernconf  		'ln -s /root/kernconf/ICHIGO /usr/src/sys/amd64/conf/ICHIGO ; ln -s /root/kernconf/RACK /usr/src/sys/amd64/conf/RACK'
alias sorta 			sort -d -u
alias tnt			'poudriere jail -u -v stable/15 -a amd64 -j 15amd64 -b -m src=/usr/src'
alias virtoss 			'virtual_oss -Q 0 -C 2 -c 2 -r 48000 -b 16 -s 1024 -P /dev/dsp6 -R /dev/null -w vdsp.wav -l dsp'
alias zfs-df 			'zfs list -o space'

unalias h
unalias j
unalias la
unalias lf
unalias ll

alias cmake-opts  		"cmake -L | awk '{if(f)print} /-- Cache values/{f=1}'"
alias autotools-opts  	'./autogen.sh && ./configure --help=recursive'
alias autotools-too 	'autoreconf && ./configure --help=recursive'

The idea that I could insert the .cshrc-env file into my fvwm3 config worked except that I had a few little mistakes in the file.  I believe that because FVWM is kind of in its own shell when started, it doesn't know $PATH set in the .cshrc file, so revising this in the .cshrc-env file may cause xterms to break.  Another mistake I made was how I fixed the first error by adding it to the .cshrc file.  Either my syntax was wrong or I cannot revise the path variable on a line later in the file, whatever the reason, I just revised the set path variable line to add more to it.  I did make a syntax error with doing this also, and eventually cured everything so that all things worked without errors or error messages.  I knew for certain that I had an error when my background image wasn't loading and things in the fvwm buttons were absent.  Another day I might spend looking through the cool things I could add from the /usr/share/examples/csh/dot.cshrc file but I'm not going to rush that so I can put it in this blog post.

If I hadn't explored the sample files for .cshrc then I would never have discovered a compilation of cool stuff is already on my system to peruse.  Defaults may be nice, they're functional, but there are plenty of ways to change things on your system to make it fit your needs better.  You may not even believe there is any need to do so right now, but explore and find out for yourself.  It may be that some of the shell tricks mentioned in this Larvitz blog post are in that file.  Many things in Linux are adjusted by environment variables and since the majority of what we may use on FreeBSD is from Linux development, we should familiarize ourselves with what can be done.  I still have plenty to organize on my system but now my .cshrc file (files actually) are easier to maintain and considerably cleaner.

No comments:

Frequently viewed this week