Skip to content

Tip #11: 7 im Pfad ersetzen

Wer kennt nicht das Problem, wenn man ein deutsches Tastaturlayout nutzt. Da gibt man den Pfad /usr/share7foo ein und, schwupps, schon hat sich eine 7 in die Angabe verirrt. Es wäre schön, wenn die Shell diese 7 zu einem Slash korrigieren würde. Auf der Mailingliste zsh-users wurde dazu folgende Lösung präsentiert:

function _7slash {                                                              
   local noseven=${words[CURRENT]//7/\/}                                        
   if [[ $words[CURRENT] != $noseven ]]                                         
   then                                                                         
     compadd -U -X ‘Correct 7 to /’ -f $noseven                                 
   fi                                                                           
}

Das Ganze wird mit zur Completion hinzugefügt und kann sofort genutzt werden. Die Funktion ersetzt dann jede 7 zu einem Slash. Eventuell wäre es sinnvoll, da noch etwas mehr Logik reinzustecken und so offensichtliche Fehlersetzungen auszuschließen.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
BBCode format allowed
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Form options
cronjob