Compare commits
3 commits
3f3febddf3
...
05e0fbae40
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05e0fbae40 | ||
|
|
fe720dfddf | ||
|
|
f386570dc1 |
3 changed files with 144 additions and 17 deletions
|
|
@ -1035,6 +1035,7 @@ And some shortcut keys from the =general= project:
|
|||
"<tab> <tab>" '("switch" . tab-switch)
|
||||
"<tab> p" '("new project" . ha-tab-bar-new-project)
|
||||
"<tab> n" '("new space" . ha-tab-bar-new)
|
||||
"<tab> u" '("update names" . ha-tab-bar-update-names)
|
||||
"<tab> d" '("delete space" . ha-tab-bar-delete))
|
||||
|
||||
(global-set-key (kbd "s-C-t") 'ha-tab-bar-new)
|
||||
|
|
@ -1050,6 +1051,7 @@ I want to quickly jump, by the number shown on the tab, to that grouping. The fo
|
|||
(defun ha-tab-bar-update-names ()
|
||||
"Create normal-mode keybindings for the tab groupings.
|
||||
This creates `SPC TAB 1' to jump to the first tab, etc."
|
||||
(interactive)
|
||||
;; Remove all previously created keybindings:
|
||||
(ignore-errors
|
||||
(dolist (indx (number-sequence 1 9))
|
||||
|
|
@ -1108,14 +1110,14 @@ Also, as [[https://www.bytedude.com/gpg-in-emacs/][bytedude]] mentions, I need t
|
|||
|
||||
:config
|
||||
(setenv "GPG_AGENT_INFO" nil)
|
||||
(epa-file-enable))
|
||||
(ignore-error (epa-file-enable)))
|
||||
#+end_src
|
||||
|
||||
Since I already (at this point in my file) have Org installed and running, the following code configures the encryption of certain header sections (see [[https://orgmode.org/worg/org-tutorials/encrypting-files.html][this tutorial]]). Headers with a =:crypt:tag (see =org-crypt-tag-matcher= to change it) will be encrypted.
|
||||
|
||||
To temporarily read an encrypted part, and call =M-x org-decrypt-entry= when the cursor is inside that section. Saving the file, will re-encrypt it.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
#+begin_src emacs-lisp :tangle no
|
||||
(use-package org
|
||||
:config
|
||||
(require 'org-crypt)
|
||||
|
|
|
|||
|
|
@ -145,12 +145,10 @@ The [[https://github.com/emacs-dashboard/emacs-dashboard][emacs-dashboard]] proj
|
|||
(string-replace "\n" "" smaller-version)))
|
||||
|
||||
(setq dashboard-startup-banner
|
||||
(if (ha-emacs-for-work?)
|
||||
"~/src/hamacs/support/teal-sticker.png"
|
||||
;; Choose a random image from my collection of startup images:
|
||||
(thread-first "~/src/hamacs/support/dashboard"
|
||||
(directory-files t (rx ".png"))
|
||||
(seq-random-elt))))
|
||||
;; Choose a random image from my collection of startup images:
|
||||
(thread-first "~/src/hamacs/support/dashboard"
|
||||
(directory-files t (rx ".png"))
|
||||
(seq-random-elt)))
|
||||
|
||||
(setq dashboard-banner-logo-title
|
||||
(format "Emacs %s — %s"
|
||||
|
|
|
|||
145
zshell.org
145
zshell.org
|
|
@ -21,6 +21,7 @@ Regardless, I keep my shell configuration conspicuously light.
|
|||
Let’s create the following files, and the configuration below will be injected into one of them:
|
||||
|
||||
- =~/.zshenv= :: Usually run for every zsh
|
||||
- =~/.zprofile= :: Usually run for login shells (this includes the system-wide =/etc/zprofile=)
|
||||
- =~/.zshrc= :: Run for interactive shells … default file when tangling
|
||||
- =~/.zlogin= :: Run for login shells … seems to run as often as =.zshrc=
|
||||
|
||||
|
|
@ -43,8 +44,24 @@ Let’s create the following files, and the configuration below will be injected
|
|||
* Path
|
||||
The all important =PATH= environment variable, needs my special =bin= directory.
|
||||
|
||||
#+BEGIN_SRC zsh :export ~/.zshenv
|
||||
export PATH=$HOME/bin:/usr/local/bin:$PATH
|
||||
#+BEGIN_SRC zsh :tangle ~/.zshenv
|
||||
export PATH=$HOME/bin:$HOME/.local/bin:$PATH
|
||||
#+END_SRC
|
||||
|
||||
My Apple Macbook screws up my =PATH= by having =/etc/profile= (that runs after my =~/.zshenv=) /pre-pend/ system directories like =/bin= and =/usr/bin= /after/ I’ve set up my =PATH= environment variable. So, in my own =.zprofile= (which runs afterwards), I reverse it using the lovely =tac= program:
|
||||
|
||||
#+BEGIN_SRC sh :tangle ~/.zprofile :shebang #!/bin/zsh
|
||||
if [[ -f /etc/zprofile ]]
|
||||
then
|
||||
# Reverse the PATH variable
|
||||
reversed_path=$(echo $PATH | tr ':' '\n' | tac | tr '\n' ':')
|
||||
|
||||
# Reset the path after removing the trailing colon:
|
||||
export PATH=${reversed_path%:}
|
||||
|
||||
# Output the reversed PATH
|
||||
# echo "Reversed PATH: $reversed_path"
|
||||
fi
|
||||
#+END_SRC
|
||||
|
||||
* Options
|
||||
|
|
@ -94,7 +111,10 @@ setopt MENU_COMPLETE
|
|||
When using Homebrew on a Mac, we need to add its =PATH=:
|
||||
|
||||
#+BEGIN_SRC zsh :tangle ~/.zshenv
|
||||
eval $(/opt/homebrew/bin/brew shellenv zsh)
|
||||
if [[ -d /opt/homebrew ]]
|
||||
then
|
||||
eval $(/opt/homebrew/bin/brew shellenv zsh)
|
||||
fi
|
||||
#+END_SRC
|
||||
|
||||
This adds the following environment variables, along with expanding the =PATH=.
|
||||
|
|
@ -203,13 +223,16 @@ Anything special for particular languages.
|
|||
*** Python
|
||||
Not overly impressed, for to get =pyenv= to work, we need to add this code:
|
||||
|
||||
#+BEGIN_SRC zsh
|
||||
#+BEGIN_SRC zsh :tangle ~/.zshenv
|
||||
export PYENV_ROOT="$HOME/.pyenv"
|
||||
export PATH="$PYENV_ROOT/bin:$PATH"
|
||||
|
||||
eval "$(pyenv init --path)"
|
||||
#+END_SRC
|
||||
|
||||
And call the =pyenv= to initialize it:
|
||||
|
||||
#+BEGIN_SRC zsh
|
||||
# eval "$(pyenv init --path)"
|
||||
#+END_SRC
|
||||
|
||||
** Plugins
|
||||
Configure the plugins, making sure to not use =git=, as the aliases are a pain to remember when I already have a superior Git interface in Emacs.
|
||||
|
|
@ -228,7 +251,7 @@ Configure the plugins, making sure to not use =git=, as the aliases are a pain t
|
|||
To have a plugin /install/, add its name to the =plugins= array variable /before/ we =source= the OMZ script:
|
||||
|
||||
#+begin_SRC zsh
|
||||
plugins=(colorize direnv gnu-utils iterm2 macos pyenv virtualenv zbell zsh-syntax-highlighting)
|
||||
plugins=(colorize direnv gnu-utils iterm2 macos virtualenv zbell zsh-syntax-highlighting)
|
||||
#+END_SRC
|
||||
|
||||
Notice the =iterm2= plugin as well as the =macos= plugins that would be nice to figure out how to make them optionally added (although I believe they check themselves).
|
||||
|
|
@ -242,6 +265,26 @@ The trick is to install some base-level plugins, and then, on my work computer,
|
|||
fi
|
||||
#+END_SRC
|
||||
|
||||
I would like to have a history /per project/, so that when I start a session for a project, my history has where I left off /for that project/ and not everything. I guess I’m not the only one who [[https://github.com/ivan-cukic/zsh-per-project-history][thought of this idea]]. We first need to add his plugin to the list of supplied plugins, so do this once:
|
||||
|
||||
#+BEGIN_SRC zsh :tangle no
|
||||
git clone https://github.com/ivan-cukic/zsh-per-project-history ~/.oh-my-zsh/plugins/per-project-history
|
||||
#+END_SRC
|
||||
|
||||
His idea is to have a variable array, =PER_PROJECT_HISTORY_TAGS= that lists files that should identify the start of a project, and while his default seems sufficient, I am not found of the spammy message, so:
|
||||
|
||||
#+BEGIN_SRC zsh
|
||||
declare -a PER_PROJECT_HISTORY_TAGS
|
||||
export PER_PROJECT_HISTORY_TAGS=(.envrc .git)
|
||||
declare -r PER_PROJECT_HISTORY_TAGS
|
||||
#+END_SRC
|
||||
|
||||
we just need to add =per-history= to the list of plugins:
|
||||
|
||||
#+BEGIN_SRC zsh
|
||||
plugins+=(per-project-history)
|
||||
#+END_SRC
|
||||
|
||||
Now that I’ve filled in the =plugins= variable, load OMZ and the plugins:
|
||||
|
||||
#+BEGIN_SRC zsh
|
||||
|
|
@ -274,6 +317,80 @@ Oh use the absolute /over-the-top/ bling associated with Oh My Zshell’s /theme
|
|||
#+END_SRC
|
||||
|
||||
I keep the prompt simple since all of the /gunk/ we typically put in a prompt is better placed in [[https://iterm2.com/documentation-status-bar.html][iTerm2's Status Bar]].
|
||||
* Homebrew
|
||||
When using Homebrew on a Mac, we need to add its =PATH= and environment variables. This is typically done by running the command:
|
||||
|
||||
#+BEGIN_SRC zsh :tangle no
|
||||
eval $(brew shellenv zsh)
|
||||
#+END_SRC
|
||||
|
||||
We want to add the path and environment variables into the =~/.zshenv= file, but this file should not contain any logic or code. So, let’s run the command /from Emacs/, and store the results in the file.
|
||||
|
||||
The full script to run is:
|
||||
|
||||
#+BEGIN_SRC zsh :tangle no :results file :file ~/.zshenv_brew
|
||||
echo '# -*- mode:sh; -*-'
|
||||
if which brew >/dev/null
|
||||
then
|
||||
if [[ -d /opt/homebrew ]]
|
||||
then
|
||||
/opt/homebrew/bin/brew shellenv zsh
|
||||
else
|
||||
brew shellenv zsh
|
||||
fi
|
||||
fi
|
||||
#+END_SRC
|
||||
|
||||
Seems that if I want the GNU versions (instead of the old ones supplied by Apple), I have to do it myself:
|
||||
|
||||
#+BEGIN_SRC zsh :tangle no :results file :file ~/.zshenv_gnu
|
||||
echo '# -*- mode:sh; -*-'
|
||||
if which brew >/dev/null
|
||||
then
|
||||
for PKG in binutils gettext unzip openssl texinfo mysql-client openjdk
|
||||
do
|
||||
if PKG_INSTALL=$(brew --prefix $PKG)
|
||||
then
|
||||
echo export PATH=$PKG_INSTALL/bin:'$PATH'
|
||||
fi
|
||||
done
|
||||
|
||||
for PKG in coreutils ed findutils gnu-indent gnu-sed gnu-tar grep make
|
||||
do
|
||||
if PKG_INSTALL=$(brew --prefix $PKG)
|
||||
then
|
||||
echo export PATH=$PKG_INSTALL/libexec/gnubin:'$PATH'
|
||||
fi
|
||||
done
|
||||
fi
|
||||
#+END_SRC
|
||||
|
||||
And linking all the GNU libraries:
|
||||
|
||||
#+BEGIN_SRC zsh :tangle no :results file :file ~/.zshenv_lib
|
||||
echo '# -*- mode:sh; -*-'
|
||||
|
||||
if which brew >/dev/null
|
||||
then
|
||||
for PKG in readline openssl xz binutils ctags libgccjit imagemagick
|
||||
do
|
||||
if PKG_INSTALL=$(brew --prefix $PKG)
|
||||
echo export LDFLAGS=\"-L$PKG_INSTALL/lib '$LDFLAGS'\"
|
||||
echo export CPPFLAGS=\"-I$PKG_INSTALL/include '$CPPFLAGS'\"
|
||||
done
|
||||
echo export LDFLAGS=\"'$LDFLAGS' -L$(brew --prefix)/lib\"
|
||||
echo export CPPFLAGS=\"'$CPPFLAGS' -I$(brew --prefix)/include\"
|
||||
fi
|
||||
#+END_SRC
|
||||
|
||||
And pull in all the results into the =~/.zshenv= file (why yes, this could be inlined):
|
||||
|
||||
#+BEGIN_SRC zsh :tangle ~/.zshenv
|
||||
[[ -f $HOME/.zshenv_brew ]] && source $HOME/.zshenv_brew
|
||||
[[ -f $HOME/.zshenv_gnu ]] && source $HOME/.zshenv_gnu
|
||||
[[ -f $HOME/.zshenv_lib ]] && source $HOME/.zshenv_lib
|
||||
#+END_SRC
|
||||
|
||||
* iTerm2
|
||||
On Mac systems, I like the [[https://www.iterm2.com/][iTerm2 application]], and we can enable [[https://iterm2.com/documentation-shell-integration.html][shell integration]], either via the old school way, or just rely on [[https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/iterm2][the /plugin/ ]]above:
|
||||
|
||||
|
|
@ -324,7 +441,9 @@ While it /should/ figure out (as Emacs keybindings are the default), this is how
|
|||
bindkey -e
|
||||
#+END_SRC
|
||||
|
||||
Where be the =emacsclient=, and how should we call it?
|
||||
Where be the =emacsclient=? It should, at this point, be in our path.
|
||||
|
||||
And how should we call it?
|
||||
|
||||
#+BEGIN_SRC zsh :tangle ~/.zshenv
|
||||
export EMACS="emacsclient --socket-name personal"
|
||||
|
|
@ -407,7 +526,7 @@ For instance:
|
|||
Assuming we’ve installed [[https://github.com/lsd-rs/lsd][lsd]], let’s make an alias for it:
|
||||
|
||||
#+BEGIN_SRC zsh
|
||||
if whence lsd >/dev/null
|
||||
if which lsd >/dev/null
|
||||
then
|
||||
alias ls=lsd
|
||||
fi
|
||||
|
|
@ -431,6 +550,13 @@ And an abstraction for transitory endpoints over SSH:
|
|||
alias ossh="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o loglevel=ERROR"
|
||||
#+END_SRC
|
||||
|
||||
And other ones that I use:
|
||||
|
||||
#+BEGIN_SRC zsh
|
||||
alias os=openstack
|
||||
alias k=kubectl
|
||||
#+END_SRC
|
||||
|
||||
* Final Message
|
||||
For sensitive work-related environment variables, store them elsewhere, and load them:
|
||||
|
||||
|
|
@ -446,6 +572,7 @@ To let us know we read the =~/.zshrc= file:
|
|||
|
||||
#+description: A literate programming file for configuring Zshell.
|
||||
#+property: header-args:zsh :tangle ~/.zshrc
|
||||
#+property: header-args:sh :tangle no
|
||||
#+property: header-args :results none :eval no-export :comments no mkdirp yes
|
||||
#+options: num:nil toc:t todo:nil tasks:nil tags:nil date:nil
|
||||
#+options: skip:nil author:nil email:nil creator:nil timestamp:nil
|
||||
|
|
|
|||
Loading…
Reference in a new issue