$ sed -i '/secret-command/d' $HISTFILE # deletion of history line containing 'secret-command'
Because if you get it even slightly wrong, you could easily hose your entire history. If it were me, I would just use an editor to delete that line (or two, if timestamps are enabled).Shell Productivity Tips and Tricks
61–70 of 97 posts
Re: Shell Productivity Tips and Tricks
#62The single best shell productivity tip for me was to use z: https://github.com/rupa/z It automatically makes a list of directories you frequently use in your shell and if you type `z a-small-substring-of-the-directory-path` it does a cd to that directory. (e.g. I type `z and` and it changes my current directory to $HOME/Work/Projects/android`). Saved me tons of typing.
Re: Shell Productivity Tips and Tricks
#63Earlier quoted context omitted.
Except with CDPATH the `cd` is usually not an alias. Even `/usr/bin/cd` is aware of CDPATH. It's a bug in the script, just like reacting badly to $IFS or $LANG.
What is /usr/bin/cd for? cd is supposed to be a shell built-in, because running /usr/bin/cd will make another process and that cannot change the current working directory of the shell you are in. EDIT: $ cat /usr/bin/cd #!/usr/bin/sh builtin cd "$@"
$ cat /usr/bin/cd
#!/bin/sh
# $FreeBSD: src/usr.bin/alias/generic.sh,v 1.2 2005/10/24 22:32:19 cperciva Exp $
# This file is in the public domain.
builtin `echo ${0##*/} | tr \[:upper:] \[:lower:]` ${1+"$@"}Re: Shell Productivity Tips and Tricks
#64 :earlier 5m
and copied the line. Afterward, I typed :later 5m
and was back where I started, ready to paste the missing line :-)Re: Shell Productivity Tips and Tricks
#65Best shell productivity trick ever: don't use the shell for anything more complicated than launching executables and use a reasonably modern programming language to achieve all other tasks.
I'd love a good answer here. Shell is clunky and annoying as hell, but a "better" language like python is very verbose for typical shell stuff like process management (processes, pipes, signal handling), small text handling tasks like regex matching or string splitting. Perl is maybe the closest here, but it certainly has it's fair share of annoyances, and I more or less dropped perl for python decades ago and don't…
Re: Shell Productivity Tips and Tricks
#66Earlier quoted context omitted.
What is a reasonably modern language? Everything seems to be at least 20 years old now.
OP might have made their statements tongue in cheek. But there's the truth in there that even programming languages that are 20 years old had a completely different mindset applied to their design process than the original Unix shell which was much more ad-hoc. 40 years ago IT was a completey different environment than 20 years ago.
Re: Shell Productivity Tips and Tricks
#67The single best shell productivity tip for me was to use z: https://github.com/rupa/z It automatically makes a list of directories you frequently use in your shell and if you type `z a-small-substring-of-the-directory-path` it does a cd to that directory. (e.g. I type `z and` and it changes my current directory to $HOME/Work/Projects/android`). Saved me tons of typing.
Re: Shell Productivity Tips and Tricks
#68No matter how many times I read articles like this I always manage to learn something new. For example this time I learned about brace expansion. Will save me retyping a bunch of commands with different text.
Same here. I though I'd seen most of them by now but apparently not :) echo ${MY_VAR:-some_default} is another class of useful functionality.
Re: Shell Productivity Tips and Tricks
#69Today, was actually the first time that I used the vim time travel feature. I noticed that I had deleted a line by accident somewhen during the last few minutes. So I typed :earlier 5m and copied the line. Afterward, I typed :later 5m and was back where I started, ready to paste the missing line :-)
:later 8h
and commit the code before heading home. ;)Re: Shell Productivity Tips and Tricks
#70Two big ones missing. After ctl-r history search: ctl-o ctl-o ctl-o re-execute the history one by one alt-. alt-. alt-. last argument (better ux than that !$ business)