tcsh
.
.fonts
in your $HOME directory.fc-cache -fv
.fc-list
. For example, I would do fc-list -f "%{family}\n" | sort -u | grep 'Inconsolata'
1 to check if my downloaded Inconsolata fonts got into the font cache.~/.Xdefaults
xrdb -merge $HOME/.Xdefaults
to your shell init script. My shell init script is ~/.alias
.*customization: -color
XTerm*termName: xterm-256color
xterm*saveLines: 500
xterm*scrollBar: false
xterm*cursorColor: white
xterm*pointerColor: white
xterm*Foreground: white
xterm*Background: black
xterm*c132: true
xterm*loginShell: false
! Fonts
! XTerm*faceName: DejaVu Sans Mono:size=11
! XTerm*faceName: Inconsolata:size=11
! XTerm*faceName: Inconsolata\\-dz:style=dz:size=11
XTerm*faceName: Inconsolata\\-g:style=g:size=11
Done! Now source your shell init script and launch xterm
.
Note: In order to use font names with hyphens in them, I had to escape them by using \\
. So for the Inconsolata-g
font, I have XTerm*faceName: Inconsolata\\-g:style=g:size=11
.
It might be helpful to add the below aliases to your tcsh init script for quick font refresh and check, using fontsrefresh; fontsavail | grep 'Inconsolata'
.
alias fontsavail 'fc-list -f "%{family}\n" | sort -u'
alias fontsrefresh 'fc-cache -fv'
echo "Hi\nHow\nHi\nAre\nHi\nYou?\nAre"
, you will get this in your terminal:
Hi
How
Hi
Are
Hi
You?
Are
Here’s how we can remove the duplicate lines using awk
..
echo "Hi\nHow\nHi\nAre\nHi\nYou?\nAre" | awk '\!x[$0]++'
The above will give this output:
Hi
How
Are
You?
The escape char \
is required for !
in tcsh.
This is how that awk snippet works:
Hi
, x[$0]=x[Hi]=0
. So !x[Hi]
will be True
and it will be printed out.x[Hi]
becomes 1 because of the ++
increment operator.$0==Hi
, as x[Hi]==1
, !x[Hi]
will be False
and so $0 won’t be printed out.This is the most common way of my sed usage:
echo [SOMETHING] | sed 's/old/NEW/g'
Based on that, I have this tcsh alias1 to get timestamps that I use to append to quick tar backups.
alias gettimestamp 'date | tr " :" "__" | sed '"'"'s/_[0-9]*_EDT.*//g'"'"''
Learn about sed from [here][s1].
Note how single quotes are escaped inside single-quoted alias definitions in tcsh. [s1]: http://www.grymoire.com/Unix/Sed.html ↩︎
Here’s how I solve that problem.
If you have an alias alias test 'echo \!:1*'
and if you run test abc def
, you will get the output abc def
.
!:1*
prints out all the arguments starting from argument 1 till the
last where even argument 1 is optional. If that argument doesn’t
exist, the variable will be assigned a null value.
But tcsh will not complain about it – the *
after !:1
is
the beauty. On the other hand, if I have an alias alias test2 'echo \!:1'
, and if I run test
– with zero arguments – tcsh will give
an error.
So extending that, I have the below alias defined to grab an argument of any index.
alias opt_args 'set arg1 = `echo \!:1* | awk '"'"'{ print $1 }'"'"'`; \\
echo -n "Arg num 1 = $arg1 "; \\
set arg2 = `echo \!:2* | awk '"'"'{ print $1 }'"'"'`; \\
echo -n "Arg num 2 = $arg2 "; \\
set arg3 = `echo \!:3* | awk '"'"'{ print $1 }'"'"'`; \\
echo -n "Arg num 3 = $arg3 "; \\
echo ""; \\
'
You can test this alias by running these commands:
opt_args abc
opt_args abc def
opt_args abc def ghi
opt_args abc def ghi jkl
]]>I wanted to set an alias for a find
command containing the -regex
switch. For simplicity I will use this example:
find . -type f -regex '.*\.txt$'
This expression simply gives a list of all *.txt files in any directory under the current path.
The above command works fine when running in the terminal, but when
saving that to a tcsh
alias, that $
needs to be escaped:
alias findtxt "find . -type f -regex '.*txt'\"\$"''"
A simple
$
has to be written as'\"\$"'
!!!
Granted that I will usually get the same result if I did alias findtxt "find . -type f -regex '.*txt'"
instead. But this turned out
to be an interesting exercise on how to escape a $
.