3This is a collection of functions for the Fish shell, which are [
automatically loaded][
functions].
4When I call one of these functions for the first time, Fish looks for the corresponding file in this folder and loads the function from there.
6[
functions]:
https://fishshell.com/docs/current/language.html#autoloading-functions
10# This adds the root of the repo to the PATH, which has cog_helpers.py
11from os.path import abspath, basename, dirname
14sys.path.append(abspath(dirname(dirname("."))))
23folder_name = "fish_functions"
27for f in sorted(glob.glob("fish_functions/*.fish")):
29 # Look for the line in the file that defines the function.
31 # e.g. if the file is called 'tmpdir.fish', look for the line that
32 # starts 'function tmpdir'
33 function_name = basename(f).replace('.fish', '')
34 definition_line = next(
37 if line.startswith(f'function {function_name}')
40 # Now split the definition line into components
41 components = shlex.split(definition_line)
43 description_flag = components.index("--description")
45 raise ValueError(f"No --description flag for {function_name}")
46 description = components[description_flag + 1]
48 functions.append({"name": basename(f), "description": description})
50cog_helpers.create_description_table(folder_name=folder_name, scripts=functions)
54 <a href="https://github.com/alexwlchan/scripts/blob/main/fish_functions/add_repo_to_path.fish">
55 <code>add_repo_to_path.fish</code>
59 Add a folder in my ~/repos directory to my PATH
63 <a href="https://github.com/alexwlchan/scripts/blob/main/fish_functions/append_to_file_if_not_exists.fish">
64 <code>append_to_file_if_not_exists.fish</code>
68 Append a line to a file, but only if it's not already there
72 <a href="https://github.com/alexwlchan/scripts/blob/main/fish_functions/auto_activate_venv.fish">
73 <code>auto_activate_venv.fish</code>
77 Auto activate/deactivate virtualenv when I change directories
81 <a href="https://github.com/alexwlchan/scripts/blob/main/fish_functions/fish_prompt.fish">
82 <code>fish_prompt.fish</code>
90 <a href="https://github.com/alexwlchan/scripts/blob/main/fish_functions/forget_last_command.fish">
91 <code>forget_last_command.fish</code>
95 Remove the last-typed command from my fish history
99 <a href="https://github.com/alexwlchan/scripts/blob/main/fish_functions/github-clone.fish">
100 <code>github-clone.fish</code>
104 Clone a GitHub repository into my ~/repos directory
108 <a href="https://github.com/alexwlchan/scripts/blob/main/fish_functions/go.fish">
113 Remind me to use ./tool/go in Tailscale repos
117 <a href="https://github.com/alexwlchan/scripts/blob/main/fish_functions/pip_sync.fish">
118 <code>pip_sync.fish</code>
122 Make a virtualenv dependencies look like requirements.txt
126 <a href="https://github.com/alexwlchan/scripts/blob/main/fish_functions/reload_fish_config.fish">
127 <code>reload_fish_config.fish</code>
131 Load the latest version of my fish config
135 <a href="https://github.com/alexwlchan/scripts/blob/main/fish_functions/tmpdir.fish">
136 <code>tmpdir.fish</code>
140 Create and switch into a temporary directory
144 <a href="https://github.com/alexwlchan/scripts/blob/main/fish_functions/venv.fish">
145 <code>venv.fish</code>
149 Create and activate a new virtual environment
152<!-- [[[end]]] (sum: FW10hKks6J) -->