Warren Block wrote:
On Fri, 10 Feb 2012, Gonzalo Nemmi wrote:
On Thu, Feb 9, 2012 at 9:52 PM, Eitan Adler <li...@eitanadler.com> 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
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"