]> gitweb.pimeys.fr Git - config-20-100.git/blob - .zsh/rc/local/30_debian_tools
Ajout du zshrc, même s'il manque encore de commentaires etc.
[config-20-100.git] / .zsh / rc / local / 30_debian_tools
1 #!/bin/zsh
2
3 # debian stuff
4 if [[ -r /etc/debian_version ]] ; then
5 # debian upgrade
6 #f3# Execute \kbd{apt-get update \&\& }\\&\quad \kbd{apt-get dist-upgrade}
7 upgrade() {
8 emulate -L zsh
9 if [[ -z $1 ]] ; then
10 $SUDO apt-get update
11 $SUDO apt-get -u upgrade
12 else
13 ssh $1 $SUDO apt-get update
14 # ask before the upgrade
15 local dummy
16 ssh $1 $SUDO apt-get --no-act upgrade
17 echo -n 'Process the upgrade?'
18 read -q dummy
19 if [[ $dummy == "y" ]] ; then
20 ssh $1 $SUDO apt-get -u upgrade --yes
21 fi
22 fi
23 }
24 fi
25
26 # TODO: Is it supported to use pager settings like this?
27 # PAGER='less -Mr' - If so, the use of $PAGER here needs fixing
28 # with respect to wordsplitting. (ie. ${=PAGER})
29 if check_com -c $PAGER ; then
30 #f1# View Debian's changelog of a given package
31 dchange() {
32 emulate -L zsh
33 if [[ -r /usr/share/doc/$1/changelog.Debian.gz ]] ; then
34 zcat /usr/share/doc/$1/changelog.Debian.gz | $PAGER
35 elif [[ -r /usr/share/doc/$1/changelog.gz ]] ; then
36 zcat /usr/share/doc/$1/changelog.gz | $PAGER
37 else
38 if check_com -c aptitude ; then
39 echo "No changelog for package $1 found, using aptitude to retrieve it."
40 aptitude changelog $1
41 else
42 echo "No changelog for package $1 found, sorry."
43 return 1
44 fi
45 fi
46 }
47 _dchange() { _files -W /usr/share/doc -/ }
48 compdef _dchange dchange
49
50 #f1# View Debian's NEWS of a given package
51 dnews() {
52 emulate -L zsh
53 if [[ -r /usr/share/doc/$1/NEWS.Debian.gz ]] ; then
54 zcat /usr/share/doc/$1/NEWS.Debian.gz | $PAGER
55 elif [[ -r /usr/share/doc/$1/NEWS.gz ]] ; then
56 zcat /usr/share/doc/$1/NEWS.gz | $PAGER
57 else
58 echo "No NEWS file for package $1 found, sorry."
59 return 1
60 fi
61 }
62 _dnews() { _files -W /usr/share/doc -/ }
63 compdef _dnews dnews
64
65 #f1# View upstream's changelog of a given package
66 uchange() {
67 emulate -L zsh
68 if [[ -r /usr/share/doc/$1/changelog.gz ]] ; then
69 zcat /usr/share/doc/$1/changelog.gz | $PAGER
70 else
71 echo "No changelog for package $1 found, sorry."
72 return 1
73 fi
74 }
75 _uchange() { _files -W /usr/share/doc -/ }
76 compdef _uchange uchange
77 fi
78