-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpenser-a.sh
More file actions
executable file
·74 lines (66 loc) · 2.15 KB
/
penser-a.sh
File metadata and controls
executable file
·74 lines (66 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Par Julien MOREAU aka PixEye
edit=edit # Argument qui lance l'éditeur
display=what # Argument qui affiche la liste
notfic=~/.psbt # Nom du fichier qui contient les notes
nom_cmde=`basename $0` # Nom de la commande
usage="Usage: $nom_cmde [edit|<mots> ...]" # Message d'aide
usage=$usage"\n\tVous permet d'ajouter une ligne à votre pense-bête."
usage=$usage"\n\tSi le seul parametre est \"$edit\","
usage=$usage"\n\t édite le fichier: $notfic"
# Pour prendre des notes (une ligne par exécution)
tmp="/tmp/$nom_cmde.tmp"
if test `uname -s` != "HP-UX" ; then e="-e" ; fi
if test -z "$EDITOR" ; then EDITOR=vi ; fi
if [ $# -eq 0 ] ; then
if test ! -s "$notfic" ; then
echo "$nom_cmde: Votre fichier pense-bête est vide." 1>&2
echo $e $usage 1>&2 ; exit 1
else
echo $e "*** Utiliser l'argument \"$edit\" pour éditer \c"
echo $e "directement le fichier avec $EDITOR.\n"
fi
else
if [ `echo $1|cut -c-2` = "-h" ] ; then
echo $e $usage 1>&2 ; exit 2
elif [ "$1" = $edit ] ; then
$EDITOR "$notfic"
elif [ "$1" = "$display" -o "$1" = "quoi" -o "$1" = "koa" ] ; then
echo
else
echo $e "\t. $*" > "$tmp"
cat "$notfic" >> "$tmp" # Pour l'ajout en tête
mv "$tmp" "$notfic"
fi
clear
xhost 2> /dev/null|grep ^"access control enabled" > /dev/null
if [ $? -eq 0 ] ; then echo $e "x- \c" ; else echo $e "x+ \c" ; fi
mesg > /dev/null
if [ $? -eq 1 ] ; then echo $e "m- \c" ; else echo $e "m+ \c" ; fi
#if mail $e ; then echo $e "You have mail. \c" ; fi
fi
if test ! -s "$notfic" ; then
echo "$nom_cmde: Votre fichier pense-bête est vide." 1>&2
echo $e $usage 1>&2 ; exit 1
else
echo $e "Contenu de votre pense-bête :\n"
#export LINES=`resize|grep LINE|sed 's|[^0-9]||g'`
export LINES
if test -z "$LINES" ; then LINES=24 ; fi
if test -n "$LINES" ; then
nbl=`wc -l < "$notfic"`
nbl2display=`expr $LINES - 5`
if [ "$nbl" -gt "$nbl2display" ] ; then
head -n "$nbl2display" "$notfic"
#echo "(head -n $nbl2display $notfic)"
echo $e "\t\t\t..."
else
cat "$notfic"
fi
else
cat "$notfic"
fi
#echo "LINES=$LINES, nbl2display=$nbl2display, nbl=$nbl"
fi
exit 0 # Sortie sans erreur
# vim: tabstop=8 shiftwidth=8 noexpandtab