• Slidy
  • Toolbending::Ligne de commande, Commande de ligne

    De Ustensile
    Aller à : navigation, rechercher

    Young Americans who leave their great big homogeneous country and visit some other part of the world typically go through several stages of culture shock: first, dumb wide-eyed astonishment. Then a tentative engagement with the new country’s manners, cuisine, public transit systems and toilets, leading to a brief period of fatuous confidence that they are instant experts on the new country. As the visit wears on, homesickness begins to set in, and the traveler begins to appreciate, for the first time, how much he or she took for granted at home. At the same time it begins to seem obvious that many of one’s own cultures and traditions are essentially arbitrary, and could have been different; driving on the right side of the road, for example. When the traveler returns home and takes stock of the experience, he or she may have learned a good deal more about America than about the country they went to visit. [1]

    Comment les outils sont rendus visibles

    Apple Ipad: "Nous pensons que la technologie est optimale lorsqu'elle est invisible, lorsque vous n'êtes conscients que de ce que faites et non du dispositif avec lequel vous le faites."

    Comment on rend un outil invisible? Comment cela se fait?

    Si nous voulons utiliser un outil mais en détournant son usage principal, nous devons comprendre ses aspect culturels. Mais comment le faire si ils sont devenues invisible?

    Stephenson: Aliénation comme outil. Habits, expectations, fit, "intuition".

    Mode Texte

    "Ligne de commande" = La communication entre l'utilisateur et l'ordinateur en mode texte.

    Télétypes dans les années 1960; Douglas Engelbart: Graphical User Interface.

    Engelbart.jpg

    The command line is, by itself, just as much an user interface abstracted from the operating system kernel as the GUI. While the "desktop" look and feel of the GUI emulates real life objects of an analog office environment, the Unix, BSD, Linux/GNU and Mac OS X command line emulates teletype machines that served as the user terminals to the first Unix computers in the early 1970s. This legacy lives on in the terminology of the "virtual terminal" and the device file /dev/tty (for "teletype") on Unix-compatible operating systems. Both graphical and command line computing are therefore media; mediating layers in the cybernetic feedback loop between humans and machines, and proofs of McLuhan's truism that the contents of a new medium is always an old medium.[2]

    Teletype.jpg

    Unix tool philosophy

    "Ne faire qu'une seule chose, et la faire bien". man man, pipe, connectors.

    Unix, officiellement UNIX (parfois écrit « Unix », avec des petites capitales), est un système d'exploitation multitâche et multi-utilisateur créé en 1969. Il est fondé sur une approche par laquelle il offre de nombreux petits outils, chacun doté d'une mission spécifique[3].

    1. La concision est merveilleuse.
    2. Écrivez des programmes qui font une seule chose mais qui le font bien.
    3. Concevez un prototype dès que possible. ("pire c'est mieux")
    4. Préférez la portabilité à l'efficacité.
    5. Stockez les données en ASCII.
    6. Utilisez le levier du logiciel à votre avantage.
    7. Utilisez les scripts shell pour améliorer l'effet de levier et la portabilité.
    8. Évitez les interfaces utilisateur captives.
    9. Faites de chaque programme un filtre.
    info coreutils
    

    Expérimentation de base

    cd
    ls
    mkdir
    >
    ../
    

    Commandes de base (pdf)

    Shortcuts

    Utilise tab, ↑ et ↓

    match one arbitrary character with ?

    ls h?llo.txt
    

    ... will list hello.txt, hallo.txt, h9llo.txt etc.

    match any number of arbitrary characters with *

    cat * > all_files_in_one.txt
    cp * /mnt/usbstick
    cp *.html /mnt/usbstick
    ls *.htm*
    

    Ouvrir un fichier sous un programme spécifique sous Mac OSX

    open -a programme nomdufichier
    open -a firefox 1.jpg
    

    Connectors

    feed command2 with the output of command 1 (to enter the character on Mac OS : Alt + Maj + L):

    command1 | command2
    

    save the result of command in a file named output.txt:

    info coreutils > coreutils.txt
    

    execute one command after the other:

    ls ; date
    

    Do two actions with two programs one after the other, but only if the first one is successful:

    mkdir pictures && cp *.jpg pictures
    

    logical "OR": execute next command only if the previous completed with an error message:

    cat gkrlmpfst.txt || echo this file doesn't exist
    

    Tips & Tricks[4]

    Introduce yourself:

    echo I am `whoami`. It is `date` and we are in the directory `pwd` | espeak
    

    or, on OSX:

    echo I am `whoami`. It is `date` and we are in the directory `pwd` | say
    

    What time is it in Sao Paulo at 18:47 in Brussels?

    TZ=America/Sao_Paulo date "+%F %R (%Z%z)" -d 'TZ="Europe/Brussels" 18:47'
    

    Get the alphabetical list of all words in a text:

    cat text.txt | tr " " "\n" | sort | uniq
    

    Make a cadavre exquis of several texts:

    cat a.txt b.txt c.txt > abc.txt
    

    Make a top 5 of your biggest files:

    ls -l -S *.* | head -5
    

    Make a parody of Wikipedia:

    wget -k -O /tmp/o.html https://en.wikipedia.org/wiki/BNP_Paribas && sed -i "s/\w\+ing/schtroumpfing/gi" /tmp/o.html && firefox /tmp/o.html
    

    Make a poem out of any text:

    cat text.txt | strings | shuf | head
    

    Rank all unix commands by popularity:

    history | awk '{print $2}' | sort | uniq -c | sort -rn | head
    

    Please Computer | Make Me Design

    "Please Computer | Make Me Design" est à l'origine le package source de la "Screen Party" du 22 avril 2010 à l'ESAPV Mons, proposé par Open Source Publishing. "Please Computer | Make Me Design" est une initiation à la ligne de commande par le biais du design graphique, de l'écriture et de la poésie concrète. Ce pack collecte textes et didacticiels de références, ainsi qu'une collection de scripts. Il a été créé pour faciliter la collaboration, mais aussi pour pouvoir être augmenter par la suite, par exemple dans le cadre d'autres ateliers."

    https://github.com/latsami/PleaseMakeMeDesign/blob/lgm-fr/LISEZMOI

    Please Computer Make Me Design, Version Toolbending préparé par Max

    Part II

    Dealcards.jpg

    Mise en place

    Commencez avec une collection de > 15 images !

    Télécharger des images

    Licenses: Public domain, Creative Commons CC BY-SA, Licence Art Libre ...: http://freedomdefined.org/Definition/Fr

    • la liberté d'utiliser l'image et de jouir des avantages à en user
    • la liberté d'étudier l'image et de mettre en œuvre le savoir que l'on en tire
    • la liberté de faire et de redistribuer des copies, de l'ensemble ou d'une partie de l'information ou de l'expression
    • la liberté de modifier ou d'améliorer, et de distribuer les images dérivées

    Liens :

    Installation : ImageMagick

    ImageMagick http://fs.pad.constantvzw.org/public_pad/ImageMagickOSX

    From Windows x64 Version 6.8.9

    From Linux or Virtual Machine :

    sudo apt-get install imagemagick
    

    Virtual Machine: https://www.virtualbox.org/

    Copier + installer le fichier .dvi (clé USB Femke)

    username/password: adminuser/adminuser
    Root Password: adminuser
    

    Créez vos ingrédients à partir de (presque) zéro

    Slicing images:

    Découpe d'une image en bandes ou en dalles. Lorsqu'il n'est pas donné une position spécifique à découper, L'option crop se répète autant de fois que possible, "cookie-cutter-style", produisant une série d'images.

    mkdir cuts
    
    convert original/image.jpg -crop 64x64 cuts/tile%d.png
    convert original/image.jpg -crop 64x cuts/strip%d.png
    convert original/image.jpg -crop x64 cuts/bar%d.png
    

    (%d = special syntax for autonumbering)

    Exploser un fichier pdf en multiple images:

    mkdir pages
    
    convert original/lissitsky.pdf pages/page-%d.jpg
    

    Animation

    convert cuts/*.* animation_cuts.gif
    

    Fastreader.gif

    Transformer tout les pdfs dans un dossier en animation gif

    convert *.pdf -threshold 50% -type bilevel -resize 50% pages/page-%d.jpg ; convert pages/*.jpg fastreader.gif
    

    Mixing versions

    mkdir transform transform_A transform_B
    

    Créez plusieurs versions d'un collection d'images avec convert

    Transform, skew, blur, colorize ... http://www.imagemagick.org/Usage/

    convert original/*.* -define modulate:colorspace=LCHuv -modulate 100,100,25 transform_A/%d_A.jpg
    convert original/*.* -bordercolor white -border 10 transform_B/%d_A.jpg
    
    cp transform_A/*.jpg transform & cp transform_B/*.jpg transform
    
    convert transform/*.* animation_transform.gif
    

    Ou ... copiez/collez les commandes dans un script et enregistrez sous transform.sh:

    <syntaxhighlight lang="bash">

    1. !/bin/bash
    1. first conversion

    convert original/*.* -define modulate:colorspace=LCHuv -modulate 100,100,25 transform_A/%d_A.jpg

    1. second conversion

    convert original/*.* -bordercolor white -border 10 transform_B/%d_A.jpg

    1. copy files

    cp transform_A/*.jpg transform & cp transform_B/*.jpg transform

    1. combine into animation

    convert transform/*.* animation_transform.gif

    </syntaxhighlight>

    Dans le terminal:

    bash transform.sh
    

    Boucles

    Colouredlena.gif

    Variable

    Dans le terminal:

    mkdir boucle
    

    Prepare un image en RGB (image.jpg, image.png) dans le dossier 'original'. Dans un éditeur de texte, Copier/coller le script ci-dessous et enregistrez sous boucle.sh:

    <syntaxhighlight lang="bash">

    1. !/bin/bash

    for i in 0 25 50 75 100 125 150 175;

    do

       convert original/lena.jpg -define modulate:colorspace=LCHuv -modulate 100,100,$i boucle/$i.jpg
    

    done

    convert boucle/*.* animation_boucle.gif </syntaxhighlight>

    Dans le terminal:

    bash boucle.sh
    

    Increment

    Test on a single folder of 1-2 images. Create the target folder 'increment' first.

    <syntaxhighlight lang="bash">

    1. !/bin/bash

    for IMAGE in $( ls original ) ; do COUNTER=0 while [ $COUNTER -lt 360 ] ; do COUNTER=$[ $COUNTER+20 ] convert original/$IMAGE -rotate $COUNTER increment/$IMAGE"_"$COUNTER.jpg done done convert rotate/*.* animation_increment.gif

    </syntaxhighlight>

    Another example:

    Increment charcoal.gif

    <syntaxhighlight lang="bash">

    1. !/bin/bash

    for IMAGE in $( ls original ) ; do COUNTER=0 while [ $COUNTER -lt 5 ] ; do COUNTER=$[ $COUNTER+1 ] convert original/$IMAGE -charcoal $COUNTER increment/$IMAGE"_"$COUNTER.jpg done done

    convert increment/*.* animation_increment.gif </syntaxhighlight>

    Essayer avec plusieurs dossiers, types d'images ; essayer à varier et combiner les éléments.

    Les scripts

    Publish here!

    Logiciels, installation

    username/password: 
    adminuser/adminuser
    Root Password: 
    adminuser(sudo)
    

    Pour en savoir plus

    Practice

    Theory

    1. Neal Stephenson. In the beginning was the commandline. (Cryptonomicon, 1999)
    2. Florian Cramer, (echo echo) echo (echo): Command Line Poetics, http://reader.lgru.net/texts/echo-echo-echo-echo-command-line-poetics/
    3. https://fr.wikipedia.org/wiki/Unix
    4. http://relearn.be/r/practical::10-ultimate-tips-to-no-longer-be-ashamed-to-open-the-terminal-in-public