2023-09-18 16:45:14 +00:00
#+TITLE : Fish
2020-07-16 12:25:18 +00:00
#+setupfile : headers
2023-07-01 21:53:30 +00:00
#+PROPERTY : header-args:fish :mkdirp yes :tangle ~/.config/fish/config.fish :exports code :noweb yes
2020-01-30 11:33:19 +00:00
#+PROPERTY : header-args :exports code :tangle no
2019-10-23 11:02:59 +00:00
2023-09-18 16:45:14 +00:00
* Fish
2021-02-04 13:43:09 +00:00
The file present in =~/.config/fish/config.fish= is the configuration file for
the [[https://fishshell.com/ ][fish shell ]]. It contains custom functions, environment variables and
abbreviations.
2020-11-13 14:18:43 +00:00
2023-03-20 16:17:57 +00:00
Just in case, we might sometimes need to declare the fish function =fish_title=
2021-02-04 13:43:09 +00:00
as =true= , so let’ s do so.
2020-11-13 14:18:43 +00:00
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
function fish_title
true
end
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 11:02:59 +00:00
2023-09-18 16:45:14 +00:00
** Fish from within Emacs
2023-12-10 14:09:07 +00:00
I sometimes call fish from within Emacs, with =M-x ansi-term= . In this
case, the variable =TERM= needs to have the value =eterm-color= .
2020-11-13 14:18:43 +00:00
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
if test -n "$EMACS"
set -x TERM eterm-color
end
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 13:25:35 +00:00
2023-09-18 16:45:14 +00:00
** Global variables
2022-11-09 14:29:42 +00:00
An important thing to do is to load all variables from my =~/.profile=
file (which you can find [[https://labs.phundrak.com/phundrak/dotfiles/src/branch/master/.profile ][here ]]). The [[https://github.com/oh-my-fish/plugin-foreign-env ][foreign-env ]] plugin comes in handy:
2022-06-07 17:20:14 +00:00
#+begin_src fish
2022-11-03 10:45:21 +00:00
fenv source ~/.profile
2022-06-07 17:20:14 +00:00
#+end_src
2024-02-20 05:18:30 +00:00
2024-02-07 05:32:39 +00:00
[[https://direnv.net/ ][Direnv ]] is a really neat tool that allows you to load the content of a
dotenv file as environment variables. Its installation is quite simple
for fish.
#+begin_src fish
direnv hook fish | source
#+end_src
2024-04-03 04:04:23 +00:00
I also use [[https://github.com/elkowar/eww/ ][eww ]] for some widgets, let’ s load its shell completions.
#+begin_src fish
eww shell-completions --shell fish | source
#+end_src
2024-06-20 07:39:55 +00:00
The [[https://crates.io/crates/sqlx ][sqlx ]] CLI is a requirement for my Rust projects using this crate.
The code below integrates its completions in Fish.
#+begin_src fish
sqlx completions fish | source
#+end_src
2024-02-07 05:32:39 +00:00
Since I don’ t really have a better place on this website to put it,
here is my direnv configuration located at
=$HOME/.config/direnv/direnv.toml= .
#+begin_src toml :tangle ~/.config/direnv/direnv.toml :mkdirp yes :exports code
[global]
load_dotenv = true
#+end_src
2023-09-18 16:45:14 +00:00
*** Development
2023-12-10 14:09:07 +00:00
Finally, some development packages require the =PKG_CONFIG_PATH= to be
set, so let’ s do so.
2022-06-07 17:20:14 +00:00
#+BEGIN_SRC fish
set -gx PKG_CONFIG_PATH /usr/local/lib/pkgconfig/ $PKG_CONFIG_PATH
#+END_SRC
2023-09-18 16:45:14 +00:00
** Tramp remote access
2023-03-20 16:17:57 +00:00
When accessing from a remote machine our computer from Emacs, tramp
needs a precise shell appearance: a simple =$= followed by a space after
which to put the commands it needs to execute, and nothing else. Due
to this, let’ s deactivate and redefine some functions defining the
appearance of fish.
2020-11-13 14:18:43 +00:00
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
if test "$TERM" = "dumb"
function fish_prompt
echo "\$ "
end
function fish_right_prompt; end
function fish_greeting; end
function fish_title; end
end
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 13:25:35 +00:00
2023-09-18 16:45:14 +00:00
** Regular fish shell appearance
2023-02-22 14:34:56 +00:00
Now, there is only one function I modify when it comes to the
appearance of fish when I’ m the one using it: the ~fish_greeting~
function. I just want it empty.
2020-11-13 14:18:43 +00:00
#+BEGIN_SRC fish
2024-06-20 07:41:15 +00:00
function fish_greeting
pumo-system-info
end
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 13:25:35 +00:00
2023-12-10 14:09:07 +00:00
For my fish prompt, I use [[https://starship.rs ][starship ]], a shell-agnostic prompt. Let’ s
load it:
2021-12-18 10:54:32 +00:00
#+begin_src fish
2024-06-20 07:40:26 +00:00
function starship_transient_prompt_func
starship module character
end
2021-12-18 10:54:32 +00:00
starship init fish | source
2024-06-20 07:40:26 +00:00
enable_transience
2021-12-18 10:54:32 +00:00
#+end_src
2020-12-02 15:12:10 +00:00
2023-09-18 16:45:14 +00:00
** Setting up external tools
*** Starship configuration
2021-12-18 10:54:32 +00:00
:PROPERTIES:
:header-args:toml: :tangle ~/.config/starship.toml
:END:
2023-12-10 14:09:07 +00:00
As mentioned above, starship is a shell-agnostic prompt, written in
Rust and which can be configured separately from the shell. I decided
to configure it here though, since fish is the only shell I use which
is compatible with starship.
2020-12-02 16:28:08 +00:00
2023-12-10 14:09:07 +00:00
First I’ ll modify the default format variable, removing the modules I
don’ t need.
2021-12-18 10:54:32 +00:00
#+begin_src toml
format = """
$username\
$hostname\
$shlvl\
$singularity\
$kubernetes\
$directory\
$vcsh\
$git_branch\
$git_commit\
$git_state\
$git_metrics\
$git_status\
$hg_branch\
$docker_context\
$package\
$cmake\
$dart\
$deno\
$lua\
$nodejs\
$python\
$rlang\
$rust\
$scala\
$zig\
2024-06-20 07:41:03 +00:00
$nix_shell\
$direnv\
2021-12-18 10:54:32 +00:00
$memory_usage\
$env_var\
$custom\
$cmd_duration\
$line_break\
$jobs\
$battery\
$time\
$status\
$shell\
$character"""
#+end_src
2023-12-10 14:09:07 +00:00
I want starship to be able to detect Lisp files, be it CommonLisp or
EmacsLisp. Unfortunately, it seems nerd-font doesn’ t have any symbol
for either language, so I’ m just using a lambda character.
2021-12-18 10:54:32 +00:00
#+begin_src toml
[custom.lisp]
extensions = ["lisp", "el"]
2021-12-20 10:37:09 +00:00
symbol = "λ "
2021-12-18 10:54:32 +00:00
style = "bold green"
#+end_src
2024-06-20 07:41:03 +00:00
Some module configurations don’ t exactly sit right with me, so let’ s
tweak them a bit.
#+begin_src toml
[nix_shell]
format = '[$symbol$state( \($name\))]($style)'
symbol = '❄️ '
[shlvl]
disabled = false
threshold = 3
[direnv]
disabled = false
detect_files = ['.envrc', '.env']
symbol = ' '
#+end_src
2021-12-18 10:54:32 +00:00
Finally, let’ s disable all modules I don’ t need.
#+begin_src toml
[cobol]
disable = true
[dotnet]
disable = true
[elixir]
disable = true
[elm]
disable = true
[erlang]
disable = true
[golang]
disable = true
[helm]
disable = true
[java]
disable = true
[julia]
disable = true
[kotlin]
disable = true
[nim]
disable = true
[ocaml]
disable = true
[perl]
disable = true
[php]
disable = true
[pulumi]
disable = true
[purescript]
disable = true
[red]
disable = true
[ruby]
disable = true
[swift]
disable = true
[terraform]
disable = true
[vlang]
disable = true
[vagrant]
disable = true
[conda]
disable = true
[aws]
disable = true
[gcloud]
disable = true
[openstack]
disable = true
[crystal]
disable = true
#+end_src
2021-02-04 08:14:52 +00:00
2024-02-20 05:18:30 +00:00
*** Loading =zoxide=
=zoxide= is a smarter =cd= command. I actually have it replace =cd= entirely through the =--cmd= flag you see below..
2021-12-25 20:32:49 +00:00
#+begin_src fish
2024-02-20 05:18:30 +00:00
zoxide init --cmd cd fish | source
2021-12-25 20:32:49 +00:00
#+end_src
2023-09-18 16:45:14 +00:00
** Abbreviations
2020-11-13 14:18:43 +00:00
#+NAME : generate-abbr
#+BEGIN_SRC emacs-lisp :var table=[] :exports none :tangle no
2021-10-12 09:31:20 +00:00
(replace-regexp-in-string "\\\\vert[{}]*"
"|"
(mapconcat (lambda (x) (format "abbr %s '%s'" (car x) (cadr x)))
table
"\n")
t t)
2020-11-13 14:18:43 +00:00
#+END_SRC
2020-02-24 18:52:13 +00:00
2023-12-10 14:09:07 +00:00
Abbreviations are a great way to keep correctly track of which
commands are run in the shell without polluting the history of the
shell with obscure commands. When typing an abbreviation, fish will
replace it with replace it with its expanded equivalent. Below are
some of the abbreviations I use. Be aware some of them that invoke GUI
programs can be invoked through ~devour~ which will make the terminal
disappear while the program runs, and once the GUI program exists the
terminal window will come back.
[Fish] Remove, add, update some abbreviations
Abbreviations removed: `p', `surge', `ls', and `feh'
Abbreviations added: `suser', `egui',
Add `devour' to abbreviations `egui', `mpv', `sxiv', `webcam'
2021-02-04 08:43:55 +00:00
2023-09-18 16:45:14 +00:00
*** System monitoring
2023-03-20 16:17:57 +00:00
Here I have some abbreviations which are quite useful when performing
some system monitoring. With =df= , we can get an overview of our
filesystem usage, while with =diskspace= we get some more precise
information. =meminfo= is a call to =free= with sane defaults, and similar
to =meminfo= , we also have =gpumeminfo= to get a quick look at the
memory-related logs of our X session. I also declared =cpuinfo= an alias
of =lscpu= in order to keep consistent with =meminfo= . =pscpu= gives us
information on what the CPU is running right now, and =pscpu10= limits
that to the top 10 threads. Similarly, =psmem= gives us information on
the memory usage of the current threads, and =psmem10= only the ten most
important threads in terms of memory usage.
2020-11-13 14:18:43 +00:00
#+NAME : mgmt-abbr
2020-11-29 12:47:28 +00:00
| abbreviation | command |
|--------------+--------------------------------------------|
| df | df -H |
| diskspace | sudo df -h \vert grep -E "sd\vert{}lv\vert{}Size" |
| du | du -ch |
| meminfo | free -m -l -t |
| gpumeminfo | grep -i --color memory /var/log/Xorg.0.log |
| cpuinfo | lscpu |
| pscpu | ps auxf \vert sort -nr -k 3 |
| pscpu10 | ps auxf \vert sort -nr -k 3 \vert head -10 |
| psmem | ps auxf \vert sort -nr -k 4 |
| psmem10 | ps auxf \vert sort -nr -k 4 \vert head -10 |
2020-11-13 14:18:43 +00:00
#+begin_SRC fish
2021-10-12 09:31:20 +00:00
<<generate-abbr(table=mgmt-abbr) >>
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 11:02:59 +00:00
2023-09-18 16:45:14 +00:00
*** System management (packages and services)
2023-12-10 14:09:07 +00:00
I added some of these abbreviations due to how often I have to write
the whole thing.
2019-10-23 13:25:35 +00:00
2023-09-18 16:45:14 +00:00
**** Package management
2023-12-10 14:09:07 +00:00
The first command is =remove= which removes a package from my system, as
well as its dependencies no longer needed. =p= . =pacman= 's or =paru= 's. This
is why I simply type =purge= . And if I want to simply search among the
=pacman= repos, I can type =search= . Otherwise, if I want to include AUR
results, I’ ll use =paru= .
2020-11-13 14:18:43 +00:00
#+NAME : pm-abbr
2021-03-31 14:22:50 +00:00
| abbreviation | command |
|--------------+------------------|
| remove | sudo pacman -Rsc |
| purge | paru -Sc |
2020-11-13 14:18:43 +00:00
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
<<generate-abbr(table=pm-abbr) >>
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 13:25:35 +00:00
2023-09-18 16:45:14 +00:00
**** Service management
2023-12-10 14:09:07 +00:00
I don’ t have the muscle memory of =systemctl= . So instead, I simply type
=c= when I want to do something user service related. And if I want to
manipulate system services, I can instead type a simple capital =S= .
2020-11-13 14:18:43 +00:00
#+NAME : service-abbr
[Fish] Remove, add, update some abbreviations
Abbreviations removed: `p', `surge', `ls', and `feh'
Abbreviations added: `suser', `egui',
Add `devour' to abbreviations `egui', `mpv', `sxiv', `webcam'
2021-02-04 08:43:55 +00:00
| abbreviation | command |
|--------------+------------------|
| s | systemctl |
| suser | systemctl --user |
2020-11-13 14:18:43 +00:00
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
<<generate-abbr(table=service-abbr) >>
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 13:25:35 +00:00
2023-09-18 16:45:14 +00:00
*** Development
2023-12-10 14:09:07 +00:00
A good amount of these commands are development related, especially
when it comes to compilation or Docker.
2019-10-23 13:25:35 +00:00
2023-09-18 16:45:14 +00:00
**** CMake
2023-03-20 16:17:57 +00:00
I have the following abbreviations to quickly run CMake and create a
2021-02-04 13:43:09 +00:00
configuration for debug or release profiles.
2020-11-13 14:18:43 +00:00
#+NAME : abbr-cmake
| abbreviation | command |
|--------------+----------------------------------|
| cdebug | cmake -DCMAKE_BUILD_TYPE=Debug |
| crelease | cmake -DCMAKE_BUILD_TYPE=Release |
Here is the corresponding fish configuration:
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
<<generate-abbr(table=abbr-cmake) >>
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 11:02:59 +00:00
2024-02-07 18:33:23 +00:00
**** Docker
And of course, when it comes to Docker Compose, I don't have time to write the
full command, so I use these instead.
2020-11-13 14:18:43 +00:00
#+NAME : abbr-docker
| abbreviation | command |
|--------------+------------------------------|
2024-02-07 18:33:23 +00:00
| dc | docker-compose |
| dcb | docker-compose build |
| dcd | docker-compose down |
| dcl | docker-compose logs |
| dclf | docker-compose logs -f |
| dcp | docker-compose pull |
| dcr | docker-compose run --rm |
| dcu | docker-compose up |
| dcub | docker-compose up --build |
| dcud | docker-compose up -d |
| dcudb | docker-compose up -d --build |
2020-11-13 14:18:43 +00:00
Here is the corresponding fish configuration:
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
<<generate-abbr(table=abbr-docker) >>
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 11:02:59 +00:00
2023-09-18 16:45:14 +00:00
**** Text editors
2021-02-04 13:43:09 +00:00
I greatly prefer to use Emacsclient as my main text editor; Emacs has basically
all I need. So, it's only normal I have an abbreviation to launch a new instance
of it. If launched in the terminal, I’ ll usually want Emacs to be displayed in
CLI mode and not in GUI mode, otherwise I would invoke it with my WM’ s shortcut.
2023-03-20 16:17:57 +00:00
In case we want to launch Emacs in GUI mode anyway, ~egui~ is available too.
2020-11-13 14:18:43 +00:00
#+NAME : abbr-text-ed
[Fish] Remove, add, update some abbreviations
Abbreviations removed: `p', `surge', `ls', and `feh'
Abbreviations added: `suser', `egui',
Add `devour' to abbreviations `egui', `mpv', `sxiv', `webcam'
2021-02-04 08:43:55 +00:00
| abbreviation | command |
|--------------+-----------------------|
2022-11-09 14:30:22 +00:00
| e | emacsclient -c -n |
[Fish] Remove, add, update some abbreviations
Abbreviations removed: `p', `surge', `ls', and `feh'
Abbreviations added: `suser', `egui',
Add `devour' to abbreviations `egui', `mpv', `sxiv', `webcam'
2021-02-04 08:43:55 +00:00
| egui | devour emacsclient -c |
2020-11-13 14:18:43 +00:00
Here is the corresponding fish configuration:
#+BEGIN_SRC fish :noweb yes
2021-10-12 09:31:20 +00:00
<<generate-abbr(table=abbr-text-ed) >>
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 13:25:35 +00:00
2023-09-18 16:45:14 +00:00
**** Compilation
2021-02-04 13:43:09 +00:00
By default, I set ~clang~ , ~clang++~ , ~gcc~ and ~g++~ to the latest standard and
with the ~-Wall~ flag activated.
2020-11-13 14:18:43 +00:00
#+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
2021-10-12 09:31:20 +00:00
<<generate-abbr(table=abbr-comp) >>
2020-11-13 14:18:43 +00:00
#+END_SRC
2020-08-28 13:39:39 +00:00
2023-09-18 16:45:14 +00:00
**** Git
2021-02-04 13:43:09 +00:00
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.
2020-11-13 14:18:43 +00:00
#+NAME : abbr-git
| abbreviation | command |
|--------------+-----------------------------------------------------|
| randcommit | git commit -m (curl -s whatthecommit.com/index.txt) |
Here is the corresponding fish configuration:
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
<<generate-abbr(table=abbr-git) >>
2020-11-13 14:18:43 +00:00
#+END_SRC
2020-08-28 13:39:39 +00:00
2023-09-18 16:45:14 +00:00
*** LaTeX
2021-02-04 13:43:09 +00:00
Yes, although I use org-mode, I still have some use for LaTeX, especially when
2023-03-20 16:17:57 +00:00
it comes to PDF exports of my org files. Hence, why I use the LaTeX package
2021-02-04 13:43:09 +00:00
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 time for an
abbreviation. Same goes for ~texhash~ which must be run as sudo.
2020-11-13 14:18:43 +00:00
#+NAME : latex-abbr
| abbreviation | command |
|--------------+--------------|
| tlmgr | tllocalmgr |
| texhash | sudo texhash |
Here is the corresponding fish configuration:
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
<<generate-abbr(table=latex-abbr) >>
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 13:25:35 +00:00
2023-09-18 16:45:14 +00:00
*** Some security measures
2023-03-20 16:17:57 +00:00
Some commands can be quite dangerous when not used properly, which is
why I added default flags and options in order to get warnings before
things get ugly. The =-i= and =-I= add prompts in case we might not want
to do what we asked the shell to do. Notice =lns= which creates
symlinks, =rmd= which removes directories, =rmf= which forces deletion,
and =rmdf= which forces the delition of a directory. Notice also the
=--preserve-root= which will prevent me from accidentally removing the
root folder. I added the same option to =chgrp= , =chmod= , and =chown= .
2020-11-13 14:18:43 +00:00
#+NAME : sec-abbr
2023-03-10 14:15:06 +00:00
| abbreviation | command |
|--------------+--------------------------|
| cp | cp -i |
| rsync | rsync -Pa --progress |
| ln | ln -i |
| lns | ln -si |
| mv | mv -i |
| rm | rm -Iv |
| rmd | rm --preserve-root -Irv |
| rmdf | rm --preserve-root -Irfv |
| rmf | rm --preserve-root -Ifv |
| chgrp | chgrp --preserve-root -v |
| chmod | chmod --preserve-root -v |
| chown | chown --preserve-root -v |
2020-11-13 14:18:43 +00:00
Here is the corresponding fish configuration:
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
<<generate-abbr(table=sec-abbr) >>
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 13:25:35 +00:00
2023-09-18 16:45:14 +00:00
*** Typos
2023-12-10 14:09:07 +00:00
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. Well, I have some of my abbreviations which were make
exactly because of this. Sometimes for some reason, my brain makes me
write ~clean~ instead of ~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~ .
2020-11-13 14:18:43 +00:00
#+NAME : typo-abbr
| abbreviation | command |
|--------------+---------|
| clean | clear |
| exi | exit |
| exti | exit |
| hotp | htop |
Here is the corresponding fish configuration:
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
<<generate-abbr(table=typo-abbr) >>
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 13:25:35 +00:00
2023-09-18 16:45:14 +00:00
*** Misc
2021-02-04 13:43:09 +00:00
Finally, some miscellaneous abbreviations that don't really fit into any of the
above categories.
2019-10-23 13:25:35 +00:00
2023-09-18 16:45:14 +00:00
**** Media
2023-03-20 16:18:59 +00:00
Here you will find various commands related to media in general. The
first one is a command to play some chillhop from the [[https://www.youtube.com/ @LofiGirl][Lofi Girl
YouTube channel]]'s livestream.
2020-11-13 14:18:43 +00:00
#+BEGIN_SRC fish
2023-03-20 16:18:59 +00:00
abbr chill 'mpv --force-window=no --no-video "https://www.youtube.com/watch?v=jfKfPfyJRdk" &'
2020-11-13 14:18:43 +00:00
#+END_SRC
2023-12-10 14:09:07 +00:00
When it comes to MPV, I do not want to force it to open a graphical window if
2021-02-04 13:43:09 +00:00
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.
2020-11-13 14:18:43 +00:00
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
abbr mpv 'mpv --no-border --force-window=no'
2020-11-13 14:18:43 +00:00
#+END_SRC
2021-02-04 13:43:09 +00:00
When I want to download a song from YouTube, I'll just use the command ~flac
videoIdentifier~ to get it through ~youtube-dl~ .
2020-11-13 14:18:43 +00:00
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
abbr flac 'youtube-dl -x --audio-format flac --audio-quality 0 -o "~/Music/ %(uploader)s/%(title)s.%(ext)s"'
2020-11-13 14:18:43 +00:00
#+END_SRC
2022-02-24 16:13:23 +00:00
Some sane default options for [[https://github.com/nsxiv/nsxiv ][~nsxiv~ ]]. This includes playing GIFs and
2023-12-10 14:09:07 +00:00
not displaying the filename below. Nsxiv will also open in full-screen
2022-11-09 14:30:40 +00:00
and will fit the displayed image to the frame. It will also output to
stdout the selected files in case I want to pipe them to another
program.
2020-11-13 14:18:43 +00:00
#+BEGIN_SRC fish
2022-11-09 14:30:40 +00:00
abbr nsxiv 'nsxiv -abfos f'
2020-11-13 14:18:43 +00:00
#+END_SRC
2023-03-20 16:17:57 +00:00
The following abbreviation is here to launch software with my Nvidia
GPU.
2022-09-19 10:35:40 +00:00
#+begin_src fish
abbr nv 'env __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia'
#+end_src
2023-12-10 14:09:07 +00:00
Finally, let's declare the following abbreviation that will launch an
MPV instance displaying my webcam:
2020-11-13 14:18:43 +00:00
#+BEGIN_SRC fish
2023-03-20 16:18:38 +00:00
abbr webcam 'devour mpv --demuxer-lavf-format=video4linux2 --demuxer-lavf-o-set=input_format=mjpeg av://v4l2:/dev/video0 --profile=low-latency --untimed'
2020-11-13 14:18:43 +00:00
#+END_SRC
2020-08-28 13:39:39 +00:00
2023-09-18 16:45:14 +00:00
**** Sudo
2021-02-04 13:43:09 +00:00
First, I make it so that ~sudo~ comes with the ~-A~ switch in order to call my
2024-09-21 13:27:37 +00:00
custom graphical script for getting my password (see [[file:./scripts.md#askpass ][askpass ]]). I also made it so
2021-02-04 13:43:09 +00:00
~please~ is an equivalent to ~sudo -A~ as a joke.
2020-11-13 14:18:43 +00:00
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
abbr please 'sudo -A'
2020-11-13 14:18:43 +00:00
#+END_SRC
2020-08-28 13:39:39 +00:00
2023-09-18 16:45:14 +00:00
**** History
2021-02-04 13:43:09 +00:00
I find it more intuitive and faster to just write ~hist~ instead of ~history~ ,
so let's declare that.
2020-11-13 14:18:43 +00:00
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
abbr hist history
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 11:02:59 +00:00
2023-09-18 16:45:14 +00:00
**** Compression
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 one day hopefully, after seeing the abbreviations'
expansion over and over I'll remember the command like I did for the
abbreviation of ~remove~ (see [[file:./fish.md#package-management ][Package management ]]).
2020-11-13 14:18:43 +00:00
#+NAME : tar-abbr
| abbreviation | command |
|--------------+-----------|
| compress | tar -czf |
| untar | tar -xvzf |
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
<<generate-abbr(table=tar-abbr) >>
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 11:02:59 +00:00
2023-09-18 16:45:14 +00:00
**** exa
2023-12-10 14:09:07 +00:00
#+NAME : eza-abbr
2020-11-13 14:18:43 +00:00
| abbreviation | command |
|--------------+--------------------------------------------|
2023-12-10 14:09:07 +00:00
| eza | eza -halg@ --group-directories-first --git |
| lsl | eza -halg@ --group-directories-first --git |
2020-04-11 18:27:46 +00:00
2020-11-13 14:18:43 +00:00
#+BEGIN_SRC fish
2023-12-10 14:09:07 +00:00
<<generate-abbr(table=eza-abbr) >>
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 11:02:59 +00:00
2023-09-18 16:45:14 +00:00
**** Network Management
2023-12-10 14:09:07 +00:00
First, we have just =nmcli= with sane default options, that is a pretty
output with colours.
2020-11-13 14:18:43 +00:00
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
abbr nmcli 'nmcli -p -c auto'
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-10-23 11:02:59 +00:00
2023-09-18 16:45:14 +00:00
**** NordVPN
2023-12-10 14:09:07 +00:00
Next, we have some NordVPN-related shortcuts. The first one is a
simple abbreviation to =nordvpn= . The second one is a shortcut to
connect to a server, and to disconnect from the current server. I also
have a couple of shortcuts to quickly connect to some preselected
countries, mainly France, Germany, Japan and the US.
2020-11-13 14:18:43 +00:00
#+NAME : nordvpn-abbr
| abbreviation | command |
|--------------+-------------------------|
| n | nordvpn |
| nc | nordvpn c |
| nd | nordvpn d |
| ncf | nordvpn c France |
| ncg | nordvpn c Germany |
| ncj | nordvpn c Japan |
| ncu | nordvpn c United_States |
#+BEGIN_SRC fish
2021-10-12 09:31:20 +00:00
<<generate-abbr(table=nordvpn-abbr) >>
2020-11-13 14:18:43 +00:00
#+END_SRC
2019-11-29 20:15:37 +00:00
2023-09-18 16:45:14 +00:00
**** Wget
2023-12-10 14:09:07 +00:00
By default, continue a download that was interrupted.
2020-11-13 14:18:43 +00:00
#+BEGIN_SRC fish
2022-06-07 17:20:14 +00:00
abbr wget 'wget --hsts-file="$XDG_DATA_HOME/wget-hsts" -c'
2020-11-13 14:18:43 +00:00
#+END_SRC
2021-04-04 10:10:48 +00:00
2023-09-18 16:45:14 +00:00
** Last thing before we’ re done
2021-04-04 10:10:48 +00:00
For some reason, Fish began searching for packages when I enter a command name
wrong. For instance, if I type ~vim~ , I get something like this:
#+BEGIN_SRC text :tangle no
$ vim
fish: Unknown command: vim
usr/bin/vim is owned by extra/gvim 8.2.2653-1
usr/bin/vim is owned by extra/vim 8.2.2653-1
#+END_SRC
But I don’ t want that, it slows down my shell. So, in order to fix that, we need
the following lines:
#+BEGIN_SRC fish
function fish_command_not_found
__fish_default_command_not_found_handler $argv
end
#+END_SRC
2023-12-10 14:09:07 +00:00
Ta-dah! No more package suggestions from fish!
2022-12-16 13:41:07 +00:00
I also have some private abbreviations I don’ t want people to know
about that I store in a separate configuration file.
#+begin_src fish
source $HOME/.config/fish/private.fish
#+end_src