From owner-freebsd-current@FreeBSD.ORG Fri Feb 10 11:25:11 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BD962106566B for ; Fri, 10 Feb 2012 11:25:11 +0000 (UTC) (envelope-from 000.fbsd@quip.cz) Received: from elsa.codelab.cz (elsa.codelab.cz [94.124.105.4]) by mx1.freebsd.org (Postfix) with ESMTP id 032AD8FC1A for ; Fri, 10 Feb 2012 11:25:10 +0000 (UTC) Received: from elsa.codelab.cz (localhost [127.0.0.1]) by elsa.codelab.cz (Postfix) with ESMTP id 36A5728435; Fri, 10 Feb 2012 12:06:03 +0100 (CET) Received: from [192.168.1.2] (ip-86-49-61-235.net.upcbroadband.cz [86.49.61.235]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by elsa.codelab.cz (Postfix) with ESMTPSA id 4485D2842E; Fri, 10 Feb 2012 12:06:01 +0100 (CET) Message-ID: <4F34FA17.7080000@quip.cz> Date: Fri, 10 Feb 2012 12:05:59 +0100 From: Miroslav Lachman <000.fbsd@quip.cz> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9.1.19) Gecko/20110420 Lightning/1.0b1 SeaMonkey/2.0.14 MIME-Version: 1.0 To: Warren Block References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Colin Percival , Chris Rees , Eitan Adler , freebsd-current Current , "Wojciech A. Koszek" , Gonzalo Nemmi Subject: Re: Enhancing the user experience with tcsh X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Feb 2012 11:25:11 -0000 Warren Block wrote: > On Fri, 10 Feb 2012, Gonzalo Nemmi wrote: > >> On Thu, Feb 9, 2012 at 9:52 PM, Eitan Adler wrote: >>> In conf/160689 (http://www.freebsd.org/cgi/query-pr.cgi?pr=160689) > >>> there has been some discussion about changing the default cshrc file. >> In the same line that Wojciech on the PR ".cshrc should be updated for >> modern hardware" I always set this ones on /usr/share/skel/dot.cshrc >> >> bindkey "\e[1~" beginning-of-line #make Home key work; >> bindkey "\e[2~" overwrite-mode #make Ins key work; >> bindkey "\e[3~" delete-char #make Delete key work; >> bindkey "\e[4~" end-of-line #make End key work; >> >> Besides that I add an "if [ -d $HOME/bin ]" and add it to $PATH if it >> exists, but that has nothing to do with ".cshrc should be updated for >> modern hardware" ... it jsut comes in really handy. > > The question becomes "how much is too much?" For example, ever since a > thread in the forums showed examples of csh/tcsh autocompletion, I've > thought the default .cshrc should be stuffed with them. Not for typing > reduction so much as self-documenting commands like > > complete chown 'p/1/u/' > complete man 'C/*/c/' > complete service 'n/*/`service -l`/' > > 'service' autocompletes with a list of services--it helps the user by > showing valid choices. Same with 'chown', it gives a list of users. > > Then there's this, which probably isn't quite right but has been useful > to me (thanks to forum members for help with it): > > complete make 'n@*@`make -pn | sed -n -E "/^[#_.\/[:blank:]]+/d; /=/d; > s/[[:blank:]]*:.*//gp;"`@' > > That completes with all lower-case make targets for the current directory. > > Package operations are easier when the package names autocomplete: > > complete pkg_delete 'c/-/(i v D n p d f G x X r)/' \ > 'n@*@`ls /var/db/pkg`@' > complete pkg_info 'c/-/(a b v p q Q c d D f g i I j k K r R m L s o G O > x X e E l t V P)/' \ > 'n@*@`\ls -1 /var/db/pkg | sed s%/var/db/pkg/%%`@' > > There's lots more that could be done. Are they appropriate for a stock > .cshrc? Maybe now is the time. I am +1 for better support of command autocompletion for FreeBSD specific commands. For example, I have this for services complete service 'c/-/(e l r v)/' 'p/1/`service -l`/' 'n/*/(start stop reload restart status rcvar onestart onestop)/' Something for kernel modules complete kldload 'n@*@`ls -1 /boot/modules/ /boot/kernel/ | awk -F/ \$NF\ \~\ \".ko\"\ \{sub\(\/\.ko\/,\"\",\$NF\)\;print\ \$NF\}`@' complete kldunload 'n@*@`kldstat | awk \{sub\(\/\.ko\/,\"\",\$NF\)\;print\ \$NF\} | grep -v Name`@' complete kill 'c/-/S/' 'c/%/j/' 'n/*/`ps -ax | awk '"'"'{print $1}'"'"'`/' complete killall 'c/-/S/' 'c/%/j/' 'n/*/`ps -axc | awk '"'"'{print $5}'"'"'`/' Or for portmaster alias _PKGS_PkGs_PoRtS_ 'awk -F\| \{sub\(\"\/usr\/ports\/\"\,\"\"\,\$2\)\;print\ \$2\} /usr/ports/INDEX-`uname -r | cut -d . -f 1` && pkg_info -E \*' complete portmaster 'c/--/(always-fetch check-depends check-port-dbdir clean-distfiles \ clean-packages delete-build-only delete-packages force-config help \ index index-first index-only list-origins local-packagedir no-confirm \ no-index-fetch no-term-title packages packages-build packages-if-newer \ packages-local packages-only show-work update-if-newer version)/' \ 'c/-/(a b B C d D e f F g G h H i l L m n o p r R s t u v w x)/' \ 'n@*@`_PKGS_PkGs_PoRtS_`@' The alias is there because same list of ports and packages are used for other pkg / ports commands (portupgrade, pkg_info, pkg_delete, pkg_tree, portell etc...) I have collected completion for about 50 commands like: vim, where, which, dd, find, man, limit, kill, bzip2, camcontrol, ifconfig, postfix, postmap, mount, su, sed, sysctl, make etc.. Come of them are rough and need some tweaks. I would like to share them with others, if there are interrest to include it in stock FreeBSD base. And if we are talking about better completion and history support, what about following? set history=10000 set histdup=prev set savehist=(10000 merge) set autolist=ambiguous set autocorrect set autoexpand set complete set correct=cmd set color set colorcat set filec At last - if you are using screen or tmux and what properly saved and merged history from all screens after logout, you need to add history -S to the ~.logout file. Otherwise I have saved history only from last screen window. Miroslav Lachman