[Fish] Fix tangling, add some abbreviations, reorganize them

This commit fixes some file tangling that was broken due to some
`:tangle' headers that were left empty.

The environment variable `$VISUAL' is added an is an equivalent of
`$EDITOR'

Abbreviations are reorganized in a more intuitive way.

The displayed uptime was broken, this commit fixes it.
This commit is contained in:
Lucien Cartier-Tilet 2020-08-28 15:39:39 +02:00
parent 78aa7cb9fc
commit 802384a98c
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -89,7 +89,7 @@
set -l ruler (string repeat -n $ruler_length "=") set -l ruler (string repeat -n $ruler_length "=")
set -l osname (cat /etc/os-release | grep -i pretty_name | sed 's/.*"\(.*\)".*/\1/') set -l osname (cat /etc/os-release | grep -i pretty_name | sed 's/.*"\(.*\)".*/\1/')
set -l uptime (uptime | sed 's/up \(.*\)/\1/') set -l uptime (uptime -p | sed 's/up //')
set -l root (df -Ph | grep -E "/\$") set -l root (df -Ph | grep -E "/\$")
set -l root_p (echo $root | awk '{print $5}' | tr -d '%') set -l root_p (echo $root | awk '{print $5}' | tr -d '%')
@ -155,9 +155,11 @@
:END: :END:
Now, lets declare our editor of choice, EmacsClient; not Emacs itself since Now, lets declare our editor of choice, EmacsClient; not Emacs itself since
it will most often be just quick edits, nothing too heavy, if it is called it will most often be just quick edits, nothing too heavy, if it is called
from the =EDITOR= variable (from Git, for example). from the ~EDITOR~ variable (from Git, for example), or from the ~VISUAL~
variable.
#+BEGIN_SRC fish #+BEGIN_SRC fish
set -gx EDITOR emacsclient -c set -gx EDITOR emacsclient -c
set -gx VISUAL emacsclient -c
#+END_SRC #+END_SRC
We also need to set the path to the Dart SDK. We also need to set the path to the Dart SDK.
@ -344,30 +346,11 @@
<<generate-abbr(table=abbr-cmake)>> <<generate-abbr(table=abbr-cmake)>>
#+END_SRC #+END_SRC
*** Compilation
:PROPERTIES:
:CUSTOM_ID: Abbreviations-Development-Compilation-dd066050
:END:
By default, I set =clang=, =clang++=, =gcc= and =g++= to the latest
standard and with the =-Wall= flag activated.
#+NAME: abbr-comp
| abbreviation | command |
|--------------+----------------------|
| clang | clang -Wall |
| clang++ | clang++ -Wall |
| g++ | g++ -Wall -std=c++20 |
| gcc | gcc -Wall -std=c18 |
Here is the corresponding fish configuration:
#+BEGIN_SRC fish :tangle
<<generate-abbr(table=abbr-comp)>>
#+END_SRC
*** Docker *** Docker
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: Abbreviations-Development-Docker-2d0a1288 :CUSTOM_ID: Abbreviations-Development-Docker-2d0a1288
:END: :END:
And of course, when it comes to Docker Compose, I dont have time to write And of course, when it comes to Docker Compose, I don't have time to write
the full command, so I use these instead. the full command, so I use these instead.
#+NAME: abbr-docker #+NAME: abbr-docker
| abbreviation | command | | abbreviation | command |
@ -388,50 +371,17 @@
<<generate-abbr(table=abbr-docker)>> <<generate-abbr(table=abbr-docker)>>
#+END_SRC #+END_SRC
*** Git
:PROPERTIES:
:CUSTOM_ID: Abbreviations-Development-Git-5e5055c1
:END:
And lets face it: we all at one point just wanted to commit our code
without thinking about the message, to just get over with it. Dont worry,
I got you covered.
#+NAME: abbr-git
| abbreviation | command |
|--------------+-----------------------------------------------------|
| randcommit | git commit -m (curl -s whatthecommit.com/index.txt) |
Here is the corresponding fish configuration:
#+BEGIN_SRC fish :tangle
<<generate-abbr(table=abbr-git)>>
#+END_SRC
*** Prolog
:PROPERTIES:
:CUSTOM_ID: Abbreviations-Development-Prolog-72c9d2ef
:END:
When I launch =swipl=, I prefer to have my terminal cleaned before and
after it runs, I find it more clean.
#+NAME: abbr-prolog
| abbreviation | command |
|--------------+----------------------------|
| swipl | clear && swipl -q && clear |
Here is the corresponding fish configuration:
#+BEGIN_SRC fish
<<generate-abbr(table=abbr-prolog)>>
#+END_SRC
*** Text editors *** Text editors
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: Abbreviations-Development-Text_editors-5a23df47 :CUSTOM_ID: Abbreviations-Development-Text_editors-5a23df47
:END: :END:
I greatly prefer to use Emacsclient as my main text editor; Emacs has I greatly prefer to use Emacsclient as my main text editor; Emacs has
basically all I need. So, its only normal I have an abbreviation to launch basically all I need. So, it's only normal I have an abbreviation to launch
a new instance of it. However, in a graphical environment, this will launch a new instance of it. However, in a graphical environment, this will launch
a new graphical window of Emacs. To launch a terminal instance, Ill use a new graphical window of Emacs. To launch a terminal instance, I'll use
=enw= (=nw= stands for the option “nowindow” =-nw= of Emacs). I also wish to ~enw~ (~nw~ stands for the option “nowindow” ~-nw~ of Emacs). I also wish to
completely stop using other text editors, such as =vi=, =vim=, =nano= and completely stop using other text editors, such as ~vi~, ~vim~, ~nano~ and
=ed=, so lets all add their command as an abbreviation for Emacs. ~ed~, so let's all add their command as an abbreviation for Emacs.
#+NAME: abbr-text-ed #+NAME: abbr-text-ed
| abbreviation | command | | abbreviation | command |
@ -448,15 +398,51 @@
<<generate-abbr(table=abbr-text-ed)>> <<generate-abbr(table=abbr-text-ed)>>
#+END_SRC #+END_SRC
*** Compilation
:PROPERTIES:
:CUSTOM_ID: Abbreviations-Development-Compilation-dd066050
:END:
By default, I set ~clang~, ~clang++~, ~gcc~ and ~g++~ to the latest
standard and with the ~-Wall~ flag activated.
#+NAME: abbr-comp
| abbreviation | command |
|--------------+----------------------|
| clang | clang -Wall |
| clang++ | clang++ -Wall |
| g++ | g++ -Wall -std=c++20 |
| gcc | gcc -Wall -std=c18 |
Here is the corresponding fish configuration:
#+BEGIN_SRC fish
<<generate-abbr(table=abbr-comp)>>
#+END_SRC
*** Git
:PROPERTIES:
:CUSTOM_ID: Abbreviations-Development-Git-5e5055c1
:END:
And let's face it: we all at one point just wanted to commit our code
without thinking about the message, to just get over with it. Don't worry,
I got you covered.
#+NAME: abbr-git
| abbreviation | command |
|--------------+-----------------------------------------------------|
| randcommit | git commit -m (curl -s whatthecommit.com/index.txt) |
Here is the corresponding fish configuration:
#+BEGIN_SRC fish
<<generate-abbr(table=abbr-git)>>
#+END_SRC
** LaTeX ** LaTeX
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: Abbreviations-LaTeX-76865eb9 :CUSTOM_ID: Abbreviations-LaTeX-76865eb9
:END: :END:
Yes, although I use org-mode, I still have some use for LaTeX, especially Yes, although I use org-mode, I still have some use for LaTeX, especially
when it comes to PDF exports of my org files. Hence why I use the LaTeX when it comes to PDF exports of my org files. Hence why I use the LaTeX
package manager. It is recommended to use =tllocalmgr= instead of =tlmgr=, package manager. It is recommended to use ~tllocalmgr~ instead of ~tlmgr~,
but I can never remember the command, and the latter is faster to type, so but I can never remember the command, and the latter is faster to type, so
time for an abbreviation. Same goes for =texhash= which must be run as sudo. time for an abbreviation. Same goes for ~texhash~ which must be run as sudo.
#+NAME: latex-abbr #+NAME: latex-abbr
| abbreviation | command | | abbreviation | command |
|--------------+--------------| |--------------+--------------|
@ -504,18 +490,20 @@
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: Abbreviations-Typos-370bbb27 :CUSTOM_ID: Abbreviations-Typos-370bbb27
:END: :END:
Lets admit it, we all make typos from time to time in the shell, and some Let's admit it, we all make typos from time to time in the shell, and some
are recurrent enough we make abbreviations or aliases of the correct command. are recurrent enough we make abbreviations or aliases of the correct command.
Well, I have some of my abbreviations which were make exactly because of Well, I have some of my abbreviations which were make exactly because of
this. Sometimes for some reasons, my brain makes me write =clean= instead of this. Sometimes for some reasons, my brain makes me write ~clean~ instead of
=clear=. So, lets just replace the former by the latter. Im also very bad ~clear~. So, let's just replace the former by the latter. I'm also very bad
at typing =exit=. And sometimes I suck at typing =htop=. at typing ~exit~. And sometimes I suck at typing ~htop~. ~q~ isn't a typo per
se, instead just a habit I have.
#+NAME: typo-abbr #+NAME: typo-abbr
| abbreviation | command | | abbreviation | command |
|--------------+---------| |--------------+---------|
| clean | clear | | clean | clear |
| exi | exit | | exi | exit |
| exti | exit | | exti | exit |
| q | exit |
| hotp | htop | | hotp | htop |
Here is the corresponding fish configuration: Here is the corresponding fish configuration:
@ -527,58 +515,33 @@
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: Abbreviations-Misc-c2631eb6 :CUSTOM_ID: Abbreviations-Misc-c2631eb6
:END: :END:
Finally, some miscellaneous abbreviations that dont really fit into any of Finally, some miscellaneous abbreviations that don't really fit into any of
the above categories. the above categories.
*** Sudo *** Media
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: Abbreviations-Misc-Sudo-aef0214a :CUSTOM_ID: Abbreviations-Misc-Media-e4b85d56
:END: :END:
First, I make it so that =sudo= comes with the =-A= switch in order to call Here you will find various commands related to media in general. the first
my custom graphical script for getting my password (see one is a command to play some chillhop from the [[https://www.youtube.com/user/Chillhopdotcom][Chillhop YouTube channel]]'s
[[file:~/.local/bin/askpass][.local/bin/askpass]]). I also made it so =please= is an equivalent to =sudo livestream.
-A= as a joke.
#+BEGIN_SRC fish #+BEGIN_SRC fish
abbr please 'sudo -A' abbr chill 'mpv --force-window=no --no-video "https://www.youtube.com/user/Chillhopdotcom/live" &'
#+END_SRC #+END_SRC
*** Exit When it comes to mpv, I do not want to force it to open a graphical window
:PROPERTIES: if for example I want to listen to an audio file. I also do not want any
:CUSTOM_ID: Abbreviations-Misc-Exit-e3482f5c border on that window. So, I declared this abbreviation.
:END:
Sometimes I find it easier to just type =q= instead of =exit=.
#+BEGIN_SRC fish #+BEGIN_SRC fish
abbr q exit abbr mpv 'mpv --no-border --force-window=no'
#+END_SRC #+END_SRC
*** History When I want to download a song from YouTube, I'll just use the command ~flac
:PROPERTIES: videoIdentifier~ to get it through ~youtube-dl~.
:CUSTOM_ID: Abbreviations-Misc-History-a2124b23
:END:
I also find it more intuitive and faster to just write =hist= instead of
=history=, so lets declare that.
#+BEGIN_SRC fish
abbr hist history
#+END_SRC
*** ~youtube-dl~ related commands
:PROPERTIES:
:CUSTOM_ID: Abbreviations-Misc-~youtube-dl~_related_commands-654caed1
:END:
**** Song download from YouTube
:PROPERTIES:
:CUSTOM_ID: Abbreviations-Misc-~youtube-dl~_related_commands-Song_download_from_YouTube-ec2afa3c
:END:
When I want to download a song from YouTube, Ill just use the command
=flac videoIdentifier= to get it through =youtube-dl=.
#+BEGIN_SRC fish #+BEGIN_SRC fish
abbr flac 'youtube-dl -x --audio-format flac --audio-quality 0 -o "~/Music/%(uploader)s/%(title)s.%(ext)s"' abbr flac 'youtube-dl -x --audio-format flac --audio-quality 0 -o "~/Music/%(uploader)s/%(title)s.%(ext)s"'
#+END_SRC #+END_SRC
**** Videos download from YouTube
:PROPERTIES:
:CUSTOM_ID: Abbreviations-Misc-~youtube-dl~_related_commands-Videos_download_from_YouTube-33910b0b
:END:
I download a LOT of videos from YouTube, generally educative videos that I I download a LOT of videos from YouTube, generally educative videos that I
do not want to lose to YouTube one day who will decide that such channel is do not want to lose to YouTube one day who will decide that such channel is
unworthy of their platform, or if the original author decides to delete unworthy of their platform, or if the original author decides to delete
@ -588,25 +551,50 @@
abbr ytdl 'youtube-dl -f best -ciw -o "~/Videos/YouTube/%(uploader)s/%(upload_date)s - %(title)s.%(ext)s"' abbr ytdl 'youtube-dl -f best -ciw -o "~/Videos/YouTube/%(uploader)s/%(upload_date)s - %(title)s.%(ext)s"'
#+END_SRC #+END_SRC
*** MPV Some sane default options for ~sxiv~, a simple X image Viewer. This includes
:PROPERTIES: playing GIFs and not displaying the filename below. Sxiv will also open in
:CUSTOM_ID: Abbreviations-Misc-MPV-f99dd400 fullscreen and will fit the displayed image to the frame. I also abbreviated
:END: ~feh~ to sxiv, old habits die hard.
When it comes to mpv, I do not want to force it to open a graphical window
if for example I want to listen to an audio file. I also do not want any
border on that window. So, I declared this abbreviation.
#+BEGIN_SRC fish #+BEGIN_SRC fish
abbr mpv 'mpv --no-border --force-window=no' abbr sxiv 'sxiv -abfs f'
abbr feh 'sxiv -abfs f'
#+END_SRC
Finally, let's declare the following abbreviation that will launch an mpv
instance displaying my webcam:
#+BEGIN_SRC fish
abbr webcam 'mpv --demuxer-lavf-format=video4linux2 --demuxer-lavf-o-set=input_format=mjpeg av://v4l2:/dev/video0'
#+END_SRC
*** Sudo
:PROPERTIES:
:CUSTOM_ID: Abbreviations-Misc-Sudo-aef0214a
:END:
First, I make it so that ~sudo~ comes with the ~-A~ switch in order to call
my custom graphical script for getting my password (see [[file:bin.org::#Askpass-d0d7a8c0][askpass]]). I also
made it so ~please~ is an equivalent to ~sudo -A~ as a joke.
#+BEGIN_SRC fish
abbr please 'sudo -A'
#+END_SRC
*** History
:PROPERTIES:
:CUSTOM_ID: Abbreviations-Misc-History-a2124b23
:END:
I also find it more intuitive and faster to just write ~hist~ instead of
~history~, so let's declare that.
#+BEGIN_SRC fish
abbr hist history
#+END_SRC #+END_SRC
*** Compression *** Compression
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: Abbreviations-Misc-Compression-4fd4ffef :CUSTOM_ID: Abbreviations-Misc-Compression-4fd4ffef
:END: :END:
It seems its just like many other people, but I cannot for the life of me It seems it's just like many other people, but I cannot for the life of me
remember the syntax of =tar=. So, I made the following abbreviations, and remember the syntax of ~tar~. So, I made the following abbreviations, and
one day hopefully, after seeing the abbreviations expansion over and over one day hopefully, after seeing the abbreviations' expansion over and over
Ill remember the command like I did for the abbreviation of =remove= (see I'll remember the command like I did for the abbreviation of ~remove~ (see
[[#Abbreviations-System_management_(packages_and_services)-Package_management-efbcdf0f][Package management]]). [[#Abbreviations-System_management_(packages_and_services)-Package_management-efbcdf0f][Package management]]).
#+NAME: tar-abbr #+NAME: tar-abbr
| abbreviation | command | | abbreviation | command |
@ -618,19 +606,6 @@
<<generate-abbr(table=tar-abbr)>> <<generate-abbr(table=tar-abbr)>>
#+END_SRC #+END_SRC
*** Sxiv
:PROPERTIES:
:CUSTOM_ID: Abbreviations-Misc-Sxiv-1c0cf845
:END:
Some sane default options for =sxiv=, a simple X image Viewer. This includes
playing GIFs and not displaying the filename below. Sxiv will also open in
fullscreen and will fit the displayed image to the frame. I also abbreviated
~feh~ to sxiv, old habits die hard.
#+BEGIN_SRC fish
abbr sxiv 'sxiv -abfs f'
abbr feh 'sxiv -abfs f'
#+END_SRC
*** exa *** exa
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: Abbreviations-Misc-exa-e1b528b9 :CUSTOM_ID: Abbreviations-Misc-exa-e1b528b9
@ -680,19 +655,6 @@
<<generate-abbr(table=nordvpn-abbr)>> <<generate-abbr(table=nordvpn-abbr)>>
#+END_SRC #+END_SRC
*** Webcam
:PROPERTIES:
:CUSTOM_ID: Abbreviations-Misc-Webcam-34eedb5a
:END:
#+NAME: webcam-abbr
| abbreviation | command |
|--------------+------------------------------------------------------------------------------------------------------------------|
| webcam | mpv --no-border --demuxer-lavf-format=video4linux2 --demuxer-lavf-o-set=input_format=mjpeg av://v4l2:/dev/video0 |
#+BEGIN_SRC fish
<<generate-abbr(table=webcam-abbr)>>
#+END_SRC
*** Wget *** Wget
:PROPERTIES: :PROPERTIES:
:CUSTOM_ID: Abbreviations-Misc-Wget-27f4bebf :CUSTOM_ID: Abbreviations-Misc-Wget-27f4bebf