# tcsh alias substitutions



## freethread (Aug 21, 2011)

I found a program that use precmd alias so I moved to postcmd and making this chage I decided to enhance the command in the alias. Before the command was

```
alias precmd rehash
```
now it is

```
alias postcmd 'rehash ; printf "\033]2;\!# \007"'
```
it not always works, the most of the times tcsh print

```
printf: illegal format character Y
```
I have some aliases that make use of substitution and they works fine. Is there something different in substitution with precmd and postcmd respect to normal aliases?


----------



## wblock@ (Aug 21, 2011)

Seems to work if the second semicolon is escaped.

```
alias postcmd 'rehash ; printf "\033]2\;\!# \007"'
```


----------



## freethread (Aug 21, 2011)

yes, it works for more commands. I have a common .cshrc for all users, it's not big but some lines give 'Missing ].' and 'printf: No match.' at login (after the postcmd alias). And a file '\007' in the home.
I can live without it, but...


----------



## freethread (Aug 21, 2011)

It's a double/single quote matter both in the alias and in the printf. This works for me for most commands

```
alias postcmd "rehash ; printf -- '\033]2\;%s\007' '\!#'"
```
this one more less

```
alias postcmd 'rehash ; printf -- "\033]2\;%s\007" "\!#"'
```
It depends on the double/single quotes in the command. The 1st form works almost always except if the command contains single quotes. Executing this command

```
ff /usr/local '*wmiirc*'
```
give 'printf: No match' and don't set title. Executing this other it works (with the 1st form)

```
ff /usr/local "*wmiirc*"
```
ok, I'll think it over, another day. At the moment the 1st form is good.


----------

