abbreviations.fish 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. ##############################
  2. # make things a tad bit quicker.
  3. # NOTE: abbr's will default to universal scope, ie. conditional logic will not "work" for different systems, ie. macOS and Linux, thus use the `-g` flag with `abbr` to make global scope which is NOT universal thus making conditional logic work.
  4. #
  5. ###
  6. # NOTE: ❗️ abbr's DO NOT support spaces
  7. # NOTE: adding a new `abbr` requires a reload, ie. `exec fish` for every running fish shell instance.
  8. # NOTE: double quotes ie. `"$dots"` will be expand env var after pressing `space`, whereas single quotes expands after pressing `enter`
  9. ###
  10. ##############################
  11. # Added the below abbreviations because I'm really tired of typing the below commands.
  12. ##
  13. abbr -ag fishr 'exec fish'
  14. abbr -ag fr 'exec fish'
  15. #
  16. # NOTE: OS specific fish abbreviations are defined below
  17. abbr -ag clearf 'cat /dev/null >' # add name of `file` and alias
  18. abbr -ag clrf 'cat /dev/null >' # add name of `file` and alias
  19. #############################
  20. # reminders
  21. ##
  22. abbr -ag ex.ls.top.10.big.files 'echo "du -h . | sort -n -r | head -n 10" | pbcopy'
  23. # TODO: format this cmd more elegantly, spread cmd and link across multiple lines
  24. abbr -ag ex.ffmpeg.enc.specific.size 'echo -e "https://askubuntu.com/a/1028051/134740\n" | pbcopy; echo -e "([FINAL_SIZE] MiB * 8192 [converts MiB to kBit]) / [TOTAL_SECONDS] = ~XXX kBit/s total bitrate"\n; echo -e "XXX - 128 kBit/s (desired audio bitrate) = YYY kBit/s video bitrate"\n;'
  25. abbr -ag ex.find.mv.files.pwd 'echo find . -type f \\( -name "*.mkv" -o -name "*.srt" -o -name "*.txt" -o -name "*.mp4" \\) -exec mv {} . \\;'
  26. abbr -ag ex.ls.broken.links 'echo "find . -type l -exec file {} \; | grep broken" | pbcopy'
  27. abbr -ag ex.git.undo.unstaged.changes 'echo "git checkout /path/to/file see https://stackoverflow.com/a/52943227/708807"'
  28. #############################
  29. # shell specific
  30. ##
  31. abbr -ag cd- 'cd -'
  32. abbr -ag cp "cp -iv"
  33. # double quote example
  34. abbr -ag dots "cd $dots"
  35. # single quote example
  36. abbr -ag dotss 'cd $dots'
  37. abbr -ag dotsw "cd $dots/.wiki"
  38. abbr -ag rmd "rm -rf"
  39. abbr -ag rm.all.but "echo 'ls --hide=\*{.EXT,.EXT2,.EXT3} | xargs rm'"
  40. #############################
  41. # /os/archlinux
  42. ##
  43. abbr -ag dotsarch "cd $dots/jobs/Linux/arch"
  44. abbr -ag dots.arch "cd $dots/jobs/Linux/arch"
  45. # get weather
  46. abbr -ag get-weather "curl wttr.in"
  47. abbr -ag getweather "curl wttr.in"
  48. # music
  49. abbr -ag kntusong "open https://www.kntu.com/last-7-days-of-music-on-kntu/"
  50. abbr -ag kuntsong "open https://www.kntu.com/last-7-days-of-music-on-kntu/"
  51. abbr -ag ksong "open https://www.kntu.com/last-7-days-of-music-on-kntu/"
  52. #############################
  53. # networking related, ie. wget, curl, etc etc
  54. ##
  55. abbr -ag curll 'curl -O -L -C -' # the equivalent of the std wget cmd
  56. abbr -ag crl 'curl -O -L -C -'
  57. abbr -ag curlget 'curl -O -L -C -'
  58. abbr -ag cget 'curl -O -L -C -'
  59. #############################
  60. # ruby tooling
  61. ##
  62. if [ -d "$HOME/.rvm" ]
  63. abbr -ag be "bundle exec"
  64. end
  65. #############################
  66. # python tooling
  67. ##
  68. # NO SPACES in abbr's
  69. # abbr -ag 'pip outdated' 'pip list --outdated'
  70. #############################
  71. # rsync
  72. #
  73. # rysnc -ah --progress [source] [destination]
  74. # -a = preserve file permssions
  75. # -h = human readable output
  76. ##
  77. abbr -ag cpv "rsync -a --no-o --no-g -h --info=progress2 -P" # useful for network mnts
  78. abbr -ag cpvr "rsync -a --no-o --no-g -h --info=progress2 --append" # resume transfer
  79. abbr -ag rm "rm -iv"
  80. abbr -ag mv "mv -iv"
  81. abbr -ag df "df -h"
  82. abbr -ag du "du -h"
  83. abbr -ag today "date +'%A, %B %-d, %Y'"
  84. abbr -ag ll "ls -1" # same as below
  85. abbr -ag l1 "ls -1" # only filenames, nothing else, single column
  86. abbr -ag lr "ls -lrth" # show newest file first, ie. last line of output
  87. #
  88. abbr -ag ljd "ls -d ./*/" # only show directories
  89. abbr -ag l.just.dirs "ls -d ./*/" # only show dirs
  90. abbr -ag ls.just.dirs "ls -d ./*/" # only show dirs
  91. #
  92. abbr -ag ls.count.files "ls -p | /usr/bin/grep -v / | wc -l" # ignores hidden files
  93. abbr -ag ls.count.dirs "ls -p | /usr/bin/grep / | wc -l" # ignores hidden dirs
  94. ################
  95. # funny abbreviations
  96. ##
  97. abbr -ag hunh "emoji --hunh"
  98. abbr -ag tf "emoji --table-flip"
  99. abbr -ag woot "emoji --yay"
  100. ################
  101. # git abbreviations
  102. ##
  103. # NOTE: i don't think it's possible to define a `gs` alias / abbr in `~/.gitconfig`
  104. abbr -ag gs "git status"
  105. abbr -ag gd 'git diff --stat'
  106. abbr -ag ga 'git add --all'
  107. abbr -ag gitc 'git commit -m'
  108. abbr -ag gac 'git commit -am'
  109. abbr -ag gqc 'git random' # SEE: `gitconfg`
  110. abbr -ag gp 'git push --quiet'
  111. abbr -ag gpl 'git pull'
  112. abbr -ag gru 'git remote -v update'
  113. abbr -ag gco 'git checkout'
  114. abbr -ag gsmru 'git smrupdate'
  115. abbr -ag git-ls-aliases 'git aliases'
  116. abbr -ag git.aliases 'git aliases'
  117. abbr -ag gf 'git fresh'
  118. abbr -ag git.is.shallow 'git rev-parse --is-shallow-repository'
  119. abbr -ag git.shallow\? 'git rev-parse --is-shallow-repository'
  120. abbr -ag git.ls.commits 'git rev-list --count HEAD'
  121. abbr -ag git.count.commits 'git rev-list --count HEAD'
  122. abbr -ag git.b.dates 'git branch --sort=creatordate --sort=committername --format "%(align:20) %(creatordate:relative) %(end) %(align:25) %(committername) %(end) %(refname:lstrip=-1)"'
  123. ################
  124. # personal fish functions
  125. ##
  126. abbr -ag pp 'path_pretty' # `path_pretty` fish function
  127. abbr -ag ppr "path_pretty_redux"
  128. abbr -ag path-add 'path_add' # fish func
  129. abbr -ag path-remove 'path_remove' # fish func
  130. abbr -ag path-rm 'path_remove'
  131. abbr -ag pthrm 'path_remove'
  132. abbr -ag prm 'path_remove'
  133. ################
  134. # alacritty
  135. ##
  136. # NOTE creating al windows on macOS with a retina screen requires 2x the dimensions
  137. # NOTE it appears alacritty v0.2.5 manages window dimensions differently than v0.2.{0,1}
  138. #
  139. # # NO WORK, al ≥ v0.7x no longer uses the `-d [NUM] [NUM]` flag
  140. # abbr -ag al-win-retina-irc "alacritty -d 138 39 &; disown"
  141. # abbr -ag al-win-retina-split "alacritty -d 56 15 &; disown"
  142. # abbr -ag al-win-4k-irc "alacritty -d 93 22 &; disown"
  143. # abbr -ag al-win-4k-cast "alacritty -d 60 14 &; disown"
  144. # abbr -ag al-win-ipad2-irc "alacritty -d 210 60 &; disown"
  145. # abbr -ag al-win-u28e590d-irc "alacritty -d 192 45 &; disown" # ext samsung monitor
  146. # abbr -ag al-win-4k-samsung "alacritty -d 192 45 &; disown" # NO WORK, al ≥ v0.7x
  147. #
  148. # abbr -ag alwin4ksam "alacritty -d 192 45 &; disown"
  149. ################
  150. # SSL encryption: useful abbreviations for working with NOC lists 💣
  151. # `openssl aes-256-cbc -d -a -in secrets.txt.enc -out secrets.txt.new`
  152. ##
  153. if type -q openssl
  154. #/path/to/file #/path/to/file.dat
  155. abbr -ag encrypt "openssl enc -aes-256-cbc -in"
  156. #/path/to/file.dat -out #/path/to/file
  157. abbr -ag decrypt "openssl enc -aes-256-cbc -d -in"
  158. end
  159. abbr -ag sh2 "sha256sum"
  160. #################
  161. # node.js
  162. ##
  163. abbr -ag nrd "npm run dev"
  164. abbr -ag nr "npm run"
  165. # node.js / using the cli repl
  166. if type -q node; and type -q rlwrap;
  167. abbr -ag inode "rlwrap node"
  168. else
  169. # TODO:
  170. # echo "Your gunna need to do a `brew install rlwrap`"
  171. end
  172. #################
  173. # docker tooling
  174. ##
  175. if type -q docker
  176. # abbr -ag dm "docker-machine"
  177. abbr -ag d "docker"
  178. abbr -ag dc "docker-compose"
  179. abbr -ag dta "docker-tags"
  180. abbr -ag di "docker images"
  181. end
  182. #################
  183. # asdf tooling
  184. ##
  185. if type -q asdf
  186. abbr -ag cdasdfsrc "cd $HOME/.asdf"
  187. end
  188. #################
  189. # pyenv tooling
  190. ##
  191. if type -q pyenv
  192. abbr -ag cd-pyenv-src "cd (pyenv root)"
  193. abbr -ag cdpyenvsrc "cd (pyenv root)"
  194. end
  195. #################
  196. # rust tooling
  197. ##
  198. abbr -ag rrepl "rustup run nightly-2016-08-01 ~/.cargo/bin/rusti"
  199. ####################
  200. # VirtualBox tooling
  201. ##
  202. if type -q virtualbox
  203. abbr -ag vboxm "VBoxManage"
  204. abbr -ag vbm "VBoxManage"
  205. end
  206. ####################
  207. # email clients
  208. ##
  209. if type -q neomutt
  210. abbr -ag nmutt "neomutt"
  211. end
  212. ####################
  213. # video processing > ffmpeg
  214. ##
  215. if type -q ffprobe
  216. abbr -ag ffmpeg.rotate \
  217. "echo 'ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotaate=0 output=0 output.mp4'"
  218. abbr -ag ffprobe.howManyFrames \
  219. "ffprobe -v error -select_streams v:0 -show_entries stream=nb_frames -of default=nokey=1:noprint_wrappers=1"
  220. abbr -ag ffprobe-how-many-frames \
  221. "ffprobe -v error -select_streams v:0 -show_entries stream=nb_frames -of default=nokey=1:noprint_wrappers=1"
  222. abbr -ag ffprobe-ls-frames \
  223. "ffprobe -v error -select_streams v:0 -show_entries stream=nb_frames -of default=nokey=1:noprint_wrappers=1"
  224. abbr -ag ffprobe-ls-tframes \
  225. "ffprobe -v error -select_streams v:0 -show_entries stream=nb_frames -of default=nokey=1:noprint_wrappers=1"
  226. end
  227. switch $os # personally defined env var
  228. case Darwin
  229. ################
  230. # macOS specific abbreviations
  231. ##
  232. ## unsorted
  233. abbr -ag dll "diskutil list"
  234. abbr -ag dle "diskutil eject"
  235. abbr -ag dle2 "diskutil eject /dev/disk2"
  236. abbr -ag apl.poweroff "sudo shutdown -h now"
  237. abbr -ag apl.batt.time "mac-batt-time.sh"
  238. abbr -ag apl.get.serial "ioreg -l | grep IOPlatformSerialNumber"
  239. # ffmpeg
  240. abbr -ag mac-ffmpeg-ls-devs "ffmpeg -f avfoundation -list_devices true -i \"\""
  241. abbr -ag ffmpeglsdevs "ffmpeg -f avfoundation -list_devices true -i \"\""
  242. abbr -ag ffmpeg.convert.mk4 "echo 'ffmpeg -i [INPUT.MKV] -map 0 -c copy -c:a aac [OUTPUT.MP4]'"
  243. ##
  244. # mounting network disks, ie. time capsule on LAN
  245. # NOTE: the below abbr uses parameter expansion
  246. # LINK: https://fishshell.com/docs/current/index.html#expand
  247. #
  248. # NOTE: added `-o -d=755,-f=644` per the man page set unix octal bits for files
  249. # NOTE: macos 10.15 ie. catalina changes paths for root file system ie. no more /mnt/path
  250. abbr -ag tcm 'mount -t smbfs -o -d=755,-f=644 //capin:"$TC_PASSWORD"@10.0.1.1/Data /System/Volumes/Data/mnt/tc'
  251. abbr -ag mtc 'mount -t smbfs -o -d=755,-f=644 //capin:"$TC_PASSWORD"@10.0.1.1/Data /System/Volumes/Data/mnt/tc'
  252. abbr -ag utc "umount /System/Volumes/Data/mnt/tc"
  253. abbr -ag df "gdf -h"
  254. abbr -ag tcmafp 'mount -t afp afp://capin:"$TC_PASSWORD"@10.0.1.1/Data /System/Volumes/Data/mnt/tc'
  255. abbr -ag afptcm 'mount -t afp afp://capin:"$TC_PASSWORD"@10.0.1.1/Data /System/Volumes/Data/mnt/tc'
  256. #
  257. set -gx tc '/System/Volumes/Data/mnt/tc'
  258. ####
  259. # macOS Debugging
  260. ##
  261. # TODO: migrate all `mac, mac-` related abbrs, alias, shell scripts to use `apl` prefix
  262. abbr -ag apl.sip.status "csrutil status"
  263. # setup an alias for quicklook from the terminal in macOS
  264. abbr -ag ql "qlmanage -p"
  265. # update location DB
  266. # NOTE: changed abbr to `mac-updatedb` because of homebrew installed
  267. #...`findutils` which provides the `updatedb` bin.
  268. abbr -ag apl.updatedb "sudo /usr/libexec/locate.updatedb"
  269. abbr -ag apl.finder.tog.hidden.files "mac-toggle-hidden-files"
  270. abbr -ag apl.finder.hide.files "mac-toggle-hidden-files"
  271. abbr -ag apl.finder.show.files "mac-toggle-hidden-files"
  272. abbr -ag apl.tog.desktop.icons "mac-toggle-desktop-icons.sh"
  273. abbr -ag apl.ls.users "mac_lsusers"
  274. abbr -ag apl.dmesg 'sudo dmesg >> "$TMPDIR/dmesg.log"; tail -f "$TMPDIR/dmesg.log"'
  275. ################
  276. # launchd / launchctl
  277. ##
  278. abbr -ag lc "launchctl"
  279. ################
  280. # homebrew specifc abbreviations
  281. ##
  282. if type -q brew
  283. # working with brew src and formula
  284. abbr -ag cdbrewsrc "cd (brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core"
  285. abbr -ag cdbrewcache "cd $HOME/Library/Caches/Homebrew"
  286. abbr -ag cdmytap "cd $code/git/github/public/homebrew-us-05"
  287. # brew python shit
  288. abbr -ag cdbrewpysitep "cd (brew --prefix)/opt/python/Frameworks/Python.framework/Versions/Current/lib/python3.9/site-packages"
  289. abbr -ag cdbrewpysp "cd (brew --prefix)/opt/python/Frameworks/Python.framework/Versions/Current/lib/python3.9/site-packages"
  290. abbr -ag cdbrewtaps "/usr/local/Homebrew/Library/Taps"
  291. abbr -ag bog "brew outdated --greedy"
  292. # logs
  293. abbr -ag cdbrewlogs "cd (brew --prefix)/var/log"
  294. # python
  295. abbr -ag hbb "$bp/bin"
  296. abbr -ag hbp3 "$bp/bin/pip3"
  297. abbr -ag hbp3s "$bp/bin/pip_search"
  298. abbr -ag hbpy3 "$bp/bin/python3"
  299. # TODO: why is `bpip` sometimes a func
  300. #
  301. # `bpip` sometimes a fish shell function, see. `funced bpip`
  302. # youtube-dl
  303. abbr -ag you "youtube-dl"
  304. abbr -a -g youdl 'youtube-dl --output "%(title)s.%(ext)s"'
  305. ###
  306. # brew postgresql
  307. # NOTE: i modified the below .plist file to point to postgres@10 directory
  308. abbr -ag brew-pg-start "launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist"
  309. abbr -ag brew-pg-stop "launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist"
  310. ###
  311. # brew redis
  312. abbr -ag brew-redis-start "launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist"
  313. abbr -ag brew-redis-stop "launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist"
  314. ###
  315. # brew OpenSSH built with LibreSSL
  316. abbr -ag brew-ssh-start "sudo launchctl load /Library/LaunchDaemons/com.chrisrjones.sshd.plist"
  317. abbr -ag brew-ssh-stop "sudo launchctl unload /Library/LaunchDaemons/com.chrisrjones.sshd.plist"
  318. abbr -ag ssh-start "sudo launchctl load /Library/LaunchDaemons/com.chrisrjones.sshd.plist"
  319. abbr -ag ssh-stop "sudo launchctl unload /Library/LaunchDaemons/com.chrisrjones.sshd.plist"
  320. ###
  321. # brew MongoDB
  322. abbr -ag brew-mongod-start "launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist"
  323. abbr -ag brew-mongod-stop "launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist"
  324. end
  325. case Linux
  326. ###############################
  327. # sytemd BS 🙄
  328. abbr -ag sc "sudo systemctl"
  329. ###############################
  330. # help pengiuns 🐧 digest apples 🍎
  331. abbr -ag pbcopy "xclip -selection clipboard"
  332. abbr -ag pbpaste "xclip -selection clipboard -o"
  333. abbr -ag say "spd-say"
  334. ###############################
  335. # os/linux/arch
  336. ##
  337. if type -q pacman
  338. abbr -ag pm "sudo pacman"
  339. end
  340. if type -q yay
  341. abbr -ag yays "yay -S"
  342. abbr -ag ys "yay -S"
  343. abbr -ag yss "yay -Ss"
  344. end
  345. ###############################
  346. # Linuxbrew
  347. if type -q brew
  348. # working with brew src and formula
  349. abbr -ag cd-brew-src "cd (brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core"
  350. abbr -ag cdbrewsrc "cd (brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core"
  351. abbr -ag rews "cd (brew --prefix)/Homebrew/Library/Taps/homebrew/homebrew-core"
  352. # youtube-dl
  353. abbr -ag you "youtube-dl"
  354. end
  355. end