Skip to content

Commit

Permalink
Moved back to fish shell
Browse files Browse the repository at this point in the history
  • Loading branch information
jaidetree committed Aug 7, 2021
1 parent 048644f commit 2f686a3
Show file tree
Hide file tree
Showing 16 changed files with 307 additions and 53 deletions.
6 changes: 6 additions & 0 deletions .dir-locals.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
;; ((org-mode
;; (eval add-hook! 'after-save-hook
;; '(lambda () (if (y-or-n-p "Tangle?")
;; (org-babel-tangle)
;; t)) nil t)))
;;
4 changes: 2 additions & 2 deletions alacritty/alacritty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,8 @@ live_config_reload: true
# You can set shell.program to the path of your favorite shell, e.g. /bin/fish.
# Entries in shell.args are passed unmodified as arguments to the shell.
shell:
# program: /usr/local/bin/fish
program: /usr/local/bin/elvish
program: /usr/local/bin/fish
# program: /usr/local/bin/elvish
# args:
# - --command=tmux

Expand Down
Binary file modified elvish/db
Binary file not shown.
15 changes: 0 additions & 15 deletions elvish/elvish.org
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,3 @@ set paths = [
/Library/Frameworks/Mono.framework/Versions/Current/bin/
]
#+end_src


* Configure nvm

Node version manager supports project-based configuration to specify a version
of node to use.

#+begin_src elvish
set E:NVM_DIR = $E:HOME"/.nvm"
bash $E:NVM_DIR"/nvm.sh"
#+end_src

;; Local Variables:
;; eval: (add-hook 'after-save-hook (lambda ()(if (y-or-n-p "Tangle?")(org-babel-tangle))) nil t)
;; End:
3 changes: 0 additions & 3 deletions elvish/rc.elv
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,3 @@ set paths = [
/usr/local/MacGPG2/bin
/Library/Frameworks/Mono.framework/Versions/Current/bin/
]

set E:NVM_DIR = $E:HOME"/.nvm"
bash $E:NVM_DIR"/nvm.sh"
50 changes: 24 additions & 26 deletions omf/init.fish
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
# BEHAVIOR CHANGES
##############################################################################
# fish_vi_key_bindings
# fish_hybrid_key_bindings
# fish_default_key_bindings
# [[file:oh-my-fish.org::*Path][Path:1]]
set -x PATH \
$HOME/.npm-global/bin \
$HOME/bin \
$HOME/.yarn/bin \
$HOME/.config/yarn/global/node_modules/.bin \
$HOME/.luarocks/bin \
$HOME/.emacs.d/bin \
/usr/local/bin \
/usr/local/opt/openjdk/bin \
/usr/bin \
/usr/sbin \
/sbin \
/usr/local/MacGPG2/bin \
/Library/Frameworks/Mono.framework/Versions/Current/bin \
$PATH
# Path:1 ends here

# PATH
##############################################################################
set -x PATH $HOME/.npm-global/bin $HOME/bin $HOME/.yarn/bin $HOME/.config/yarn/global/node_modules/.bin $PATH
set -x PATH $HOME/.luarocks/bin /usr/local/bin $HOME/.emacs.d/bin $PATH
set -x LUA_PATH '$HOME/.luarocks/share/lua/5.3/?.lua;$HOME/.luarocks/share/lua/5.3/?/init.lua;/usr/local/share/lua/5.3/?.lua;/usr/local/share/lua/5.3/?/init.lua;/usr/local/Cellar/luarocks/3.1.3/share/lua/5.3/?.lua;/usr/local/lib/lua/5.3/?.lua;/usr/local/lib/lua/5.3/?/init.lua;./?.lua;./?/init.lua'
set -x LUA_CPATH '$HOME/.luarocks/lib/lua/5.3/?.so;/usr/local/lib/lua/5.3/?.so;/usr/local/lib/lua/5.3/loadall.so;./?.so'

# CONFIG
##############################################################################
# set -gx JAVA_TOOL_OPTIONS "--add-modules=java.xml.bind"

# Conditional Configs
##############################################################################
# [[file:oh-my-fish.org::*Bindings][Bindings:1]]
fish_default_key_bindings
# Bindings:1 ends here

# DIR ENV
##############################################################################
# [[file:oh-my-fish.org::*Dir Env][Dir Env:1]]
direnv hook fish | source
# Dir Env:1 ends here


# Nix
##############################################################################
# set -x NIX_PATH "darwin-config=$HOME/.nixpkgs/darwin-configuration.nix:$HOME/.nix-defexpr/channels"
# source ~/dotfiles/client/nix/nix.fish
# echo "$NIX_PATH"
# [[file:oh-my-fish.org::*ASDF Version Manager][ASDF Version Manager:1]]
source (brew --prefix asdf)"/asdf.fish"
# ASDF Version Manager:1 ends here
12 changes: 12 additions & 0 deletions omf/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# [[file:oh-my-fish.org::*Setup Install Script][Setup Install Script:1]]
#!/usr/bin/env bash
# Setup Install Script:1 ends here

# [[file:oh-my-fish.org::*Install Fish][Install Fish:1]]
brew install fish
# Install Fish:1 ends here

# [[file:oh-my-fish.org::*Change Default Shell][Change Default Shell:1]]
which fish | sudo tee -a /etc/shells
chsh -s `which fish`
# Change Default Shell:1 ends here
86 changes: 86 additions & 0 deletions omf/oh-my-fish.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#+title: Oh My Fish
:CONFIG:
#+property: header-args:fish :tangle init.fish
#+property: header-args:bash :tangle install.sh
#+property: header-args :mkdirp yes
#+startup: indent
:END:


* Install

** Setup Install Script

Generate shebang for install.sh script

#+begin_src bash
#!/usr/bin/env bash
#+end_src

** Install Fish
#+begin_src bash
brew install fish
#+end_src

** Change Default Shell

#+begin_src bash
which fish | sudo tee -a /etc/shells
chsh -s `which fish`
#+end_src

* Config

** Path

Determines which binaries and executables are always accessible without having
to specify a path prefix.

#+begin_src fish
set -x PATH \
$HOME/.npm-global/bin \
$HOME/bin \
$HOME/.yarn/bin \
$HOME/.config/yarn/global/node_modules/.bin \
$HOME/.luarocks/bin \
$HOME/.emacs.d/bin \
/usr/local/bin \
/usr/local/opt/openjdk/bin \
/usr/bin \
/usr/sbin \
/sbin \
/usr/local/MacGPG2/bin \
/Library/Frameworks/Mono.framework/Versions/Current/bin \
$PATH
#+end_src

** Bindings

#+begin_src fish
fish_default_key_bindings
#+end_src

* Plugins

** Dir Env

Loads .envrc files when entering into a directory
https://direnv.net/docs/hook.html#fish

#+begin_src fish
direnv hook fish | source
#+end_src

** ASDF Version Manager

A version manager for a wide variety of tools such as node.
http://asdf-vm.com/guide/getting-started.html#_3-install-asdf

#+begin_src fish
source (brew --prefix asdf)"/asdf.fish"
#+end_src


;; Local Variables:
;; eval: (add-hook 'after-save-hook (lambda ()(if (y-or-n-p "Tangle?")(org-babel-tangle))) nil t)
;; End:
2 changes: 1 addition & 1 deletion omf/themes/fishing-line/fish_prompt.fish
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ end
function fish_prompt
set -g _last_status $status
set -l branch (__fish_git_prompt "%s")
set -l _is_git_dirty (git status -s --ignore-submodules=dirty ^/dev/null)
set -l _is_git_dirty (git status -s --ignore-submodules=dirty 2>/dev/null)

__theme_glyphs

Expand Down
4 changes: 4 additions & 0 deletions spacehammer/advice-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
;; [[file:testing.org::*Emacs Advice Test][Emacs Advice Test:1]]
(defun some-fun (&rest args)
(string-join (cons "original" args) " "))
;; Emacs Advice Test:1 ends here
39 changes: 38 additions & 1 deletion spacehammer/advice-test.fnl
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,47 @@
(is.eq? state.calls 2 "Before test-func did not call both the original and before fn")
(is.eq? state.args "1 2 3 4" "Before test-func did not call both the original and before with the same args"))))

(it "Should call orig if before-while returns truthy"
(fn []
(let [state {:called false}
test-func (make-advisable
:test-func-5
(fn [...]
"Advisable test function"
(.. "original " (join " " [...]))))]

(add-advice test-func
:before-while
(fn [...]
(tset state :called true)
true))
(is.eq? (test-func 1 2) "original 1 2" "Before-while test-func did not call original function")
(is.eq? state.called true "Before-while test-func advice function was not called"))))

(it "Should call orig if before-until returns falsey value"
(fn []
(let [state {:called false}
test-func (make-advisable
:test-func-6
(fn [...]
"Advisable test function"
(.. "original " (join " " [...]))))]

(add-advice test-func
:before-until
(fn [...]
(tset state :called true)
false))
(is.eq? (test-func 1 2) "original 1 2" "Before-until test-func did not call original function")
(is.eq? state.called true "Before-until test-func advice function was not called"))))


(it "Should call after functions"
(fn []
(let [state {:calls 0
:args ""}
test-func (make-advisable
:test-func-5
:test-func-7
(fn [...]
"Advisable test function"
(let [args [...]]
Expand All @@ -88,6 +123,8 @@
(is.eq? state.calls 2 "After test-func did not call both the original and after fn")
(is.eq? state.args "1 2 3 4" "After test-func did not call both the original and after with the same args"))))




))

120 changes: 120 additions & 0 deletions spacehammer/advice.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#+title: Emacs Advice Test
#+property: header-args :tangle advice-test.el

* Emacs Advice Test

Implementing an advising system for [[https://fennel-lang.org][fennel-lang]] for use in the OS X [[https://github.com/agzam/spacehammer/][Spacehammer]]
configuration framework.

** Original function definition

#+begin_src elisp
(defun some-fun (&rest args)
(message "original some-fun called %s" (string-join args " "))
(string-join (cons "original" args) " "))
#+end_src

#+RESULTS:
: some-fun

** Advice

*** Before 3

#+begin_src elisp :results none
(defadvice! advtest-before-3 (&rest args)
"Before test 3"
:before #'some-fun
(message "before-3 args: %s" (string-join args " ")))
#+end_src

*** Before 1

#+begin_src elisp :results none
(defadvice! advtest-before-1 (&rest args)
"Before test 1"
:before #'some-fun
(message "before-1 args: %s" (string-join args " ")))
#+end_src

*** Before-While 1

#+begin_src elisp :results none
(defadvice! advtest-before-while-1 (&rest args)
"Before-while test 1"
:before-while #'some-fun
(message "before-while-1 args: %s" (string-join args " "))
nil)
#+end_src


*** After 1

#+begin_src elisp :results none
(defadvice! advtest-after-1 (&rest args)
"After test 1"
:after #'some-fun
(message "after-1 args: %s" (string-join args " ")))
#+end_src

*** Before 2

#+begin_src elisp :results none
(defadvice! advtest-before-2 (&rest args)
"Before test 2"
:before #'some-fun
(message "before-2 args: %s" (string-join args " ")))
#+end_src

** Test Advice

#+begin_src elisp :tangle no
(some-fun "one" "two")
#+end_src

#+RESULTS:

** Debugging & Reset

:PROPERTIES:
:header-args: :tangle no
:END:

#+begin_src elisp
(describe-function #'some-fun)
#+end_src

#+RESULTS:
: some-fun is a Lisp function.
:
: (some-fun &rest ARGS)
:
: Not documented.

#+begin_src elisp
(defun advice-unadvice (sym)
"Remove all advices from symbol SYM."
(interactive "aFunction symbol: ")
(advice-mapc (lambda (advice _props) (advice-remove sym advice)) sym))
#+end_src

#+RESULTS:
: advice-unadvice

#+begin_src elisp
(advice-unadvice #'some-fun)
#+end_src

#+RESULTS:

** Results

1. Advice is additive, supports multiple of same type
2. Advice fires last-added-runs-first
3. Types of advice processed at specific times: before and before-while are
processed together before calling the original function
4. In the case of before-while, the before and after advice that added after the
=before-while= advice did run. The =before= advice added earlier will not run if
=before-while= returns ~nil~.
a. Does this mean that if before-while returns false it short-circuits the
remaining advice defined before it, which would run after =before-while=?
Loading

0 comments on commit 2f686a3

Please sign in to comment.