bm* files, shortcuts and alias to .config

This commit is contained in:
Luke Smith 2019-02-19 13:13:05 -05:00
parent c80905abce
commit 7b74f9d8c2
8 changed files with 15 additions and 15 deletions

View file

@ -4,5 +4,5 @@ shopt -s autocd #Allows you to cd into directory merely by typing the directory
HISTSIZE= HISTFILESIZE= # Infinite history. HISTSIZE= HISTFILESIZE= # Infinite history.
export PS1="\[$(tput bold)\]\[$(tput setaf 1)\][\[$(tput setaf 3)\]\u\[$(tput setaf 2)\]@\[$(tput setaf 4)\]\h \[$(tput setaf 5)\]\W\[$(tput setaf 1)\]]\[$(tput setaf 7)\]\\$ \[$(tput sgr0)\]" export PS1="\[$(tput bold)\]\[$(tput setaf 1)\][\[$(tput setaf 3)\]\u\[$(tput setaf 2)\]@\[$(tput setaf 4)\]\h \[$(tput setaf 5)\]\W\[$(tput setaf 1)\]]\[$(tput setaf 7)\]\\$ \[$(tput sgr0)\]"
[ -f "$HOME/.shortcuts" ] && source "$HOME/.shortcuts" # Load shortcut aliases [ -f "$HOME/.config/shortcutrc" ] && source "$HOME/.config/shortcutrc" # Load shortcut aliases
[ -f "$HOME/.aliasrc" ] && source "$HOME/.aliasrc" [ -f "$HOME/.config/aliasrc" ] && source "$HOME/.config/aliasrc"

View file

@ -19,7 +19,7 @@ alias ka="killall" \
yt="youtube-dl --add-metadata -i -o '%(upload_date)s-%(title)s.%(ext)s'" \ yt="youtube-dl --add-metadata -i -o '%(upload_date)s-%(title)s.%(ext)s'" \
yta="yt -x -f bestaudio/best" \ yta="yt -x -f bestaudio/best" \
YT="youtube-viewer" \ YT="youtube-viewer" \
ref="shortcuts >/dev/null; source ~/.shortcuts" \ ref="shortcuts >/dev/null; source ~/.config/shortcutrc" \
upc="sudo pacman -Syu; pkill -RTMIN+8 i3blocks" \ upc="sudo pacman -Syu; pkill -RTMIN+8 i3blocks" \
lsp="pacman -Qett --color=always | less" \ lsp="pacman -Qett --color=always | less" \
ffmpeg="ffmpeg -hide_banner" ffmpeg="ffmpeg -hide_banner"

View file

@ -1,5 +1,5 @@
" vim: filetype=vim " vim: filetype=vim
source ~/.vifmshortcuts source ~/.config/vifm/vifmshortcuts
map <C-h> <C-w>h map <C-h> <C-w>h
map <C-j> <C-w>j map <C-j> <C-w>j

View file

@ -305,7 +305,7 @@ buttons, screen brightness, email, web browsing buttons, etc.) to what you
would expect. would expect.
.HEADING 1 "Bookmarking Files and Directories" .HEADING 1 "Bookmarking Files and Directories"
.PP .PP
Note the files \f(CW~/.bmdirs\fP and \f(CW~/.bmfiles\fP. Note the files \f(CW~/.config/bmdirs\fP and \f(CW~/.config/bmfiles\fP.
These files hold bookmarked directories and files respectively, along with shortcut keys to their left. These files hold bookmarked directories and files respectively, along with shortcut keys to their left.
LARBS, specfically the \f(CWshortcuts\fP script, will automatically read these files and autogenerate aliases and shortcuts for bash/zsh and ranger from them. LARBS, specfically the \f(CWshortcuts\fP script, will automatically read these files and autogenerate aliases and shortcuts for bash/zsh and ranger from them.
.PP .PP
@ -326,11 +326,11 @@ Create a new tab in \f(CW~/Documents\fP
\f(CWYd\fP \(en \f(CWYd\fP \(en
Copy/yank (cp) a copy of the selected file(s) to \f(CWDocuments\fP Copy/yank (cp) a copy of the selected file(s) to \f(CWDocuments\fP
.LIST OFF .LIST OFF
Shortcuts like these are generated for all key sequence/directory pairs in \f(CW~/.bmdirs\fP. Shortcuts like these are generated for all key sequence/directory pairs in \f(CW~/.config/bmdirs\fP.
Additionally, you may also add editable files to \f(CW~/.bmfiles\fP. Additionally, you may also add editable files to \f(CW~/.config/bmfiles\fP.
Each key sequence you pair with a file will become an alias to edit it in either bash or ranger. Each key sequence you pair with a file will become an alias to edit it in either bash or ranger.
.PP .PP
Whenever you edit and save one of the bookmark files, vim will automatically rerun the shortcut script, thus uupdating the shortcuts that will be used in new instances of bash and ranger. Whenever you edit and save one of the bookmark files, vim will automatically rerun the shortcut script, thus updating the shortcuts that will be used in new instances of bash and ranger.
It just werks. It just werks.
Note that it is your responsibility to ensure that none of the bindings you add conflict with another necessary function or command. Note that it is your responsibility to ensure that none of the bindings you add conflict with another necessary function or command.
.HEADING 1 "Frequently Asked Questions (FAQs)" .HEADING 1 "Frequently Asked Questions (FAQs)"
@ -366,7 +366,7 @@ Install \f(CWneomutt\fP, \f(CWofflineimap\fP and \f(CWmsmtp\fP if you haven't al
Create a GPG private/public key pair if you haven't already. Type \f(CWmod+shift+e\fP and you can select a tutorial for how to do this. Create a GPG private/public key pair if you haven't already. Type \f(CWmod+shift+e\fP and you can select a tutorial for how to do this.
.ITEM .ITEM
Download the mutt-wizard repository to the mutt config directory: Download the mutt-wizard repository to the mutt config directory:
\f(CWgit clone https://github.com/lukesmithxyz/mutt-wizard ~/.config/mutt\fP \f(CWgit clone https://github.com/lukesmithxyz/mutt-wizard ~/.config/mutt\fP.
\fBREAD THE README.\fP \fBREAD THE README.\fP
.PP .PP
.ITEM .ITEM

View file

@ -54,7 +54,7 @@ in vim or another program.
- `opout` -- "Open output", opens the corresponding `.pdf` file if run on a `.md`, `.tex` or `.rmd` file, or if given an `.html` file, will open it in the browser. Bound to `<leader>p` in my vim config to reveal typical output. - `opout` -- "Open output", opens the corresponding `.pdf` file if run on a `.md`, `.tex` or `.rmd` file, or if given an `.html` file, will open it in the browser. Bound to `<leader>p` in my vim config to reveal typical output.
- `pauseallmpv` -- Pauses all mpv instances by sending the `,` key to each. Used by several scripts, but can be used alone as well. It will not pause an audio only mpv instance. If you know how to add a hack to do this, feel free to PR it or email me an addition. - `pauseallmpv` -- Pauses all mpv instances by sending the `,` key to each. Used by several scripts, but can be used alone as well. It will not pause an audio only mpv instance. If you know how to add a hack to do this, feel free to PR it or email me an addition.
- `remaps` -- Remaps capslock to escape when pressed and super/mod when held. Maps the menu key to super as well. Runs the US international keyboard setup. If you want another keyboard setup, edit this fine. - `remaps` -- Remaps capslock to escape when pressed and super/mod when held. Maps the menu key to super as well. Runs the US international keyboard setup. If you want another keyboard setup, edit this fine.
- `shortcuts` -- For updating bash and ranger shortcuts. Reads `~/.key_directories` and `~/.key_files` for pairs of keypresses and directories and files, then autoproduces bash aliases and ranger shortcuts for them which output to `~/.shortcuts` and `~/.config/ranger/shortcuts.conf` respectively. These are read automatically by my bash and ranger configs. You don't have to run this script manually though, as it's run by vim whenever you edit one of the `~/.key_*` files. - `shortcuts` -- For updating bash and ranger shortcuts. Reads `~/.config/bmdirs` and `~/.config/bmfiles` for pairs of keypresses and directories and files, then autoproduces bash aliases and ranger shortcuts for them which output to `~/.config/shortcutrc` and `~/.config/ranger/shortcuts.conf` respectively. These are read automatically by my bash and ranger configs. You don't have to run this script manually though, as it's run by vim whenever you edit one of the `~/.bm*` files.
- `speedvid` -- Speed up a given video file (`$1`) by a given ammount (`$2`). - `speedvid` -- Speed up a given video file (`$1`) by a given ammount (`$2`).
- `tpb` -- Search Pirate Bay for the certain search terms given as arguments. - `tpb` -- Search Pirate Bay for the certain search terms given as arguments.
- `texclear` -- Remove all `.tex` related build files. This is run by my vim when I stop editing any `.tex` file. - `texclear` -- Remove all `.tex` related build files. This is run by my vim when I stop editing any `.tex` file.

View file

@ -1,10 +1,10 @@
#!/bin/bash #!/bin/bash
# Output locations. Unactivated progs should go to /dev/null. # Output locations. Unactivated progs should go to /dev/null.
shell_shortcuts="$HOME/.shortcuts" shell_shortcuts="$HOME/.config/shortcutrc"
ranger_shortcuts="$HOME/.config/ranger/shortcuts.conf" ranger_shortcuts="$HOME/.config/ranger/shortcuts.conf"
qute_shortcuts="/dev/null" qute_shortcuts="/dev/null"
fish_shortcuts="$HOME/.config/fish/shortcuts.fish" fish_shortcuts="/dev/null"
vifm_shortcuts="$HOME/.vifmshortcuts" vifm_shortcuts="$HOME/.config/vifm/vifmshortcuts"
# Remove, prepare files # Remove, prepare files
rm -f "$ranger_shortcuts" "$qute_shortcuts" 2>/dev/null rm -f "$ranger_shortcuts" "$qute_shortcuts" 2>/dev/null
@ -13,14 +13,14 @@ printf "# vim: filetype=sh\\nalias " > "$shell_shortcuts"
printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts" printf "\" vim: filetype=vim\\n" > "$vifm_shortcuts"
# Format the `bmdirs` file in the correct syntax and sent it to all three configs. # Format the `bmdirs` file in the correct syntax and sent it to all three configs.
sed "s/\s*#.*$//;/^\s*$/d" "$HOME/.bmdirs" | tee >(awk '{print $1"=\"cd "$2" && ls -a\" \\"}' >> "$shell_shortcuts") \ sed "s/\s*#.*$//;/^\s*$/d" "$HOME/.config/bmdirs" | tee >(awk '{print $1"=\"cd "$2" && ls -a\" \\"}' >> "$shell_shortcuts") \
>(awk '{print "abbr", $1, "\"cd " $2 "; and ls -a\""}' >> "$fish_shortcuts") \ >(awk '{print "abbr", $1, "\"cd " $2 "; and ls -a\""}' >> "$fish_shortcuts") \
>(awk '{print "map g" $1, ":cd", $2 "<CR>\nmap t" $1, "<tab>:cd", $2 "<CR><tab>\nmap M" $1, "<tab>:cd", $2 "<CR><tab>:mo<CR>\nmap Y" $1, "<tab>:cd", $2 "<CR><tab>:co<CR>" }' >> "$vifm_shortcuts") \ >(awk '{print "map g" $1, ":cd", $2 "<CR>\nmap t" $1, "<tab>:cd", $2 "<CR><tab>\nmap M" $1, "<tab>:cd", $2 "<CR><tab>:mo<CR>\nmap Y" $1, "<tab>:cd", $2 "<CR><tab>:co<CR>" }' >> "$vifm_shortcuts") \
>(awk '{print "config.bind(\";"$1"\", \"set downloads.location.directory "$2" ;; hint links download\")"}' >> "$qute_shortcuts") \ >(awk '{print "config.bind(\";"$1"\", \"set downloads.location.directory "$2" ;; hint links download\")"}' >> "$qute_shortcuts") \
| awk '{print "map g"$1" cd "$2"\nmap t"$1" tab_new "$2"\nmap m"$1" shell mv -v %s "$2"\nmap Y"$1" shell cp -rv %s "$2}' >> "$ranger_shortcuts" | awk '{print "map g"$1" cd "$2"\nmap t"$1" tab_new "$2"\nmap m"$1" shell mv -v %s "$2"\nmap Y"$1" shell cp -rv %s "$2}' >> "$ranger_shortcuts"
# Format the `configs` file in the correct syntax and sent it to both configs. # Format the `configs` file in the correct syntax and sent it to both configs.
sed "s/\s*#.*$//;/^\s*$/d" "$HOME/.bmfiles" | tee >(awk '{print $1"=\"$EDITOR "$2"\" \\"}' >> "$shell_shortcuts") \ sed "s/\s*#.*$//;/^\s*$/d" "$HOME/.config/bmfiles" | tee >(awk '{print $1"=\"$EDITOR "$2"\" \\"}' >> "$shell_shortcuts") \
>(awk '{print "abbr", $1, "\"$EDITOR "$2"\""}' >> "$fish_shortcuts") \ >(awk '{print "abbr", $1, "\"$EDITOR "$2"\""}' >> "$fish_shortcuts") \
>(awk '{print "map", $1, ":e", $2 "<CR>" }' >> "$vifm_shortcuts") \ >(awk '{print "map", $1, ":e", $2 "<CR>" }' >> "$vifm_shortcuts") \
| awk '{print "map "$1" shell $EDITOR "$2}' >> "$ranger_shortcuts" | awk '{print "map "$1" shell $EDITOR "$2}' >> "$ranger_shortcuts"