5 ms·
I kind of wish there was a shell that had the option for histories localized to a directory. So I can go into a directory and then look at what I was doing when
by UncleOxidant 2y ago
I kind of wish there was a shell that had the option for histories localized to a directory. So I can go into a directory and then look at what I was doing when I was last in that directory. Some complicated compilation command line to compile and link a source file and a bunch of libraries that was run when I was last in that directory, for example. There'd still be the 'history' command for everything and then maybe 'dhistory' for the commands that I ran in that specific directory when I was last there.
- tmm1 2y agoatuin.sh
- coaksford 2y agoI'm an atuin user and if this feature exists, I have not seen it and would love to have it. Could you expand on how to get per-directory history as something separate from global shell history?
- js2 2y ago`atuin search --cwd .` https://docs.atuin.sh/reference/search/#examples https://docs.atuin.sh/reference/search/#examples You could also make "directory" the default filter mode or bind it to up-arrow: https://docs.atuin.sh/configuration/config/#filter_mode https://docs.atuin.sh/configuration/config/#filter_mode https://docs.atuin.sh/configuration/key-binding/#custom-up-arrow-filter-mode https://docs.atuin.sh/configuration/key-binding/#custom-up-a...
- coaksford 2y agoThank you! Now that I know what the feature is even called it's much easier to learn about, definitely adding this to my config file.
- wswope 2y agoHit CTRL + r (by default) in the atuin menu to toggle the filter mode. Super useful. https://docs.atuin.sh/configuration/config/#filter_mode https://docs.atuin.sh/configuration/config/#filter_mode
- nodar86 2y agoYou can do this with a zsh plugin: https://github.com/jimhester/per-directory-history https://github.com/jimhester/per-directory-history
- UncleOxidant 2y agoThis looks promising, thanks!
- johnisgood 2y agoFor bash, you may be able to do something like: function set_histfile { export HISTFILE="$HOME/.bash_history_$(pwd | tr '/' '_')" } PROMPT_COMMAND="set_histfile; $PROMPT_COMMAND" There may be other ways, but probably can't do it without PROMPT_COMMAND. Someone else mentioned "direnv", too.
- emmelaich 2y agoMaybe you could wrangle this with direnv and changing the relevant shell history env vars.
- chrash 2y agonushell does this by default, sort of. it will show you autocompletes that are relevant to the current directory and will fallback to history more generally. i’m a huge nushell fan. if you can stand a non POSIX shell, it’s great for working with any kind of structured data and has a sane mostly FP scripting language
- __MatrixMan__ 2y agoWhen I first switched to nushell as my daily driver, I spent a lot of time integrating fzf in various creative ways, which was a fine learning exercise I guess. But once I realized that the auto complete was sensitive to my cwd, I've since been using my fzf bindings less and less. I'm very happy I made the switch, for this and many other reasons.
- pyinstallwoes 2y agoWhat’s it give you that is significant?
- __MatrixMan__ 2y agoI bet yash is great, sorry for distracting from the topic, but since you asked... It's not one killer feature, but it's a lot of small things that add up to this feeling that POSIX shells are stuck in a rut and that a better world is possible. I'm going to use docker output as an example. I know that you can ask docker for json and then use jq, but let's pretend that what you're working with isn't so friendly as docker. Here's the output of "docker ps", a string: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS 786fc8348b7a postgres:12.6 "docker-entrypoint.s…" 9 hours ago Up 9 hours 127.0.0.1:5432->5432/tcp I'm not proud of it, but I used to write bash scripts which looked like this: line=$(docker ps | grep postgres) echo $line | awk '{print $2}' echo $line | awk -F 'ago' '{print $2}' | sed 's/hours.*/hours/' to get output like this postgres:12.6 Up 9 hours In nushell, that's this (notice that it gets the whitespace right, which is more than I can say for awk). $ docker ps | detect columns --guess | where ($it.IMAGE =~ postgres) | select IMAGE STATUS ╭───┬───────────────┬────────────╮ │ # │ IMAGE │ STATUS │ ├───┼───────────────┼────────────┤ │ 0 │ postgres:12.6 │ Up 9 hours │ ╰───┴───────────────┴────────────╯ This the part where somebody says "powershell does that too", but check out this stackoverflow post on just how that might be done: https://stackoverflow.com/questions/47335781/extract-columns-from-text-based-table-output https://stackoverflow.com/questions/47335781/extract-columns... It's not exactly wow material. Powershell feels to me like it's made by people who want all data to be structured, and who expect the app to do the work of structuring it for them. nushell feels like it's made by people who understand that text is king, and who are willing to attempt taming that beast as-is. Plus there are a lot of batteries-included things that just feel nicer. Like if you want to make an http post request, the command is "http post". Of course you can still use curl, but I feel like this is so much more readable: $ let token = "REDACTED" ( http post -H {Circle-Token : $token} --content-type application/json "https://circleci.com/api/v2/project/gh/job/myproject/pipeline" { branch: "main", parameters: { action: "dothething" }} ) The built in help is excellent (try "help http post"), and the error messages are very pleasant: $ 5 + "5" Error: nu::parser::unsupported_operation × addition is not supported between int and string. ╭─[entry #208:1:1] 1 │ 5 + "5" · ┬ ┬ ─┬─ · │ │ ╰── string · │ ╰── doesn't support these values · ╰── int ╰──── I dunno, it's just nice. I'd be much happier teaching a bunch of scientists to use nushell than I am when teaching them to use bash. When I try to do the latter I feel like I just stepped out of a time warp from the 60's and they think I'm here to punish them.
- m463 2y agoI kind of wish there was a project-oriented complete desktop environment, where you could enter a project and everything was context-sensitive to it. editor, files, directories, shell, browser, whatever. sort of a way to work on projects, then put them on old. and maybe meta-projects to choose, track, arrange, manage some or all projects. maybe by area of responsibility.
- onemoresoop 2y agoOr switchable buffers, some could be dedicated to certain projects.
- saidinesh5 2y agoKDE Plasma had Activities that came close to this i think: https://www.howtogeek.com/be-more-productive-in-linux-with-kde-activities/ https://www.howtogeek.com/be-more-productive-in-linux-with-k... Initially it seemed useful but it quickly felt like more of a chore. At work it's mostly just the same one IDE and one browser. For personal stuff I either used a different user account/different laptop and there was little benefit of activities for me after that.
- akoboldfrying 2y agoI'm not a fan of Docker, but Docker could do this. If that's not enough, there's always whole VMs.
- zeec123 2y agonix and direnv might be worth a look.
- notnmeyer 2y agomy first thought too. on a mac at least it’s a little crusty, but it really does make it convenient to have a project completely and accurately describe its environment.
- svilen_dobrev 2y agolooong time ago - ~2005 maybe? - the late Pieter Hintjens told me about such overarching idea including whole project management and all related ping-pongs - code, data, documents, issues, e-mails, chats, everything - think like one laptop for this project and different one for that project - and that they had at the time approached something like that, and got it mostly working, over linux etc. But AFAIK it never went public and has been abandoned. So the field is ripe for whoever wants to try... though now same accounts to XYZ are being used for hundred things.. [0] https://en.wikipedia.org/wiki/Pieter_Hintjens https://en.wikipedia.org/wiki/Pieter_Hintjens
- dllthomas 2y agoWhat I do is split up my work by context into different screen (or tmux, depending on mood when I set up the computer) sessions. I have a script that attaches one by name if it's present and otherwise creates one with the name in question after setting an environment variable that's therefore inherited by any shells spawned in that screen session. Various things in my bashrc then look at that environment variable to point things at a context specific config directory, including setting HISTFILE to a context specific history file and sourcing a context specific bashrc (in which I often cd to a relevant directory and may set some variables, functions, and aliases specific to the context).
- aoanevdus 2y agoNeat idea. I think I’d like it to maintain a global history and local, with some UI affordance to remind me both exist and perhaps what are the last few entries. A lot of my commands would work in any directory, but sometimes the directory matters and I run it in the wrong place.
- akoboldfrying 2y agoThis is a great idea. Just better history management in general would be such a boon. If I have multiple console windows open, I still don't know what will wind up in .bash_history, and what (which?) history will be there when I start a new one.
- karshan 2y agoFYI The fish shell does this by default.
- oguz-ismail 2y agoBut it's not a POSIX shell
- nasretdinov 2y agoYes, but it's a shell nevertheless :), and it actually now supports some of the most common bashisms, so simple copy-pasted commands designed for bash now work. For any actual scripting IMO bash (or /bin/sh) is still the better choice, since it's installed everywhere, even though it might not have such great syntax.
- johnisgood 2y agoIt is possible to implement, however.
- laktak 2y agoTome does exactly that by replacing the history with playbooks https://github.com/laktak/tome https://github.com/laktak/tome
- oftenwrong 2y agoIf you are open to using zsh, take a look at https://github.com/larkery/zsh-histdb https://github.com/larkery/zsh-histdb . It stores your zsh history in a sqlite3 db. The benefit of this is that your history is well-structured and indexed, and that you can use SQL to query it. The working directory, exit status, and more are included, so you can easily implement your own smart history tools.
- vogelke 2y agoI keep my history in a format showing the current working directory next to each command. If you're interested, have a look at https://bezoar.org/src/dotfiles/README.htm#command-history https://bezoar.org/src/dotfiles/README.htm#command-history