5 ms·
I spend loads of time in a shell. One day I'll push my full dotfiles publicly, but until then here's a few snippets I've found super handy. I'd advise against u
by RadiantSecurity 7y ago
I spend loads of time in a shell. One day I'll push my full dotfiles publicly, but until then here's a few snippets I've found super handy. I'd advise against using them verbatim but there's a few things in there that took some time to figure out. Beware they can be somewhat buggy / break things though.
Highlights include:
- Bind C-c/C-v to Copy/Paste, bind C-g to sigterm (Note: Breaks docker interactive unless you mount bashrc into /etc/bashrc or similar!)
- Autorun tmux on SSH session
- Syntax/colour highlighting in zsh interactive, I think there's some diff/less/man magic in there too!
- Log all shell activity to .shell_logs (Be _super_ careful with this one, breaking it could prevent you opening an interactive shell
- Useful grep defaults, particularly relevant when using .shell_logs
Bashrc: https://gist.github.com/YoloClin/f4c82a6e693000a2da20e8029a49656c https://gist.github.com/YoloClin/f4c82a6e693000a2da20e8029a4...
Zshrc: https://gist.github.com/YoloClin/ffd82f441d292ccc5f25c62a80c78ad0 https://gist.github.com/YoloClin/ffd82f441d292ccc5f25c62a80c...
One thing I've lost love for is Powerline9k - Right-aligned data breaks copy/paste functionality, and patching fonts to get UI-arrows is fiddly for little functional value. If I ever need to fiddle with that stuff again, I'll configure a regular theme to do similar and go without the UI-arrow breaks.
I was considering hiding history-relevant log data (such as current system time) to behind a carriage return, something like PS1="$(date)\r$PS1".
I'm interested in hearing others' cool, non-standard hacks!
- archi42 7y agoInspired by a colleague, I wrote this (for bash): https://gist.github.com/archi/2a2331401842c0548fa8de0f69796f58 https://gist.github.com/archi/2a2331401842c0548fa8de0f69796f... > up 4 go up 4 folders (=> "cd .." 4 times). > up goes up one folder, and you can repeat pressing ENTER to go up one more. Press anything else to drop back to the shell. Could probably be "better" (e.g. no subshells), but works well for me.
- RadiantSecurity 7y agoThats cool! I'm not sure where it comes from, but I get similar behavior in zsh with 'cd ....' - similar doesn't happen in bash though. I mapped 'cd' to 'c' in my bashrc, but while doing it I also mapped 'c' to execute 'ls' as the latter was basically muscle memory whenever I was using cd. The .bashrc function looks like this: c() { builtin cd "$@" && ls; }
- imglorp 7y agoHey guys, I have the same thing, but I called the command ".." (no it doesn't conflict with the directory). ".." by itself is the same as ".. 3" .. () { local arg=${1:-1}; while [ $arg -gt 0 ]; do builtin cd .. &> /dev/null; arg=$(($arg - 1)); done; }
- msoucy 7y agoMine is similar, but only does one cd command - to allow better use of `cd -` up() { local ups="." for((i=0;i<${1:-1};i++)); do ups="${ups}/.." done builtin cd "$ups" }
- anjanb 7y agoI've written aliases like cd2='cd ../..'. similarly cd3='cd ../../..' . Similarly cd4 and cd5. next time I'll think of this!
- awake 7y agoI agree with powerlevel9k. i still have marginal enjoyment from the fiddly things thought and i've switched to powerlevel10k [1]. Its noticeably faster and the default settings are minimalist enough for me. does not fix the fact that you need to install fonts which I can't get working on some terminals (urxvt). [1] https://github.com/romkatv/powerlevel10k https://github.com/romkatv/powerlevel10k
- romka2 7y agoYou can use powerlevel10k with the default system font. It works fine with urxvt without any twiddling.
- RadiantSecurity 7y agoI had issues with urxvt and ended up moving to Kitty (https://github.com/kovidgoyal/kitty https://github.com/kovidgoyal/kitty). I'm not impressed with its' autoupdate feature, but it can be disabled. Apart from that a few visual bugs which are probably to do with nvidia the terminal is great. The best feature? Emojis render flawlessly. I had a proof of concept, but hackernews doesn't support emojis :'(
- notyourday 7y agoWhat saved my ass more times than I can count is that I make sure that whenever I'm on a production machine my prompt has obnoxious color that makes me want to close that window as soon as possible. Production root is made even more visually offensive.