Bash functions
How to create and use Bash functions
-
Include a function script
Add an external script file in .zshrc:
source ~/toolbox/scripts/functions.sh -
Write a function
Create a functions.sh file in the desired location:
#!/bin/bash # Prints the ignored files tracked by Git function -list-ignored-git() { git ls-files -v | grep '^h' } function -ignore-git() { git update-index --assume-unchanged "$1" } function -unignore-git() { git update-index --no-assume-unchanged "$1" } -
Source your shell config:
source ~/.zshrc -
Use the functions:
$ -ignore-git README.md $ -list-ignored-git h README.md $ -unignore-git README.md $ -list-ignored-git